Gazebo | Ignition | Community
Ask Your Question

Cannot Spawn URDF into gazebo using ros2

asked 2020-11-09 17:10:43 -0500

DRO gravatar image

I am trying to load a URDF file into gazebo, and do so using a ros2 python launch file. This was easily done in the past with ros1 xml launch files, however I am having trouble doing the same with ros2 python launch files. I am able to launch gazebo from this ros2 launch file, however my robot model is not displaying. There are no errors, and says everything is processed cleanly though the robot does not appear. I am loading the xml data of the urdf to robot_state_publisher, and publishing the xml data on a topic. I then use the spawn_entity node to read the xml data from that topic. In my URDF I have built my robot using meshes, and I suspect that when passing the xml data to spawn_entity on a topic, the location or file in formation of those meshes are not completed transferred. I suspect this to be the case, because if I build a robot with out meshes and use basic geometries ( box, cylinder..) in the urdf, then everything works fine and I am able to spawn the robot from a urdf into gazebo using ros2.

I am running Ubunut 20.04, gazebo 11, ros2-foxy, and gazebo_ros_packages foxy branch

Here is the code:

image description

Here is the terminal ; image description

Any help would be greatly appreciated.

Here is a portion of the URDF. image description image description

Here is the result in Gazebo image description

edit retag flag offensive close merge delete


Just posting that I see the same behavior with mesh files on Foxy, ROS2, Gazebo11. Looking for answers...

gy gravatar imagegy ( 2021-03-12 15:08:28 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-09-23 15:21:11 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

In ROS2, the SpawnEntity method let's the SDF library handle the URDF conversion. A urdf model has package:// but the sdf::readString method transforms the package:// urls into model:// . Hence, one of the ways to resolve this issue would be to convert your urdf file into a sdf file. This can be done by using the command, gz sdf -p file_name.urdf > file_name.sdf . Try to launch this sdf file. If it doesn't launch even after this, then try removing model://package_name from the uri and just keep the portion meshes/ur5/visual/bot_part_name.dae and see if this works. You can refer the following links for further information:

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2020-11-09 17:10:43 -0500

Seen: 2,021 times

Last updated: Nov 09 '20