Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuse -> ROS 2 fuse_models: Port fuse_models #304

Merged
merged 4 commits into from
Jan 14, 2023

Conversation

methylDragon
Copy link
Collaborator

See: #276

Description

This PR ports the entirety of fuse_models, including:

  • CMakeLists and packages
  • Source code
  • Tests
  • Other stuff like docs are in other PRs.

Pay special attention to the parameter and service namespacing.
In ROS 1 nodehandles were used to attach a node namespace, and then also the plugin's name (as a sub namespace). In the ROS 2 version I prepend the plugin's name, and ignore the node's namespace (since parameters are meant to be local to the node in ROS 2.)


I fixed some bugs in the parameter code (namely a missing empty check), and, perhaps more importantly, I had to shift the service description and generation from fuse_models to fuse_msgs due to:

I needed to shift it because otherwise there wouldn't be a way to generate the appropriate libraries and targets without also masking the core fuse_models library that needs to be generated.

The shift now means every service namespace will be shifted to fuse_msgs instead.

Notes

Pinging @svwilliams for visibility.

@@ -110,7 +110,7 @@ class BatchOptimizer : public Optimizer
BatchOptimizer(
fuse_core::Graph::UniquePtr graph,
const ros::NodeHandle& node_handle = ros::NodeHandle(),
const ros::NodeHandle& private_node_handle = ros::NodeHandle("~"));
const ros::NodeHandle& private_node_handle = ros::NodeHandle(""));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably could remove the fuse_optimizers changes from this PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


###########
## Build ##
###########
add_compile_options(-Wall -Werror)

include_directories(include)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_include_directories() used below should be sufficient

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)
target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}
${CERES_LIBRARIES}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, I'd recommend the target name Ceres::ceres instead. It looks like we're already using it in fuse_core.

Ceres::ceres

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${geometry_msgs_TARGETS}
${nav_msgs_TARGETS}
pluginlib::pluginlib
${rclcpp_components_TARGETS}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend against rclcpp_components_TARGETS as it includes the component manager. I think the target to use instead is rclcpp_components::component.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

benchmark_unicycle_2d_state_cost_function
benchmark
${PROJECT_NAME}
${catkin_LIBRARIES}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, remove catkin_LIBRARIES

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

benchmark
${PROJECT_NAME}
${catkin_LIBRARIES}
${CERES_LIBRARIES}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ceres::ceres

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)
set_target_properties(benchmark_unicycle_2d_state_cost_function
PROPERTIES
CXX_STANDARD 14
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++ 17

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

differential = fuse_core::getParam(interfaces, ns + "differential", differential);
differential = fuse_core::getParam(interfaces, ns + "differential", differential);
differential = fuse_core::getParam(interfaces, ns + "differential", differential);
differential = fuse_core::getParam(interfaces, ns + "differential", differential);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like all the parameter and variable names got changed to "differential" in this file.

Copy link
Collaborator Author

@methylDragon methylDragon Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pub_options.callback_group = cb_group_;

// NOTE(CH3): We might need to prepend the name here like with the other publishers
// ... But will that cause the subscriptions on the models to fail???
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What name might need to be prepended? I see jointTopicName is already used below.

Copy link
Collaborator Author

@methylDragon methylDragon Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this comment was about using that joinTopicName call. I had mistakenly thought that the original ROS 1 code didn't use the same sort of private node handle namespacing like the other publishers. Sorry for the noise 😬

Comment removed: https://github.com/locusrobotics/fuse/compare/cfe9352ddd4b3fd14865ff6692b219a6d1336962..136e98e0578314dfc8495257404250aff9cf3199

@methylDragon methylDragon force-pushed the rolling-models branch 11 times, most recently from e633ec1 to 424beef Compare January 10, 2023 12:58
@sloretz
Copy link
Collaborator

sloretz commented Jan 10, 2023

@ros-pull-request-builder retest this please!

@sloretz
Copy link
Collaborator

sloretz commented Jan 10, 2023

Looks like we'll need tf2_2d released into rolling for the PR job to pass. I'll look into creating a release repo for it.

}
auto srv = std::make_shared<std_srvs::srv::Empty::Request>();
// No need to spin since node is optimizer node, which should be spinning
auto result_future = reset_client_->async_send_request(srv);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to spin but maybe need to wait for the future to complete? result_future->wait(). That would make sure the reset has been processed before the graph is sent below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! 85aa1bc

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize we discovered and fixed an issue with this in the fuse_optimizers PR by avoiding blocking in the set_pose service callback, but I'm fine to merge this PR as is and continue the discussion there.

}
auto srv = std::make_shared<std_srvs::srv::Empty::Request>();
// No need to spin since node is optimizer node, which should be spinning
auto result_future = reset_client_->async_send_request(srv);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about maybe needing to wait on the result future

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! 85aa1bc

Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
@sloretz
Copy link
Collaborator

sloretz commented Jan 13, 2023

@ros-pull-request-builder retest this please

Copy link
Collaborator

@sloretz sloretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving knowing that this PR has a bug in graph_ignition and unicycle_2d_ignition that causes the executor to be blocked waiting for the reply to the reset service, because the fix is in the next PR #307

CI fails because tf2_2d needs to be released to Rolling. In the meantime I did colcon build, colcon test locally and I only see linting test failures, which we've also been addressing in follow up PRs.

rolling:osrf> colcon test-result
build/fuse_models/Testing/20230113-2357/Test.xml: 12 tests, 0 errors, 4 failures, 0 skipped
build/fuse_models/test_results/fuse_models/copyright.xunit.xml: 48 tests, 0 errors, 2 failures, 0 skipped
build/fuse_models/test_results/fuse_models/cpplint.xunit.xml: 512 tests, 0 errors, 509 failures, 0 skipped
build/fuse_models/test_results/fuse_models/uncrustify.xunit.xml: 48 tests, 0 errors, 48 failures, 0 skipped
build/fuse_models/test_results/fuse_models/xmllint.xunit.xml: 2 tests, 0 errors, 1 failure, 0 skipped

Summary: 3029 tests, 0 errors, 564 failures, 529 skipped

}
auto srv = std::make_shared<std_srvs::srv::Empty::Request>();
// No need to spin since node is optimizer node, which should be spinning
auto result_future = reset_client_->async_send_request(srv);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize we discovered and fixed an issue with this in the fuse_optimizers PR by avoiding blocking in the set_pose service callback, but I'm fine to merge this PR as is and continue the discussion there.

@methylDragon methylDragon merged commit 5c46265 into locusrobotics:rolling Jan 14, 2023
@methylDragon methylDragon deleted the rolling-models branch January 19, 2023 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants