Ask Your Question
0

replacement for rospy.Time(0) in ROS2?

asked 2021-10-07 16:41:51 -0500

janolus gravatar image

Hi, I want to lookup the latest transformation in a tf buffer. In ROS 1 used rospy.Time(0), but I haven't found anything about how it works in ROS2.

Here is a snippet of the code to understand in the context:

tf_buffer = tf2_ros.Buffer()
tf_listener = tf2_ros.TransformListener(tf_buffer)

dur = Duration()
dur.sec = 10
dur.nsec = 0

transform_odom_base_link = tf_buffer.lookup_transform(target_frame='base_link',
                                        source_frame='odom',
                                        time=UNKNOWN
                                        timeout=dur)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2021-10-08 16:53:33 -0500

janolus gravatar image

updated 2021-10-09 08:26:46 -0500

with rclpy.time.Time() it seems to work

edit flag offensive delete link more
0

answered 2021-10-08 07:50:16 -0500

divyam.rastogi gravatar image

You can use rclcpp::Time(0) to get the latest transformation in ROS2

edit flag offensive delete link more

Comments

well thanks for the cpp syntax but I was looking for the python syntax

janolus gravatar image janolus  ( 2021-10-08 16:53:08 -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

2 followers

Stats

Asked: 2021-10-07 16:41:02 -0500

Seen: 165 times

Last updated: Oct 08 '21