-
Notifications
You must be signed in to change notification settings - Fork 347
Added CMs MultiThreadedExecutor as an arg to on_init()
#2323
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
base: master
Are you sure you want to change the base?
Conversation
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.
A partial review here
I think as this is an API breaking change, we should open the corresponding PRs in the packages like gz_ros2_control and also webots_ros2_control probably? We can discuss this part when we finish the final review of this PR
hardware_interface/include/hardware_interface/actuator_interface.hpp
Outdated
Show resolved
Hide resolved
hardware_interface/include/hardware_interface/sensor_interface.hpp
Outdated
Show resolved
Hide resolved
hardware_interface/include/hardware_interface/sensor_interface.hpp
Outdated
Show resolved
Hide resolved
hardware_interface/include/hardware_interface/actuator_interface.hpp
Outdated
Show resolved
Hide resolved
hardware_interface/include/hardware_interface/system_interface.hpp
Outdated
Show resolved
Hide resolved
hardware_interface/include/hardware_interface/system_interface.hpp
Outdated
Show resolved
Hide resolved
@saikishor have added PR at ros-controls/gz_ros2_control#606 |
…ce.hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
…ce.hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
Awesome. Sorry I missed that one |
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
….hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
Co-authored-by: Sai Kishor Kothakota <[email protected]>
…t.cpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
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.
Please check the pre-commit failures (have you installed it properly?)
apologies, forgot to rerun pre-commit after the suggested changes |
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.
The changes itself LGTM
after some discussion with @saikishor and @bmagyar we have decided to go for a Pimpl approach on this PR, putting in draft till then |
@bmagyar @saikishor do let me know how this looks |
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.
Thank you for the changes. They are very good
Some nitpicking and other recommended changes
explicit HardwareComponentInterfaceParams( | ||
const hardware_interface::HardwareInfo & hardware_info_param, | ||
rclcpp::Executor::WeakPtr executor_param) | ||
: hardware_info(hardware_info_param), executor(executor_param) | ||
{ | ||
} | ||
|
||
explicit HardwareComponentInterfaceParams(hardware_interface::HardwareComponentParams & params) | ||
: hardware_info(params.hardware_info), executor(params.executor) | ||
{ | ||
} | ||
}; |
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.
I'm not sure if it is better to have no constructors here, because at some point, we might break this one too. Instead, filling in the information individually per element is better. We can always add them back in future
I don't have a strong opinion here
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.
refer #2323 (comment)
explicit HardwareComponentParams( | ||
const hardware_interface::HardwareInfo & hardware_info_param, rclcpp::Logger logger_param, | ||
rclcpp::Clock::SharedPtr clock_param, rclcpp::Executor::WeakPtr executor_param) | ||
: hardware_info(hardware_info_param), | ||
logger(logger_param), | ||
clock(clock_param), | ||
executor(executor_param) | ||
{ | ||
} |
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.
Same here
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.
refer #2323 (comment)
hardware_interface/include/hardware_interface/types/resource_manager_params.hpp
Outdated
Show resolved
Hide resolved
hardware_interface/include/hardware_interface/types/resource_manager_params.hpp
Outdated
Show resolved
Hide resolved
hardware_interface/include/hardware_interface/types/resource_manager_params.hpp
Outdated
Show resolved
Hide resolved
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger_interface, | ||
rclcpp::Executor::SharedPtr executor); | ||
|
||
/// Default constructor for the Resource Manager. | ||
explicit ResourceManager(rclcpp::Clock::SharedPtr clock, rclcpp::Logger logger); | ||
explicit ResourceManager( | ||
rclcpp::Clock::SharedPtr clock, rclcpp::Logger logger, rclcpp::Executor::SharedPtr executor); |
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.
With the internal structure in place, do we have to extend the other constructors?. For the newer features, they can directly use the newer struct 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.
The thing in my mind was that it seems odd to just extend one variant, maybe a seperate constructor not dependent on previous ones would be better what do you think?
rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface, | ||
rclcpp::Executor::WeakPtr executor); |
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.
same here. do we have to extend this one too?
const rclcpp_lifecycle::State & initialize( | ||
const HardwareInfo & system_info, rclcpp::Logger logger, | ||
rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface); | ||
rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface, | ||
rclcpp::Executor::WeakPtr executor); |
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.
same here
hardware_interface::HardwareComponentParams params( | ||
individual_hardware_info, resource_storage_->rm_logger_, resource_storage_->rm_clock_, | ||
executor_); |
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.
May be we should store the params in the class, so we could use it later? This can help us avoid any human errors
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.
makes sense, should we do it for all the structs or just this one in your opinion? and I am assuming it should be stored in resource manager publicly?
auto test_executor = std::make_shared<rclcpp::executors::SingleThreadedExecutor>(); | ||
auto state = sensor_hw.initialize( | ||
mock_hw_info, node->get_logger(), node->get_node_clock_interface(), test_executor); |
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.
If we would have left the old method, we don't have to create all these changes
…anager_params.hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
…anager_params.hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
…anager_params.hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
…anager_params.hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
…omponent_params.hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
@@ -158,18 +163,23 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod | |||
info_.thread_priority); | |||
async_handler_->start_thread(); | |||
} | |||
return on_init(hardware_info); | |||
return on_init(hardware_interface::HardwareComponentInterfaceParams(params)); |
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.
not sure about it but if we did not mark the constructor explicit, this could be as short as
return on_init(hardware_interface::HardwareComponentInterfaceParams(params)); | |
return on_init(params); |
Brief
This addition is the first step towards solving #2141 (also #1732 in some way). The intention currently is to give the user access to the MultiThreadedExecutor so that they can add nodes to it and publish if necessary. A future PR will add a node by default with the hardware_components name
Upon further review, another crucial change is introduced in this PR, we are constructing three structs
on_init()
and parsed by user to get all relevant data (hardware_info and executor at this point)How was this tested?
Unfortunately the demo examples aren't directly compatible due to the changed API so had to modify them a bit, but was able to add a node to the executor and check
Couple of points to note