Code cloned from Intel RealSense Gazebo/ROS
This repository provides the d435i camera model and iris_D435i model for simulation in Gazebo. Some parameters have been modified in the original model configuration files.
In fact, you can directly use the iris_depth_camera model provided by the official px4 for drone simulation.
Tested and compiled on Ubuntu 18.04 with ROS and px4 environment installed.
git clone https://github.com/tugepaopaoo/realsense_ros_gazebo.git
cd realsense_ros_gazebo
catkin_make
After the compilation is complete, you can quickly check if it was successful by running the following command in the current terminal:
source devel/setup.bash && roslaunch realsense_ros_gazebo simulation.launch
source devel/setup.bash && roslaunch realsense_ros_gazebo simulation_D435i_sdf.launch
Configuring the environment to load iris unmanned aircraft with D435i in Gazebo simulation.
Copy the camera plugin librealsense_gazebo_plugin.so
to the dynamic library directory of px4.
cp ${YOUR_WORKSPACE_PATH}/devel/lib/librealsense_gazebo_plugin.so ${YOUR_PX4_PATH}/build/px4_sitl_default/build_gazebo/
Copy the camera model D435i and aircraft model iris_D435i
to the model library of px4.
cp -r ${YOUR_WORKSPACE_PATH}/src/realsense_ros_gazebo/sdf/D435i ${YOUR_PX4_PATH}/Tools/sitl_gazebo/models/
cp -r ${YOUR_WORKSPACE_PATH}/src/realsense_ros_gazebo/sdf/iris_D435i ${YOUR_PX4_PATH}/Tools/sitl_gazebo/models/
Note: When installing PX4, you should have already configured the relevant environment in the .bashrc
file. The file should have the following commands at the end (/home/user/PX4_Firmware
should be replaced with your own path, i.e., ${YOUR_PX4_PATH}
mentioned above):
source /home/user/PX4_Firmware/Tools/setup_gazebo.bash /home/hahaha/PX4_Firmware /home/hahaha/PX4_Firmware/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:/home/user/PX4_Firmware
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:/home/user/PX4_Firmware/Tools/sitl_gazebo
Modify the mavros_posix_sitl.launch
file in the ${YOUR_PX4_PATH}/launch
directory. Replace the model in <arg name="sdf" default=" "/> with the iris_D435i.sdf
model copied to px4, and keep the rest unchanged. The modified part should look like the following:
<!-- vehicle model and world -->
<arg name="est" default="ekf2"/>
<arg name="vehicle" default="iris"/>
<arg name="sdf" default="$(find mavlink_sitl_gazebo)/models/iris_D435i/iris_D435i.sdf"/>
<arg name="world" default="$(find mavlink_sitl_gazebo)/worlds/empty.world"/>
In the terminal, run the command to see the iris_D435i.sdf
model in Gazebo.
By adjusting the graphical properties in the camera model D435i.sdf file, you can choose to either display or hide the real-time camera view in front of the camera.
<visualize>1</visualize>
for display;
<visualize>0</visualize>
for hide;
The effect when hidden is as follows:
-
Origin
- Only modifications were made to the iris_D435i.sdf file in the original repository.
Changed
<child>D435i::realsense_camera_link</child>
to<child>D435i::camera_link</child>
-
June 22, 2023
- Modify plugins src file to enable
<robotNamespace>
element. - Create new
sdf
andsdf.jinja
file to make the multi-robot simulation possible - Add multi-robot launch file accordingly (You need to copy them to your repository)
- Modify plugins src file to enable