Skip to content

Commit

Permalink
Merge pull request #42 from ichiro-its/hotfix/fix-grpc-when-run-soccer
Browse files Browse the repository at this point in the history
Hotfix/fix grpc when run soccer
  • Loading branch information
marfanr committed May 6, 2024
2 parents 3b4e99c + ecb5c5c commit be6f267
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
33 changes: 32 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,25 @@ add_library(${PROJECT_NAME} SHARED
"src/${PROJECT_NAME}/node/akushon_node.cpp"
)

add_library(${PROJECT_NAME}_exported SHARED
"src/${PROJECT_NAME}/action/model/action_name.cpp"
"src/${PROJECT_NAME}/action/model/action.cpp"
"src/${PROJECT_NAME}/action/model/pose.cpp"
"src/${PROJECT_NAME}/action/node/action_manager.cpp"
"src/${PROJECT_NAME}/action/node/action_node.cpp"
"src/${PROJECT_NAME}/action/process/interpolator.cpp"
"src/${PROJECT_NAME}/action/process/joint_process.cpp"
)

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)


target_include_directories(${PROJECT_NAME}_exported PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

ament_target_dependencies(${PROJECT_NAME}
ament_index_cpp
akushon_interfaces
Expand All @@ -65,6 +80,15 @@ ament_target_dependencies(${PROJECT_NAME}
tachimawari_interfaces
gRPC)

ament_target_dependencies(${PROJECT_NAME}_exported
ament_index_cpp
akushon_interfaces
rclcpp
rclcpp_action
std_msgs
tachimawari
tachimawari_interfaces)

target_link_libraries(${PROJECT_NAME}
gRPC::grpc++_reflection
gRPC::grpc++
Expand All @@ -79,6 +103,13 @@ install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION "bin"
INCLUDES DESTINATION "include")

install(TARGETS ${PROJECT_NAME}_exported
EXPORT export_${PROJECT_NAME}_exported
ARCHIVE DESTINATION "lib"
LIBRARY DESTINATION "lib"
RUNTIME DESTINATION "bin"
INCLUDES DESTINATION "include")

target_compile_options(${PROJECT_NAME} PRIVATE -fPIC)

add_executable(action "src/action_main.cpp")
Expand Down Expand Up @@ -119,5 +150,5 @@ ament_export_dependencies(
tachimawari
tachimawari_interfaces)
ament_export_include_directories("include")
ament_export_libraries(${PROJECT_NAME})
ament_export_libraries(${PROJECT_NAME}_exported)
ament_package()
3 changes: 1 addition & 2 deletions src/akushon/config/grpc/call_data_save_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ void CallDataSaveConfig::HandleRequest()
{
Config config(path_);
try {
nlohmann::json akushon_data = nlohmann::json::parse(request_.json_actions());
config.save_config(akushon_data);
config.save_config(request_.json_actions());
RCLCPP_INFO(rclcpp::get_logger("SaveConfig"), "config has been saved!");
} catch (nlohmann::json::exception e) {
RCLCPP_ERROR(rclcpp::get_logger("SaveConfig"), e.what());
Expand Down
13 changes: 7 additions & 6 deletions src/akushon/config/grpc/call_data_subscribe_current_joints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ CallDataSubscribeCurrentJoints::CallDataSubscribeCurrentJoints(
const std::string& path, rclcpp::Node::SharedPtr& node)
: CallData(service, cq, path), node_(node)
{
current_joint_subscription_ =
node_->create_subscription<tachimawari_interfaces::msg::CurrentJoints>(
"/joint/current_joints", 10,
[this](const tachimawari_interfaces::msg::CurrentJoints::SharedPtr curr_joints) {
curr_joints_.joints = curr_joints->joints;
});

Proceed();
} // namespace akushon

Expand All @@ -49,12 +56,6 @@ void CallDataSubscribeCurrentJoints::WaitForRequest()
void CallDataSubscribeCurrentJoints::HandleRequest()
{
try {
current_joint_subscription_ =
node_->create_subscription<tachimawari_interfaces::msg::CurrentJoints>(
"/joint/current_joints", 10,
[this](const tachimawari_interfaces::msg::CurrentJoints::SharedPtr curr_joints) {
curr_joints_.joints = curr_joints->joints;
});
nlohmann::json curr_joints;

for (const auto & items : curr_joints_.joints) {
Expand Down

0 comments on commit be6f267

Please sign in to comment.