Ask Your Question

Revision history [back]

No. The value of ros::time::now() depends on whether the parameter use_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 a rosbag, 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).

No. The value of ros::time::now() depends on whether the parameter use_sim_time is set.

    1. If use_sim_time == false, ros::time::now() gives you system time (seconds since 1970-01-01 0:00, so something like 1471868323.123456).
    2. If use_sim_time == true, and you play a rosbag, ros::time::now() gives you the time when the rosbag was recorded (probably also something like 1471868323.123456).
    3. 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).

Cases 2 and 3 are in simulation time, so a trajectory that takes 20 seconds to complete will always have a duration of 20, no matter whether the rosbag / the simulation is running at 0.1x, 1.0x or 10.0x real time.

Your example sounds like it's an offset to whenever the trajectory is started. If that is the case, you should use ros::Duration and not ros::Time for that. Also see the documentation for this.