rclcpp::Time() and rclcpp::Clock()
Hello all,
I have 4 questions about ros2 time, please see the following part :)
Q1: Which one publish /clock
topic?
- When i only
ros2 bag play [some_ros2_bag]
, withros2 topic list
, there is no topic/clock
. - When in code set
use_sim_time
true, andros2 bag play [some_ros2_bag]
, withros2 topic info /clock
, it tells meType: rosgraph_msgs/msg/Clock, Publisher count: 0, Subscription count: 1
. Nobody publish/clock
topic. - In ros1 with
rosbag play [ros1_bag] --clock
androstopic info /clock
, it tells me play bag node is publishing the data.
Q2: How should i do to let a offline slam or localization system run with simulation time, that is to say, with the timestamp of data played in the bag ? Because i can set -r
param to control play bag data speed. Record ros2 bag data by ros2 bag record [topic_1] [topic_2]
.
In the http://design.ros2.org/articles/clock_and_time.html article, it says
The ROSTime will report the same as SystemTime when a ROS Time Source is not active. When the ROS time source is active ROSTime will return the latest value reported by the Time Source. ROSTime is considered active when the parameter use_sim_time is set on the node.
Q3: When creating a rclcpp::Clock() object, as the aboving info says, why not rclcpp::Clock(RCL_ROS_TIME)
as the default time source, but rclcpp::Clock (RCL_SYSTEM_TIME)
, see here.
Q4: In ros1 tf lookup transform, ros::Time(0)
param means the latest available transform. In ros2, is the corresponding param rclcpp::Time(0)
?
Thanks for your help and time ! Best regards