Ask Your Question
1

time from ros::time(0) to ros::time::now()

asked 2016-08-22 05:26:57 -0500

Sed gravatar image

Hello,

I have a trajectory that goes from 0s to 20s and i want to test it with ROS.

if i use

       start_time=ros::time(0);
       end_time=20; (seconds)

would the intermediate time steps from ros::time::now() be between 0 ans 20?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
7

answered 2016-08-22 07:21:44 -0500

updated 2016-08-22 07:25:53 -0500

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.

edit flag offensive delete link more

Comments

Thank you... it is more clear now in my head

Sed gravatar imageSed ( 2016-08-22 07:53:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-22 05:26:57 -0500

Seen: 3,784 times

Last updated: Aug 22 '16