0
$\begingroup$

Rosanswers logo

Given I have a topic /tf in rosbag, I want to run the rosbag and use lookupTransform to get transform between different frames. The most usual way to get latest transform is lookupTransform("target_frame", "source_frame", rospy.Time(0)). What time system does the function lookupTransform use, does this function use the wall clock time of the computer calling the function lookupTransform, or does it use the timestamp in rosbag. Also, is there any difference when using lookupTransform("target_frame", "source_frame", rospy.Time(0)) and lookupTransform("target_frame", "source_frame", rospy.Time())


Originally posted by hck007 on ROS Answers with karma: 29 on 2023-07-02

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

As mintar puts it:

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).

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.


Originally posted by Guess Giant with karma: 26 on 2023-07-02

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.