Can you show your launch file? I have been trying to get this to work, but Gazebo is having trouble parsing the urdf generated from the xacro file. Thank you.
In this, you learn how to install a simple camera facing downwards
at bottom of IRIS quadrotor model in Gazebo and publish its frames on ROS(Kinetic).
This tutorial assumes your have cloned Firmware folder in ~/src/Firmware and
have successfully all its dependencies.
I) To install a camera in IRIS proceed as follows:-
Open iris_base.xacro present in ~/src/Firmware/Tools/sitl_gazebo/models/rotors_description/urdf/
Search in iris_base.xacro and add the
following code just above it and save it.
<xacro:camera_macro
namespace="${namespace}"
parent_link="base_link"
camera_suffix="red_iris"
frame_rate="30.0"
horizontal_fov="1.3962634"
image_width="800"
image_height="800"
image_format="R8G8B8"
min_distance="0.02"
max_distance="300"
noise_mean="0.0"
noise_stddev="0.007"
enable_visual="1"
>
<box size="0.05 0.05 0.05" />
<origin xyz="0 0 -0.07" rpy="0 1.57079 0"/>
</xacro:camera_macro>
Now, the camera is installed. You can take assistance of component_snippets.xacro to
understand the values.
II) If take a look a at component_snippets.xacro, you will come to know that
frames are published under /iris/camera_red_iris/image_raw , so to have it
on ros start simulator by the procedure mentioned in https://dev.px4.io/en/simulation/ros_interface.html
in What’s Happening behind the scenes section.
Hello, I’m new in this field but for a project I have to have an Iris model with a camera. So I tried to follow yours instructions (message #1 and #6) by doing:
EDIT (05/11/2018) => Found a solution to make it works:
0) Follow this tutorial, under “Build Gazebo Plugins (all operating systems)”
In /home/username/src/Firmware/Tools/sitl_gazebo/models/rotors_description/urdf/
No need to modify iris.xacro (in this location)
No need to modifiy iris.sdf (found at an other location as I saw it in other articles)
Open to edit iris_base.xacro. Before the <!-- Mount an ADIS16448 IMU. --> , I added the following bloc of code:
Just let me add some extra steps in case that someone (like me) can’t make it work.
modification to iris_base.xacro is ok but I was getting error with libgazebo_ros_camera.so plugin.
I’ve installed ros-kinetic-gazebo-ros-pkgs and ros-kinetic-gazebo-ros-control as suggest here: http://gazebosim.org/tutorials?tut=ros_installing
but that does not solve my problem (maybe I have to add some GAZEBO PLUGIN PATH)
So I follow the instruction for building from source and add
export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:~/catkin_ws/build/gazebo_ros_pkgs/gazebo_plugins/
So, now I can launch the iris and it found the plugin.
The next step is how to view the camera image on rviz.
I run rosrun rviz rviz and add a camera object, but there is a message “No image received”
The problem here is with links and transformations. there is a base_link frame and a child link named iris_1/camera_red_iris_link were the image is published. So I need to add a transformation between that frames.
I run
rosrun tf static_transform_publisher 0 0 0 0 0 0 base_link /iris_1/camera_red_iris_link 50
and now I can see camera image on rviz.
Hi @michou214, thanks for your instructions, I added camera to iris model succesfully, No error when simulation start. But then, When I want to arm model, it gives warning and error like at following lines. What is the problem ?
pxh> commander arm
WARN [commander] Preflight Fail: High Accelerometer Bias
ERROR [commander] arming failed
A small thing to note is that you need to generate the iris.sdf file again after adding the code to the xacro files above.
i.e. use command to recompile and generate the iris.sdf file:
$ DONT_RUN=1 make px4_sitl_default gazebo
Recently, I tried to add a camera in the same way on Ubuntu 20.04.
and then running DONT_RUN=1 make px4_sitl_default gazebo-classic in the PX4-autopilot.
Although the camera is successfully added, the camera does not has “frame_id”.
Since it lacks “frame_id”, the ar_track_alvar package cannot work