Add Moving Frame: ROS TF

Hello I am trying to do the second example from exercise 2.4 and 2.5
“Publish a moving frame referred to the coke_can (/coke_can frame) that is translated (1.0,0,0) and turns on the Z-axis at a speed of 2 radians per second.”

This is my code below

#!/usr/bin/env python
import rospy
import tf
import math

quaternion = tf.transformations.quaternion_from_euler(0,0,2)

if name == ‘main’:
br = tf.TransformBroadcaster()
rate = rospy.Rate(5.0)
turning_speed_rate = 0.2
while not rospy.is_shutdown():
t = ( * math.pi)turning_speed_rate
# Map to only one turn maximum [0.2
rad_var = t % (2math.pi)
rad_var2 = (2
math.pi) - rad_var
br.sendTransform((1.0 * math.sin(math.pi/2), 1.0 * math.cos(math.pi/2), 0.0),
(quaternion[0], quaternion[1], quaternion[2], quaternion[3]),,

I could generate correctly the rqt_tree, however the can did not follow the moving frame (at least in Gazebo I am not seeing it move) when I runned the listener coke_can move_can…the echo is working

@staff Could you provide me one example with quaternion and moving frame please? I am curious to deal with…

Thanks in advance


Firts of all, maybe I’m not understanding correctly your issue, correctme if so. That you publish the TF doesnt mean that that object will move. Only that the TFs will be published in the TF topic, thats all. Then you use that TF data to send it to the roomba robot and moveit around based on that data.

Please tell me if its that the issue or its another one ;).

ok @duckfrost I think you are correct in your way of thinking, because it seems that a can should not follow a frame, once it is an object usual fixed…However I would be very grateful if you could share me the solution of this exercise 2.4-2.5 from ROS TF ??. I am still too confused in how to use and convert euler to quaternion and the inverse……do you have an example of these angles structures working that you could send me, please?

Another question from other module “The URDF” …I watched videos about how to dowload 3D models from 3D Warehouse site and later adjust it in Google Sketch 2017-2019 and later assign attributes in Blender. I could dowload Blender for linux. However I had really huge issues and I am still having to dowload and make Google SketchUp works in linux. I tried numerous tutorials videos from youtube, in which they use the “PlayonLinux” frameworks and different Wine versions to dowload this program (SketchUp) and execute…

In my case I tried numerous tutorials like this and I could not successfully use this program. Could you provide this software by my e-mail for linux, or send me the installation command lines for linux, a site or an easy way or at least functional tutorial to dowload and execute “Google SketchUp 2017-2019” ??? I am really interested in work with it over my 3D models and explore its interesting features. I could dowload just the sketchup 2016 but the **3D Warehouse models are just 2017 up…

Thanks @duckfrost and @staff .
I wants to thank all of you for the support this year and wish a happy Christmas and good new year!
Regards: Marcus

Ok lets tak it by steps:

  1. So this exercise 2.4 and 2.5 is basically combining all you should have understood from previous exercises and units. Here I share the package with the solutions and the instructions to launch it:

git clone Bitbucket

And then what you have to do is:
exercise 2.4: Luanch this in different webshels and open a Graphical tools window to see the result and check

roslaunch tf_course_solutions_pkg ex_2_1_solution.launch
rosrun tf_course_solutions_pkg
rosrun tf_course_solutions_pkg

exercise 2.5: Here you just have to change in the ex_2_1_solution.launch,

        args="turtle2 turtle1"

You have to change the turtle 1 to whatever model name you want the irobot to follow.

  1. I highly reccomend you to work with the following software as far as 3D models is concerned:
    a) Blender: This software you can install it in any OS. Its great for exparting and modeling and changing origin of 3D models.
    b) To design CAD parts, better OnShape. Online and free.
    c) Blendswap is one of the best places to get Opensource 3D models.

Hope this helps and Merry Christmas.

1 Like

Thanks @duckfrost I have read and used your solution…to be honest, I used script files…your way to call them inside a launch file and use arguments in this launch file such as args =“follower” " to be followed" is better than use python script where I need to put this information after the command line. But the fact is that I could move cleaner around fixed and moving frame. And I am very happy to accomplish with that before the end of the year kakakak.

Besides, I always use for example, launch file, like this: roslaunch urdf_visualize.launch model:“Myetc/robotname…”

I would like to launch the urdf visualize automatically without type all the arguments after the main phrase ( it is not completed automatically using TAB). How can I do that? Can you send me an example? I imagine I passa the arguments inside this urdf_visualize.launch file or create another which pulls this one and launch the arguments? I am confused…

I also did not understand this programming line:

t = ( * math.pi)turning_speed_rate
# Map to only one turn maximum [0,2
rad_var = t % (2*math.pi)

Becuase here: t = seconds. 3,14 rad constant
later rad_var = receive (seconds
rad*constant) / (rad) = so the result will be in SECONDS, not in rad!
Well the robot turns radians around some place not in seconds right? so this is my doubt…

my_quaternion = tf.transformations.quaternion_from_euler(0.0,0.0,rad_var)

Here the rad_var will be used in Seconds?

same here ! I also would like to know the logic behind the t and rad_var .

1 Like