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

Reproduce Load controller + Fix with new API #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion imu_sensor_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if(BUILD_TESTING)

add_rostest_with_parameters_gmock(test_load_imu_sensor_broadcaster
test/test_load_imu_sensor_broadcaster.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/imu_sensor_broadcaster_params.yaml)
${CMAKE_CURRENT_SOURCE_DIR}/test/imu_sensor_broadcaster_no_params.yaml)
target_include_directories(test_load_imu_sensor_broadcaster PRIVATE include)
target_link_libraries(test_load_imu_sensor_broadcaster
imu_sensor_broadcaster
Expand Down
7 changes: 5 additions & 2 deletions imu_sensor_broadcaster/src/imu_sensor_broadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ controller_interface::CallbackReturn IMUSensorBroadcaster::on_init()
{
try
{
param_listener_ = std::make_shared<ParamListener>(get_node());
params_ = param_listener_->get_params();
param_listener_ = std::make_shared<ParamListener>(get_node(), "", false);
}
catch (const std::exception & e)
{
Expand All @@ -43,6 +42,10 @@ controller_interface::CallbackReturn IMUSensorBroadcaster::on_init()
controller_interface::CallbackReturn IMUSensorBroadcaster::on_configure(
const rclcpp_lifecycle::State & /*previous_state*/)
{
if (!param_listener_->are_params_initialized())
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need this in the client code, or should we put this in the library?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I think it won't be needed for sure if you call the initialize_parameters on the first instance. If the get_params is called, then it throws an exception anyway.

We can remove the check if you prefer

{
param_listener_->initialize_parameters();
}
params_ = param_listener_->get_params();

imu_sensor_ = std::make_unique<semantic_components::IMUSensor>(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test_imu_sensor_broadcaster:
ros__parameters:

test: "hello"
#sensor_name: "imu_sensor"
#frame_id: "imu_sensor_frame"