mateusmenezes95 / omnidirectional_controllers

ROS2 controllers for Omnidirectional robots with three wheels
MIT License
26 stars 4 forks source link

std::shared_ptr<rclcpp_lifecycle::LifecycleNode> controller_interface::ControllerInterfaceBase::node_’ is private within this context #1

Closed robotcopper closed 9 months ago

robotcopper commented 9 months ago

Hello,

first of all, thank you for your wonderful work.

I am currently trying to use it for my own 3-wheel omnidirectional robot project under ROS 2 Humble. However, after successfully resolving an initial issue with the inclusion: #include "tf2/LinearMath/Quaternion.h" without difficulty. I am now encountering hundreds of error messages, all with the same origin: error: ‘std::shared_ptr controllerinterface::ControllerInterfaceBase::node’ is private within this context.

I cannot seem to figure out where the problem is, considering that the only modification I have made so far is adding tf2 and tf2_ros to the packages in the CMakeLists to address the previously mentioned dependency issue. Would you be able to shed some light on the matter?

mateusmenezes95 commented 9 months ago

Hello @robotcopper, thank you!

I am happy the other robotics developers are using my package.

The problem is most likely due to incompatible ROS2 versions. I developed this controller on Foxy Fitzroy, the first Long Time Support (LTS) version. Therefore, it is expected that there will be sudden API changes between Foxy and Humble, especially since the Foxy version was the first LTS version. I recommend two ways:

  1. If possible, test the controller in the ROS2 Foxy;
  2. If option 1 is not viable, try to figure out the line of the code breaking the compilation when using the Humble version. You can share the build log here so I can try to help you.

Unfortunately, at the moment, I don't have time to port the controller to the Humble or even the Iron Irwin (the last LTS version).

robotcopper commented 9 months ago

Thank you for your fast answer.

After hours spent on my errors, I finally got it by changing "node_" in the omnidirectional_controller.cpp to "this->get_node()".

Another error was in omnidirectional_controller.hpp: in both "controller_interface::return_type" declarations, the "override" declaration was not appreciated, so I took the risk to remove it ["override"].

Finally, only one error persists, which is the following:

"/opt/ros/humble/include/class_loader/class_loader/meta_object.hpp: In instantiation of ‘B* class_loader::impl::MetaObject<C, B>::create() const [with C = omnidirectional_controllers::OmnidirectionalController; B = controller_interface::ControllerInterface]’: /opt/ros/humble/include/class_loader/class_loader/meta_object.hpp:216:7: required from here /opt/ros/humble/include/class_loader/class_loader/meta_object.hpp:218:12: error: invalid new-expression of abstract class type ‘omnidirectional_controllers::OmnidirectionalController’ 218 | return new C; | ^~~~~ In file included from /home/floris/ros2_ws/src/omnidirectional_controllers/src/omnidirectional_controller.cpp:23: /home/floris/ros2_ws/src/omnidirectional_controllers/include/omnidirectional_controllers/omnidirectional_controller.hpp:45:7: note: because the following virtual functions are pure within ‘omnidirectional_controllers::OmnidirectionalController’: 45 | class OmnidirectionalController : public controller_interface::ControllerInterface { | ^~~~~~~~~ In file included from /opt/ros/humble/include/controller_interface/controller_interface.hpp:22, from /home/floris/ros2_ws/src/omnidirectional_controllers/include/omnidirectional_controllers/omnidirectional_controller.hpp:30, from /home/floris/ros2_ws/src/omnidirectional_controllers/src/omnidirectional_controller.cpp:23: /opt/ros/humble/include/controller_interface/controller_interface_base.hpp:132:26: note: ‘virtual rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn controller_interface::ControllerInterfaceBase::on_init()’ 132 | virtual CallbackReturn on_init() = 0; | ^~~ /opt/ros/humble/include/controller_interface/controller_interface_base.hpp:144:23: note: ‘virtual controller_interface::return_type controller_interface::ControllerInterfaceBase::update(const rclcpp::Time&, const rclcpp::Duration&)’ 144 | virtual return_type update(const rclcpp::Time & time, const rclcpp::Duration & period) = 0; | ^~"

I'm not very comfortable with C++, but this error is unlike any I have encountered before. Any advice?

mateusmenezes95 commented 9 months ago

The problem that you are facing is due to the class inheritance chain. Please, share the repository with me. I will try to solve the problem from this point.

robotcopper commented 9 months ago

Oh thank you verymutch because i feel quite lost in front of this error. my repository is here: https://github.com/robotcopper/omnidirectional_controllers_humble (it's temporary public to let you access it but i will change that after. I'm not use to github when it's about public sharing. Hope you don't mind).

You will see that i did not make a lot of changes. I faced the error pretty fast. I hope you will be able to help me.

mateusmenezes95 commented 9 months ago

Thank you @robotcopper

So, I took advantage of what you had already done and implemented the port straight here in my repository. The inheritance problem was actually simple to solve. To help you understand what was done, take a look at the commit https://github.com/mateusmenezes95/omnidirectional_controllers/commit/66ac7599f9de699dd914fe91719a6f45b29def19. Please try to use the new humble branch of this repository. If you have any more problems, you can talk here

robotcopper commented 9 months ago

Thank you so much for your help @mateusmenezes95.