1
$\begingroup$

I have a Gazebo Garden simulation and I struggle to make it work with Gazebo plugins for the URDF file.

Context

I have a URDF file of my robot, but I first could not find an obvious way to make it work in Gazebo Garden, so I created a simplified SDF version of the robot.

I first made the simulation work with an SDF file for the robot, but I could not get it to work with the robot_state_publisher. I could not find any example of how to publish the robot_description and the tf from Gazebo directly so I could use it without launching the robot_state_publisher manually through a ROS 2 launch file. (I wanted to avoid this as then I needed to recreate my SDF file as URDF file to give it to the state publisher node.

I then figured out how to use the URDF version of my model and I made a launch file that loads the URDF of the robot and gives it to Gazebo. The simulation launches fine, the robot model is there, and I can use the robot_state_publisher to get the proper tf of the robot and the robot_description.

BUT: I fail to load any plugins written inside the URDF file since I can't find any examples on how to do this.

Current state

I found this comment that I could load the plugins the same way as I would in the classic Gazebo: https://github.com/gazebosim/ros_gz/issues/109

I receive the following error messages related to my problem:

[ruby $(which gz) sim-1] [Wrn] [SystemPaths.cc:168] Finding plugins using deprecated IGN_ prefixed environment variable [IGN_GAZEBO_SYSTEM_PLUGIN_PATH]. Please use the GZ_ prefix instead.
[ruby $(which gz) sim-1] [Err] [SystemLoader.cc:118] Failed to load system plugin: (Reason: Could not find shared library)
[ruby $(which gz) sim-1] - Requested plugin name: [camera_controller]
[ruby $(which gz) sim-1] - Requested library name: [libgazebo_ros_camera.so]
[ruby $(which gz) sim-1] - Library search paths:
[ruby $(which gz) sim-1]   - /home/leo/.gz/sim/plugins/
[ruby $(which gz) sim-1]   - /usr/lib/x86_64-linux-gnu/gz-sim-7/plugins/
[ruby $(which gz) sim-1]   - /home/leo/.ignition/gazebo/plugins/
[ruby $(which gz) sim-1]   - /
[ruby $(which gz) sim-1]   - /home/leo/ros2_ws/install/sdformat_urdf/lib/
[ruby $(which gz) sim-1]   - /home/leo/ros2_ws/install/ros_gz_sim/lib/
[ruby $(which gz) sim-1]   - /home/leo/ros2_ws/install/ros_gz_bridge/lib/
[ruby $(which gz) sim-1]   - /home/leo/ros2_ws/install/ros_gz_interfaces/lib/
[ruby $(which gz) sim-1]   - /opt/ros/humble/lib/x86_64-linux-gnu/
[ruby $(which gz) sim-1]   - /opt/ros/humble/lib/
[ruby $(which gz) sim-1]   - (Deprecated) /
[ruby $(which gz) sim-1]   - (Deprecated) /home/leo/ros2_ws/install/sdformat_urdf/lib/
[ruby $(which gz) sim-1]   - (Deprecated) /home/leo/ros2_ws/install/ros_gz_sim/lib/
[ruby $(which gz) sim-1]   - (Deprecated) /home/leo/ros2_ws/install/ros_gz_bridge/lib/
[ruby $(which gz) sim-1]   - (Deprecated) /home/leo/ros2_ws/install/ros_gz_interfaces/lib/
[ruby $(which gz) sim-1]   - (Deprecated) /opt/ros/humble/lib/x86_64-linux-gnu/
[ruby $(which gz) sim-1]   - (Deprecated) /opt/ros/humble/lib/

Maybe the following information is important to know:

When I set the variable GZ_SIM_RESOURCE_PATH, it did not work, I also had to set the variable IGN_GAZEBO_RESOURCE_PATH for Gazebo to be able to load the robot model as URDF.

What I need

I need examples of how to add different sensors to my URDF (actually the XACRO) file. I want to add the differential drive controller to move the robot, a regular RGB camera, a depth camera and a LiDAR. They all work fine in the SDF file, but I do not know how to translate them into the URDF file.

I am using ROS 2 Humble with Gazebo Garden inside a Docker container.

My Files

My files are available for inspection on GitHub: https://github.com/Dave-van-der-Meer/leorover_gazebo_sim_docker

The latest changes are on the "add_sensors_to_URDF" branch.

$\endgroup$
1

1 Answer 1

1
$\begingroup$

IMO, the best way to debug this is to first generate your final URDF from the xacro files and then running gz sdf -p path/to/your/urdf_file. This will generate the SDF file that Gazebo will consume when you spawn a URDF file. Also take a look at http://sdformat.org/tutorials?tut=sdformat_urdf_extensions&cat=specification& to see how to use the <gazebo> tag in URDF. Generally, the <gazebo> tag (without the reference attribute) is where you want to put your plugins.

$\endgroup$
7
  • $\begingroup$ This is how I first created the SDF file that I made in the beginning. It required a lot of manual changes to make the SDF file work in the end. But do I understand correctly that you are suggesting I should then run the simulation with the SDF file and use the robot_state_publisher using the XACRO file? I tried to void this as it means I would need to maintain two files in parallel when I modify the robot model. $\endgroup$ Apr 13, 2023 at 8:04
  • $\begingroup$ Maintaining two files is not what you want. I was thinking you add <gazebo> tags to the original xacro file that, when converted to SDF, matches the working SDF file you've manually updated. $\endgroup$
    – azeey
    Apr 13, 2023 at 15:30
  • $\begingroup$ Okay, I see. Unfortunately, when I converted the XACRO to UDF and then to SDF, I had to replace all the file paths to make it work. Also, I have no reference on how to set the <gazebo> tags/ Would they be exactly the same as in the SDF file? $\endgroup$ Apr 17, 2023 at 12:17
  • $\begingroup$ This is a good reference for using <gazebo> tags. For file path problems, take a look at gazebosim.org/api/sim/7/resources.html. Setting the GZ_SIM_RESOURCE_PATH to the directory that contains the resource should work (IGN_GAZEBO_RESOURCE_PATH if you're using Gazebo Fortress or Citadel) $\endgroup$
    – azeey
    Apr 17, 2023 at 22:36
  • $\begingroup$ This link is very interesting indeed. Thanks! My major issue, though is that I cannot find how to call the plugins the right way. I read that they should be backward compatible with IGN Gazebo, but it doesn't work for me. In general, there are not many resources and I do not find the official documentation of Gazebo very user friendly and I do not make sense out of it. $\endgroup$ Apr 20, 2023 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.