I am trying to create a controller plugin for the nav2 stack. As per the tutorials, I have rclcpp_lifecycle::LifecycleNode shared pointer which I use to create a clock (node->get_clock()) and use clock-> now() to get the latest time. I have created libraries which are used with this plugin. I want to get the latest time in these libraries without having to pass down the node handles.
In ROS1 we could create node handles in the library itself and get the latest time using ros::Time::now() but the library itself wouldn't be a node. However, I don't think we can have a ros2 node handle spawned out of the blue, without it being tied to an actual node. I don't want to have to pass a node handle 3 layers into this library for two timers that can be paused with simulation time. I have seen some examples where to get the latest time without node handles they use rclccpp::Time() but I am not sure what it means and what it does. Also, is there an alternative to ros::Time::now() or ros::Time(0) in ROS2 without passing down the node handles as mentioned earlier and what exactly does rclcpp::Time() mean without any node initialisation?
I am using ROS2 Foxy in Ubuntu 20.04
Originally posted by Divyanshu on ROS Answers with karma: 15 on 2020-11-19
Post score: 0