-
Notifications
You must be signed in to change notification settings - Fork 269
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
Add logger and clock interfaces from ResourceManager to HardwareComponent interfaces #1585
base: master
Are you sure you want to change the base?
Add logger and clock interfaces from ResourceManager to HardwareComponent interfaces #1585
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1585 +/- ##
==========================================
- Coverage 87.79% 87.75% -0.04%
==========================================
Files 102 102
Lines 8764 8797 +33
Branches 787 789 +2
==========================================
+ Hits 7694 7720 +26
- Misses 792 798 +6
- Partials 278 279 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
How can we promote this new feature? Please add something to the release notes, maybe also hardware components docs. Possibly we can use this in the demos as well?
Yes, we can use them in the demos as well. I've used it inside the MockHardwareSystem in this PR. |
This pull request is in conflict. Could you fix it @saikishor? |
…d clock interfaces
5ce5a44
to
812d103
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
rclcpp::Clock get_clock() const | ||
{ | ||
if (clock_interface_) | ||
{ | ||
return *(clock_interface_->get_clock()); | ||
} | ||
else | ||
{ | ||
return rclcpp::Clock(RCL_ROS_TIME); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this misleading? If we have no clock we shouldn't return any...
rclcpp::Clock get_clock() const | |
{ | |
if (clock_interface_) | |
{ | |
return *(clock_interface_->get_clock()); | |
} | |
else | |
{ | |
return rclcpp::Clock(RCL_ROS_TIME); | |
} | |
} | |
std::optional<rclcpp::Clock> get_clock() const | |
{ | |
return clock_interface_ ? std::optional<rclcpp::Clock>{*(clock_interface_->get_clock())} : std::nullopt; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better yet, just use the existing sharedptr
rclcpp::Clock get_clock() const | |
{ | |
if (clock_interface_) | |
{ | |
return *(clock_interface_->get_clock()); | |
} | |
else | |
{ | |
return rclcpp::Clock(RCL_ROS_TIME); | |
} | |
} | |
rclcpp::node_interfaces::NodeClockInterface::SharedPtr get_clock() const | |
{ | |
return clock_interface_; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, maybe shared_ptr is better and makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe even better yet... can we validate the clock interface sharedptr we are getting and turn it into a clock? Is that dangerous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*(clock_interface_->get_clock());
That's what I'm doing here right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but what I mean is we should do this at the top and not even accept invalid clocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bmagyar Yes, I just pushed the changes!
With the new changes, we will need to push a fix to ros2_controllers as well inorder to fix some load tests. For instance this one
Before:
controller_manager::ControllerManager cm(
std::make_unique<hardware_interface::ResourceManager>(
ros2_control_test_assets::minimal_robot_urdf),
executor, "test_controller_manager");
Now:
controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::minimal_robot_urdf, "test_controller_manager");
Take a look at the changes and let me know if they look fine to you. If yes, I will open a PR for the controllers as well.
While making these modifications, I was under the dilemma to still have the NodeClockInterface
and NodeLoggingInterface
or just replace them with the rclcpp::Clock::SharedPtr
and rclcpp::Logger
so, it is easy on the tests, but just in case, I left the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the PR of ros2_controllers: ros-controls/ros2_controllers#1184
As discussed in the WG meeting on 19th June 2024, I've added the logging and the clock interfaces to ResourceManager and HardwareComponents. I've also modified all the RCUTILS logging to RCLCPP logging.
Thank you