Hi!
I am trying to add a camera to the iris model in gazebo and get those topics on ros2. I referred to this post and added the snippet to the iris.sdf.jinja file and ran make px4_sitl_rtps gazebo. The following is the output:
[0/4] Performing build step for 'sitl_gazebo'
[1/1] Generating /home/madhav/PX4-Auto...Tools/sitl_gazebo/models/iris/iris.sdf
/home/madhav/PX4-Autopilot/Tools/sitl_gazebo/models/iris/iris.sdf.jinja -> /home/madhav/PX4-Autopilot/Tools/sitl_gazebo/models/iris/iris.sdf
[3/4] cd /home/madhav/PX4-Autopilot/bu...dhav/PX4-Autopilot/build/px4_sitl_rtps
SITL ARGS
sitl_bin: /home/madhav/PX4-Autopilot/build/px4_sitl_rtps/bin/px4
debugger: none
program: gazebo
model: none
world: none
src_path: /home/madhav/PX4-Autopilot
build_path: /home/madhav/PX4-Autopilot/build/px4_sitl_rtps
empty model, setting iris as default
GAZEBO_PLUGIN_PATH /usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins::/home/madhav/PX4-Autopilot/build/px4_sitl_rtps/build_gazebo
GAZEBO_MODEL_PATH /usr/share/gazebo-11/models:/usr/share/gazebo-11/models:/usr/share/gazebo-11/models::/home/madhav/PX4-Autopilot/Tools/sitl_gazebo/models
LD_LIBRARY_PATH /home/madhav/px4_ros_com_ros2/install/px4_ros_com/lib:/home/madhav/px4_ros_com_ros2/install/px4_msgs/lib:/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/opt/rviz_ogre_vendor/lib:/opt/ros/foxy/lib/x86_64-linux-gnu:/opt/ros/foxy/lib::/usr/lib/x86_64-linux-gnu/gazebo-11/plugins::/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins::/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins::/home/madhav/PX4-Autopilot/build/px4_sitl_rtps/build_gazebo
empty world, setting empty.world as default
Using: /home/madhav/PX4-Autopilot/Tools/sitl_gazebo/models/iris/iris.sdf
Warning [parser.cc:833] XML Attribute[version] in element[sdf] not defined in SDF, ignoring.
/home/madhav/PX4-Autopilot/Tools/sitl_run.sh: line 216: 11233 Segmentation fault (core dumped) gzserver $verbose $world_path $ros_args
SITL COMMAND: "/home/madhav/PX4-Autopilot/build/px4_sitl_rtps/bin/px4" "/home/madhav/PX4-Autopilot/build/px4_sitl_rtps"/etc -s etc/init.d-posix/rcS -t "/home/madhav/PX4-Autopilot"/test_data
Creating symlink /home/madhav/PX4-Autopilot/build/px4_sitl_rtps/etc -> /home/madhav/PX4-Autopilot/build/px4_sitl_rtps/t
_____ __ __ ___
| ___ \ \ \ / / / |
| |_/ / \ V / / /| |
| __/ / \ / /_| |
| | / /^\ \ \___ |
\_| \/ \/ |_/
px4 starting.
INFO [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
INFO [init] found model autostart file as SYS_AUTOSTART=10016
INFO [param] selected parameter default file eeprom/parameters_10016
INFO [parameters] BSON document size 291 bytes, decoded 291 bytes (INT32:12, FLOAT:3)
[param] Loaded: eeprom/parameters_10016
INFO [dataman] data manager file './dataman' size is 7866640 bytes
PX4 SIM HOST: localhost
INFO [simulator] Waiting for simulator to accept connection on TCP port 4560
Gazebo multi-robot simulator, version 11.13.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org
[Msg] Waiting for master.
[Err] [ConnectionManager.cc:121] Failed to connect to master in 30 seconds.
[Err] [gazebo_shared.cc:78] Unable to initialize transport.
[Err] [gazebo_client.cc:56] Unable to setup Gazebo
You can see that the gzserver had a seg fault and crashed after the warning.
I have used the migration article for adding ros2 plugins and this is how the plugin is written in the iris.sdf.jinja file:
<sensor name="down_camera" type="camera">
<pose>0 0 0 -1.5708 0 0</pose>
<camera>
<horizontal_fov>2.0</horizontal_fov>
<image>
<format>R8G8B8</format>
<width>640</width>
<height>480</height>
</image>
<clip>
<near>0.05</near>
<far>15000</far>
</clip>
</camera>
<always_on>1</always_on>
<update_rate>10</update_rate>
<visualize>true</visualize>
<plugin filename="libgazebo_ros_camera.so" name="camera_en_ros">
<ros>
<namespace>iris</namespace>
<remapping>image_raw:=custom_img</remapping>
<remapping>camera_info:=custom_info</remapping>
</ros>
<cameraName>down_camera_link</cameraName>
<FrameName>downCameraImage</FrameName>
<Cy>0</Cy>
<Cx>0</Cx>
<updateRate>30.0</updateRate>
</plugin>
<plugin name="GstCameraPlugin" filename="libgazebo_gst_camera_plugin.so">
<robotNamespace></robotNamespace>
<udpPort>5600</udpPort>
</plugin>
<plugin name="GeotaggedImagesPlugin" filename="libgazebo_geotagged_images_plugin.so">
<robotNamespace>iris</robotNamespace>
<interval>1</interval>
<width>3840</width>
<height>2160</height>
<maximum_zoom>8.0</maximum_zoom>
</plugin>
</sensor>
If I comment out the libgazebo_ros_camera.so plugin, I am able to get the camera and the image published on gazebo topics without errors. I can see that the plugin binary is in the folder /opt/ros/foxy/lib I suspect something is wrong with this plugin. Can someone please help me out? Thank you so much!