Ask Your Question
1

Publish /tf in data ROS2 Dashing with python

asked 2020-04-28 07:05:42 -0500

svintissen gravatar image

Hi.

I have created a simple .urdf file describing my "robot". I can change the position of the model in the "world_coordinate_system" running "ros2 run tf2_ros static_tranform_publisher" from terminal, describing a transform from "world" to "base_link". ("base_link" describes the model body)

Further I want to create a Node using python that updates the position of the model by publishing the tranform data from "world" to "base_link", but I cant find any good resources on how this is done in ROS2 Dashing.

So far I have tried using geometry_msgs.msg.TransformStamped(), then giving the transform as an input to tf2_msgs.msgTFMessage(), but I cant get it to work.

Do any of you have any examples on how this is done, or a better way to do it?

Thanks in advance, any help as well as links to tutorials or documentation is appriciated!

edit retag flag offensive close merge delete

Comments

Have you looked at the tf2 tutorials http://wiki.ros.org/tf2/Tutorials ?

DanielRobotics gravatar image DanielRobotics  ( 2020-04-28 07:31:58 -0500 )edit

Yes, Ive used the tutorials as a guide, but Im having trouble adapting it to ROS2. Part of the problem Im having is getting the ROS2 equivalent of rospy.time.now().

svintissen gravatar image svintissen  ( 2020-04-28 07:38:57 -0500 )edit

ROS2 does not have rospy.time.now() but on your nodes you can use get_clock().now().

DanielRobotics gravatar image DanielRobotics  ( 2020-04-28 08:01:25 -0500 )edit

When I try to use get_clock().now() I get the error "The stamp field must be a sub message of type Time". Why is this? Thanks!

svintissen gravatar image svintissen  ( 2020-04-28 08:06:42 -0500 )edit

You can use get_clock().now().to_msg() which will return the type of header.stamp

DanielRobotics gravatar image DanielRobotics  ( 2020-04-28 08:58:41 -0500 )edit

Thanks, that worked. Still not able to broadcast the transform as the tf2_ros package is not available for ROS2. Any tips as for what I should do instead?

svintissen gravatar image svintissen  ( 2020-04-28 11:24:37 -0500 )edit

Have you installed the package? It's available in all the indexed versions of ROS 2 https://index.ros.org/p/tf2_ros/#eloq...

tfoote gravatar image tfoote  ( 2020-04-28 12:11:41 -0500 )edit

So it is not supported in Dashing, but in eloquent?

svintissen gravatar image svintissen  ( 2020-04-28 13:17:11 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-04-30 02:30:18 -0500

svintissen gravatar image

Python bindings for tf2_ros not available in ROS2 Dashing, they are added in Eloquent.

edit flag offensive delete link more

Comments

Thanks for filling in the answer here. I've voted it up so you have enough karma to accept your own answer.

tfoote gravatar image tfoote  ( 2020-04-30 02:35:04 -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: 2020-04-28 07:05:42 -0500

Seen: 123 times

Last updated: Apr 30