Skip to content

Addition of a Default Node for Hardware Component #2348

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

Merged
merged 29 commits into from
Jul 16, 2025

Conversation

soham2560
Copy link
Contributor

Brief

Now that we have access to the CM's executor from #2323, the user can add their nodes to it and create publishers and subscribers from them. The next step, which this PR addresses, is adding a node by default, with the hardware components name, and giving the user access to it through a get_node method.

Copy link

codecov bot commented Jun 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.88%. Comparing base (c588879) to head (e1724d4).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2348      +/-   ##
==========================================
+ Coverage   88.83%   88.88%   +0.05%     
==========================================
  Files         148      148              
  Lines       16896    16938      +42     
  Branches     1440     1443       +3     
==========================================
+ Hits        15009    15056      +47     
+ Misses       1319     1317       -2     
+ Partials      568      565       -3     
Flag Coverage Δ
unittests 88.88% <100.00%> (+0.05%) ⬆️

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

Files with missing lines Coverage Δ
.../include/hardware_interface/actuator_interface.hpp 91.62% <100.00%> (+0.31%) ⬆️
...ce/include/hardware_interface/sensor_interface.hpp 86.84% <100.00%> (+0.86%) ⬆️
...ce/include/hardware_interface/system_interface.hpp 85.30% <100.00%> (+0.50%) ⬆️
...e_interface_testing/test/test_resource_manager.cpp 99.46% <100.00%> (+0.01%) ⬆️
...e_interface_testing/test/test_resource_manager.hpp 95.00% <100.00%> (+0.55%) ⬆️

... 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.

if (auto locked_executor = params.executor.lock())
{
std::string node_name = params.hardware_info.name;
std::replace(node_name.begin(), node_name.end(), '/', '_');
Copy link
Member

@saikishor saikishor Jul 12, 2025

Choose a reason for hiding this comment

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

Should we later convert it to lower case just in case?. What's your opinion here?.

I'm okay to merge it as it is and then we can deal with it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

refer
7750bd7

saikishor
saikishor previously approved these changes Jul 12, 2025
Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

In general looks great :)

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

LGTM

@soham2560 soham2560 dismissed stale reviews from christophfroehlich and saikishor via 2d70891 July 12, 2025 11:35
@@ -48,6 +48,54 @@ The following is a step-by-step guide to create source files, basic tests, and c
In the first line usually the parents ``on_init`` is called to process standard values, like name. This is done using: ``hardware_interface::(Actuator|Sensor|System)Interface::on_init(info)``.
If all required parameters are set and valid and everything works fine return ``CallbackReturn::SUCCESS`` or ``return CallbackReturn::ERROR`` otherwise.

#. **(Optional) Adding a Diagnostic Publisher**
Copy link
Member

Choose a reason for hiding this comment

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

@soham2560 Can you modify this section here? it would makes sense to be regarding the addition of the node, and how it can be accessed, and the user can use it to add services, publishers etc. May be the below example code, can be an example on what the user can do. It's better to focus on generic things rather than a specific one in the documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

check now

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

The method2 looks good. The described method1 needs some changes

@saikishor
Copy link
Member

@soham2560 there are some failing tests, can you review them?

Thanks

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Just thinking if we can move the logic into any helper methods file, instead of duplicating it in every interface class?

@soham2560
Copy link
Contributor Author

Just thinking if we can move the logic into any helper methods file, instead of duplicating it in every interface class?

Theres a future PR where we merge system, sensor and actuator since theres a lot of overlapping code, that should take care of this imo, or should it be done here regardless?

@soham2560 soham2560 requested a review from saikishor July 15, 2025 07:07
@christophfroehlich
Copy link
Contributor

Just thinking if we can move the logic into any helper methods file, instead of duplicating it in every interface class?

Theres a future PR where we merge system, sensor and actuator since theres a lot of overlapping code, that should take care of this imo, or should it be done here regardless?

ok if there are already plans in doing so, i'm also fine with that

Copy link
Contributor

@MarqRazz MarqRazz left a comment

Choose a reason for hiding this comment

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

Is there anything special we need to do to make it so that the interface_node and the CM_node do shared memory ros topics because they are part of the same component?

Comment on lines +208 to +209
"Executor is not available during hardware component initialization for '%s'. Skipping "
"node creation!",
Copy link
Contributor

Choose a reason for hiding this comment

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

How often does this happen? Can we try for the lock more than once?

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't happen as long as the Executor is a valid pointer. We had to add it as we started adding this new API now, so all the tests are calling this without a valid executor.

@saikishor
Copy link
Member

saikishor commented Jul 15, 2025

Is there anything special we need to do to make it so that the interface_node and the CM_node do shared memory ros topics because they are part of the same component?

This can be done through NodeOptions by setting the use_intra_process_comms. We can add an API something like below

virtual rclcpp::NodeOptions define_custom_node_options() const
{
rclcpp::NodeOptions node_options;
// \note The versions conditioning is added here to support the source-compatibility with Humble
#if RCLCPP_VERSION_MAJOR >= 21
node_options.enable_logger_service(true);
#else
node_options.allow_undeclared_parameters(true);
node_options.automatically_declare_parameters_from_overrides(true);
#endif
return node_options;
}

May be we can do it in a separate PR?

@bmagyar bmagyar merged commit d376254 into ros-controls:master Jul 16, 2025
23 of 28 checks passed
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.

5 participants