0
$\begingroup$

Goal:

I want to use an RGB camera in Gazebo Harmonic, Gazebo Garden or Gazebo Fortress.

Context:

I have a robot that needs a camera. I followed this tutorial, but couldn't get the camera to work.

The error I get in all the Gazebo versions that I have tried is:

[ruby $(which ign) gazebo-1] [Err] [SystemLoader.cc:94] Failed to load system plugin [libgazebo_ros_camera.so] : couldn't find shared library. 

The full robot has a very large xacro file, so I tried to make a minimal working example. However, I still get the same error.

This is my xacro file:

<?xml version= "1.0" ?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="camera"> <xacro:include filename="$(find camera)/description/materials.xacro"/> <xacro:include filename="$(find camera)/description/shapes.xacro"/> <xacro:property name="camera_length" value="0.05" /> <xacro:property name="camera_width" value="0.2" /> <xacro:property name="camera_height" value="0.1" /> <link name="base_link"> <xacro:box mass="1" x="${camera_length}" y="${camera_width}" z="${camera_height}" color="blue"> <origin xyz="0 0 ${camera_height/2}" rpy="0 0 0"/> </xacro:box> </link> <link name="camera_lens"> <xacro:cylinder_visual radius="${camera_height/2 - 0.01}" height="${0.02}" color="red"> <origin xyz="0.01 0 0" rpy="0 0 0 "/> </xacro:cylinder_visual> </link> <joint name="camera_optical_joint" type="fixed"> <parent link="base_link"/> <child link="camera_lens"/> <origin xyz="${camera_length/2} 0 ${camera_height/2}" rpy="${-pi/2} 0 ${-pi/2}" /> </joint> <gazebo reference="base_link"> <sensor name="camera" type="camera"> <pose> 0 0 0 0 0 0 </pose> <visualize>true</visualize> <update_rate>10</update_rate> <camera> <horizontal_fov>1.1</horizontal_fov> <image> <format>R8G8B8</format> <width>640</width> <height>480</height> </image> <clip> <near>0.05</near> <far>8.0</far> </clip> </camera> <plugin name="camera_controller" filename="libgazebo_ros_camera.so"> <alwaysOn>true</alwaysOn> <cameraName>camera</cameraName> <imageTopicName>image_raw</imageTopicName> <cameraInfoTopicName>camera_info</cameraInfoTopicName> <frame_name>camera_lens</frame_name> </plugin> </sensor> </gazebo> </robot> 

Setup:

My host is Ubuntu 24.04. I am using ROS Humble inside a Docker container running Ubuntu 22.04. I tried both Gazebo Fortress and Gazebo Garden, but to no avail. I also tried ROS Jazzy and Gazebo Harmonic. I like working with Gazebo Harmonic the most, then Fortress and I like Garden the least.

You can find my files here: https://github.com/lgrvanlieshout/gazebo_camera_example

Thanks in advance!

Edit:

The problem is solved! I have updated the files on github so anyone can see how to implement a camera in Gazebo.

$\endgroup$

1 Answer 1

1
$\begingroup$

I think the tutorial you link to is for Gazebo Classic (i.e. 'old Gazebo'), and you are using Gazebo Sim (i.e. 'new Gazebo').

Have a look at this demo world for an example of the camera sensor.

You will have to use ros_gz_bridge or ros_gz_image to transfer the images to ROS 2, see here.

$\endgroup$
1
  • $\begingroup$ Thanks for the fast reply, this helped immensely! $\endgroup$ Commented Nov 26, 2024 at 8:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.