Spawn a box in another frame than world
Is it possible to spawn a box in a different frame than world? having already a robot spawned, I want to spawn something relative to base_link of that robot. How to do that?
After digging in the source code I discovered an input argument called referenceframe that can be used with the spawnmodel script.
-referenceframe <entityname>
But I couldn't make Gazebo use it, I don't exactly what to write as "entityname", should it be the name of the existing robot, or robotname::baselink? or something else? No matter what I write there is no error message from Gazebo so a hint would be helpful.
Asked by mehdi on 2015-06-11 09:56:02 UTC
Answers
You can get the current world pose of base_link
and add it to the desired pose. math::Pose's + operator should do the transforms for you.
Note that you would just be giving an offset at the beginning, but as base_link
moves, their relative pose might change.
Asked by chapulina on 2015-06-11 11:13:10 UTC
Comments
The problem is that I have object layed on a disc, their position is defined by a radius and an angle relative to that disc. When I want to spawn those object at the right place I calculate x and y by reprojecting back from polar coordinates to Cartesian. I wanted to avoid all these rotation stuff plus quaternions conversion because it always leads me to confusion.
Asked by mehdi on 2015-06-11 11:27:13 UTC
But forcing my base_link to be in the same frame than world is the fastest solution ;)
Asked by mehdi on 2015-06-14 10:41:00 UTC
From experimentation, the -reference_frame
option in spawn_model must be relative to a link in a model in the world. So, for instance the following works for me:
rosrun gazebo_ros spawn_model -urdf -model my_robot -param robot_description -reference_frame other_model_name::link_name
When it can't find the reference_frame (or it's in an unexpected format), the console will output
Spawn status: SpawnModel: reference reference_frame not found, did you forget to scope the link by model name?
Asked by mrjogo on 2016-09-07 19:45:13 UTC
Comments
Could you please add a link to the part of source code / documentation where you saw
reference_frame
?Asked by chapulina on 2015-06-11 11:14:00 UTC
here https://github.com/ros-simulation/gazebo_ros_pkgs/blob/jade-devel/gazebo_ros/scripts/spawn_model line 46
Asked by mehdi on 2015-06-11 11:23:10 UTC