ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
![]() | 1 | initial version |
As mintar puts it:
The value of
ros::time::now()
depends on whether the parameteruse_sim_time
is set.
- If
use_sim_time == false
,ros::time::now()
gives you system time (seconds since 1970-01-01 0:00, so something like > 1471868323.123456).- If
use_sim_time == true
, and you play arosbag, ros::time::now()
gives you the time when the rosbag was recorded (probably also something like 1471868323.123456).- If
use_sim_time == true
, and you run a simulator like Gazebo,ros::time::now()
gives you the time from when the simulation was started, starting with zero (so probably something like 63.123456 if the simulator has been running for 63.123456 seconds).
So in your case if you want the nodes to use the time from where the rosbag was recorded, you have to append --clock
to rosbag play
so that it publishes simulated time in /clock
, and well as set the param use_time_time
before any other node starts in a fresh roscore
instance.
There might not be a difference in rospy.TIme(0)
and rospy.Time()
because the default arguments are 0
anyway, see API.