
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!
Originally posted by svintissen on ROS Answers with karma: 75 on 2020-04-28
Post score: 1
Original comments
Comment by DanielRobotics on 2020-04-28:
Have you looked at the tf2 tutorials http://wiki.ros.org/tf2/Tutorials ?
Comment by svintissen on 2020-04-28:
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().
Comment by DanielRobotics on 2020-04-28:
ROS2 does not have rospy.time.now() but on your nodes you can use get_clock().now().
Comment by svintissen on 2020-04-28:
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!
Comment by DanielRobotics on 2020-04-28:
You can use get_clock().now().to_msg() which will return the type of header.stamp
Comment by svintissen on 2020-04-28:
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?
Comment by tfoote on 2020-04-28:
Have you installed the package? It's available in all the indexed versions of ROS 2 https://index.ros.org/p/tf2_ros/#eloquent
Comment by svintissen on 2020-04-28:
So it is not supported in Dashing, but in eloquent?
Comment by tfoote on 2020-04-28:
No, it's available in all ROS 2 versions including Dashing: https://index.ros.org/p/tf2_ros/#dashing I just linked to the default/latest version there are tabs across the top for all the different versions.
Comment by svintissen on 2020-04-29:
Thanks again - Ive installed the package, but I can still not "import tf2_ros" to my python node. Keep gettign "no module named tf2_ros" - any idea what may cause this?
Comment by tfoote on 2020-04-29:
Please edit your question to provide a full overview of how to reproduce your problem. It's mostly likely that you're skipping one or more necessary steps for using the resources. However unless you show us what you're doing we are just going to be guessing. Make sure to include every step including what you did to install things as well as how you're setting up your environment.
Comment by gvdhoorn on 2020-04-29:
@tfoote: isn't the issue here that the Python side of tf2_ros is only available from Eloquent onwards? The OP posted #q350932 in parallel to this one, which links to relevant issues and a discourse post.
Comment by tfoote on 2020-04-29:
Ahh yes. I forgot that the python bindings weren't included in the initial port of the package. They were added in Eloquent.
Comment by svintissen on 2020-04-30:
Okey, I get it - Thanks!