Closed damien-robotsix closed 4 months ago
I think in your case I would rather not use NodeWithMode
, and instead manually create the ros node, which gives you more flexibility.
NodeWithMode
is meant for simplicity, and adding an extra registration call would not allow to use it like this anymore:
rclcpp::spin(std::make_shared<px4_ros2::NodeWithMode<MyExecutor, MyMode>>("my_node"));
Hello,
Here is a suggestion for the classes in NodeWithMode. They immediately trigger the registering but if you don't spin the node fast enough (like I do since I need extra configuration after the creation of the instance)
In all cases, it could be good to either: 1) let the hand to the user to trigger the registration just before spinning the node 2) have a more complex mechanism to check that the node is spinning before doing the registration.
The modification if put in this PR is for solution 1). However, this changes usage as the user must do the registration "manually" before spinning the node. So I am open to suggestions on this.
Also, I did a minor modification to access the Executor because you might need that if you want to access specific functions you implemented in the class inherited from ExecutorBase.
Damien