Skip to content

Migrate tests to use new Handle API#2369

Open
saikishor wants to merge 6 commits into
ros-controls:masterfrom
pal-robotics-forks:migrate/new_handles/api
Open

Migrate tests to use new Handle API#2369
saikishor wants to merge 6 commits into
ros-controls:masterfrom
pal-robotics-forks:migrate/new_handles/api

Conversation

@saikishor

Copy link
Copy Markdown
Member

This changes the StateInterface and CommandInterfaces used inside the tests to use the new Handles API and to move away from the deprecated API, so it'll be easier to break the API of the Handle where it needed a variable reference parsed. This is the first step toward that direction

@codecov

codecov Bot commented May 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.66%. Comparing base (2da9e91) to head (6e69ff6).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2369      +/-   ##
==========================================
- Coverage   86.71%   86.66%   -0.05%     
==========================================
  Files         148      148              
  Lines       15832    15818      -14     
  Branches     1347     1347              
==========================================
- Hits        13728    13709      -19     
- Misses       1609     1612       +3     
- Partials      495      497       +2     
Flag Coverage Δ
unittests 86.66% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ned_filter_controller/test/test_chained_filter.cpp 98.33% <ø> (ø)
...ned_filter_controller/test/test_chained_filter.hpp 100.00% <ø> (ø)
...r_controller/test/test_multiple_chained_filter.cpp 98.11% <ø> (ø)
...r_controller/test/test_multiple_chained_filter.hpp 100.00% <ø> (ø)
...ive_controller/test/test_diff_drive_controller.cpp 95.09% <100.00%> (+0.02%) ⬆️
..._controllers/test/test_gpio_command_controller.cpp 97.67% <ø> (ø)
...r_broadcaster/test/test_gps_sensor_broadcaster.cpp 100.00% <ø> (ø)
..._broadcaster/test/test_joint_state_broadcaster.cpp 96.68% <100.00%> (-0.17%) ⬇️
pose_broadcaster/test/test_pose_broadcaster.hpp 88.88% <ø> (ø)
...broadcaster/test/test_range_sensor_broadcaster.cpp 94.68% <100.00%> (+0.23%) ⬆️
... and 1 more

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@saikishor saikishor force-pushed the migrate/new_handles/api branch from e7655aa to 6e69ff6 Compare June 16, 2026 20:39

@christophfroehlich christophfroehlich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In principle LGTM, but I suppose another cleanup round, using the member variables with std::to_string() if they are used in the test assertions later.

Comment on lines +57 to +60
const std::vector<double> joint_states_ = {1.1};

StateInterface::SharedPtr joint_1_pos_ =
std::make_shared<StateInterface>(joint_names_[0], HW_IF_POSITION, &joint_states_[0]);
std::make_shared<StateInterface>(joint_names_[0], HW_IF_POSITION, "double", "1.1");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
const std::vector<double> joint_states_ = {1.1};
StateInterface::SharedPtr joint_1_pos_ =
std::make_shared<StateInterface>(joint_names_[0], HW_IF_POSITION, &joint_states_[0]);
std::make_shared<StateInterface>(joint_names_[0], HW_IF_POSITION, "double", "1.1");
const std::vector<double> joint_states_ = {1.1};
StateInterface::SharedPtr joint_1_pos_ = std::make_shared<StateInterface>(
joint_names_[0], HW_IF_POSITION, "double", std::to_string(joint_states_[0]));

or remove the joint_states_ member (used twice in cpp)

Comment on lines +50 to 56
const std::vector<double> joint_states_ = {1.1, 2.2};

StateInterface::SharedPtr joint_1_pos_ =
std::make_shared<StateInterface>(joint_names_[0], HW_IF_POSITION, &joint_states_[0]);
std::make_shared<StateInterface>(joint_names_[0], HW_IF_POSITION, "double", "1.1");
StateInterface::SharedPtr joint_2_pos_ =
std::make_shared<StateInterface>(joint_names_[1], HW_IF_POSITION, &joint_states_[1]);
std::make_shared<StateInterface>(joint_names_[1], HW_IF_POSITION, "double", "2.2");
rclcpp::executors::SingleThreadedExecutor executor;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
const std::vector<double> joint_states_ = {1.1, 2.2};
StateInterface::SharedPtr joint_1_pos_ =
std::make_shared<StateInterface>(joint_names_[0], HW_IF_POSITION, &joint_states_[0]);
std::make_shared<StateInterface>(joint_names_[0], HW_IF_POSITION, "double", "1.1");
StateInterface::SharedPtr joint_2_pos_ =
std::make_shared<StateInterface>(joint_names_[1], HW_IF_POSITION, &joint_states_[1]);
std::make_shared<StateInterface>(joint_names_[1], HW_IF_POSITION, "double", "2.2");
rclcpp::executors::SingleThreadedExecutor executor;
const std::vector<double> joint_states_ = {1.1, 2.2};
StateInterface::SharedPtr joint_1_pos_ = std::make_shared<StateInterface>(
joint_names_[0], HW_IF_POSITION, "double", std::to_string(joint_states_[0]));
StateInterface::SharedPtr joint_2_pos_ = std::make_shared<StateInterface>(
joint_names_[0], HW_IF_POSITION, "double", std::to_string(joint_states_[1]));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  hardware_interface::StateInterface::SharedPtr range_ =
    std::make_shared<hardware_interface::StateInterface>(
      sensor_name_, "range", "double", std::to_string(sensor_range_));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants