custom model for PX4 sitl GAZEBO simulation - willinum/SPEC21 GitHub Wiki

1 Create a folder under Tools/sitl_gazebo/models for your model, let’s call it iris_clone2

2 Create the following files under Tools/sitl_gazebo/models/iris_clone2: model.config and iris_clone2.sdf (these can be based off the iris or solo models in Tools/sitl_gazebo/models)

3 Create an airframe file under ROMFS/px4fmu_common/init.d-posix/airframes (Yet again, this can be based off the iris or solo airframe files), give it a unique number (for example 1001) and name it 1001_iris_clone2

4 Add the airframe name (iris_clone2) to the file platforms/posix/cmake/sitl_target.cmake in the command set(models …)

5.1 For rtps simulation: add the airframe file created in 3 to: /home/USER/PX4-Autopilot/build/px4_sitl_rtps/etc/init.d-posix/airframes

5.2 For non rtps simulation: add the airframe file created in 3 to: /home/USER/PX4-Autopilot/build/px4_sitl_default/etc/init.d-posix/airframes

  1. start gazebo siumlation with the custom model with: make px4_sitl gazebo_iris_clone or make px4_sitl_rtps gazebo_iris_clone2

EXAMPLE: iris_clone2

iris_clone2

This drone is very similar to the original iris drone which is provided by PX4. The difference can be seen by comparing the .sdf files of both drones. The most important change is the addition of a laser sensor.

For this the following lines of code have been added at the end of the .sdf file (like this:

<model name='velodyne_hdl-32'>  
   <include>
       <uri>model://velodyne_hdl32</uri>
       <pose>0 0 0.0 0 0 0</pose>
   </include>
</model>  
 <joint name='velo_joint' type='fixed'>
  	<parent>base_link</parent>
  	<child>velodyne_hdl-32::base</child>
  	<pose>0 0 0 0 0 0</pose>
</joint>              

First you add the sensor as model, inside you specify the sensor model you want to add (it has to be in the .gazebo/models folder under the same name you specify here) and the position of the sensor model in regard to the superior model (here the iris drone).

Then you add a joint (basically a connection) between your sensor model and the superior model. Here it is a fixed connection from the base_link of the iris drone to the base of the sensor model

⚠️ **GitHub.com Fallback** ⚠️