Create custom model for SITL


I am trying to modify iris model to simulate a bigger drone.
For that I started with iris.sdf file and replaced mass value of base_link to 18. I also replaced for each one of the rotors:
maxRotVelocity 7435.52
motorConstant 0.000252428
momentConstant 0.0955
rotorDragCoefficient 0.0000315
The numbers are calculated with the formulas from this thread:

I created an ekf2 file (copying everything from the iris) and modified mavros_posix_sitl.launch to point to my model. It loads but behaviour of the drone is bad.
First of all, it is spawned underground. I was able to solve this changing mass to 10. I don’t know what does the mass has to do with drone position, but it does.
With that changed, I can command with QGroundControl a take off, but it is very unstable, and falls to the ground after a few seconds.

What am I doing wrong? This is not very well documented so it’s hard to debug.
Is there any bigger drone model available? Something between 15-20 kg?


Hi @danividanivi, Have you been able to do SITL for your custom drone in Gazebo?
I am trying to do the same by facing weird issues as well.

1 Like

I don’t remember the details, but starting with a small model and tunning the parameters one by one I was able to perform the simulations.
There was not really good documentation, so it was a trial-error proccess, with some parameters modification leading to the weird issues described.

Hi @danividanivi, I have successfully created a custom model for SITL.

The steps I took for creating a custom Gazebo model and PX4 SITL airframe with the adjusted gains:

  1. Create a folder under Tools/sitl_gazebo/models for your model, let’s call it my_vehicle
  2. Create the following files under Tools/sitl_gazebo/models/my_vehicle: model.config and my_vehicle.sdf (these can be based off the iris or solo models in Tools/sitl_gazebo/models)
  3. Create a world file in Tools/sitl_gazebo/worlds called (Again, this can be based off the iris or solo world files)
  4. Create an airframe file under ROMFS/px4fmu_common/init.d-posix (Yet again, this can be based off the iris or solo airframe files), give it a number (for example 4229) and name it 4229_my_vehicle
  5. Add the airframe name (my_vehicle) to the file platforms/posix/cmake/sitl_target.cmake in the command set(models …

Now you are free to tweak any of the model values in the SDF file and any of the controller gains in the airframe file.
You can launch SITL with your model with “make px4_sitl gazebo_my_vehicle”

A couple of things to keep in mind:

  1. When increasing the mass of the vehicle, also increase the inertias. I found that Gazebo does not like really small inertias.
  2. With the larger vehicle, tweak the motor values (but you have done this already)
  3. If the quad is unstable, it is probably due to bad controller gains. Tweak them for the larger vehicle.

The make px4_sitl gazebo_my_vehicle command is running the default iris quad.
What are the basic things that can be modified to see it in the simulation to know if it is working or not?

In the steps I gave, I suggested to base the new files of the iris or solo files.
The parameters, such as the vehicle mass, inertias, motor models, controller gains etc. can be changed in the new files to simulate a different vehicle.
But one won’t necessarily be able to physically see a difference in the simulation.

The easiest way, I would say, to see a physical difference is to use another 3D model for the vehicle.
So, for instance, in the following section of the solo.sdf file:

  <visual name='base_link_inertia_visual'>
    <pose>0 0 0 0 0 0</pose>
        <scale>1 1 1</scale>

The file model://solo/meshes/solo.stl can be replaced with another stl file, which will be the visual vehicle during SITL.
Instead of replacing it with another 3D model, a naive way would be to replace it with a box just to see if everything is working.
So replacing the part with:

        <size>0.32 0.32 0.18</size>

Will you give the procedure in which the files should be changed in order to make a custom model? I have tried it myself by creating my_vehicle file under Tools/sitl_gazebo/models, created airframe file under ROMFS/px4fmu_common/init.d-posix and added airframe name under platforms/posix/cmake/sitl_target.cmake but after running the code went back to the standard iris copter.

This helps a lot and most importantly, it worked! Thanks :slight_smile:

1 Like

I am interested in making a model that in qgroundcontrol detects as a fixed-wing airplane. I don’t know if there is a pattern like iris in this case. I have tried plane but it detects it as a custom model.

I followed the instructions. Here is my issue:

INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
Error: Unknown model my_vehicle (not found by name on /home/user/Desktop/File/PX4-Autopilot/build/px4_sitl_default/tmp/rootfs/etc/init.d-posix/airframes)
ERROR [px4] Startup script returned with return value: 256

I am new to these things but i checked the


I can find the file which is instructions saying “4229_my_vehicle”

Can you help me about it ? Or are there any instructions for adding custom model(Couldn’t find properly) ?

@Fatih_Ozkan You need to add it to the cmake lists: PX4-Autopilot/CMakeLists.txt at master · PX4/PX4-Autopilot · GitHub


It handled the issue but now my model is not showin up in gazebo.

Thanks for your concern

@Fatih_Ozkan Please share exactly what you are doing and how it is failing. Otherwise we can’t help you other than tell you you are doing something wrong

HI, i tried the steps mentioned here but when i run make px4_sitl gazebo_76motordrone, it gets stuck at using the sdf file as shown but displayed no errors, its just stuck. Pls help me, thank you! :slight_smile:

src_path: /home/xavierrocker/Desktop/PX4-Autopilot
build_path: /home/xavierrocker/Desktop/PX4-Autopilot/build/px4_sitl_default
GAZEBO_PLUGIN_PATH :/home/xavierrocker/Desktop/PX4-Autopilot/build/px4_sitl_default/build_gazebo
GAZEBO_MODEL_PATH :/home/xavierrocker/Desktop/PX4-Autopilot/Tools/sitl_gazebo/models
LD_LIBRARY_PATH :/home/xavierrocker/Desktop/PX4-Autopilot/build/px4_sitl_default/build_gazebo
empty world, default world for model found
Using: /home/xavierrocker/Desktop/PX4-Autopilot/Tools/sitl_gazebo/models/76motordrone/76motordrone.sdf

Like @antonerasm said. I did:

  • I created a folder under Tools/sitl_gazebo/models for my model, named my_vehicle

  • I created the following files under Tools/sitl_gazebo/models/my_vehicle: model.config and my_vehicle.sdf (these can be based off the iris or solo models in Tools/sitl_gazebo/models)

  • I created a world file in Tools/sitl_gazebo/worlds called

  • I create my own airframe file in init.d-posix. Also i will use my own mixer.

  • I added the airframe name to the platforms/posix/cmake/sitl_target.cmake in the command set(models …)

  • And finaly i added name of it to PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/airframes/CMakeLists.txt

My issues

  1. Can not connect to QGroundControl
  2. Now my model is showing up but can’t control. Motors spinnin freely.


I created a world file in Tools/sitl_gazebo/worlds called my_vehicle .world

You need to remove your world file

My issues

  1. Can not connect to QGroundControl
  2. Now my model is showing up but can’t control. Motors spinnin freely.

This means that your mavlink interface is not configured properly with your mixers. To do it in steps and provide less confusion, change your custom model / airframe configs into a copy paste of the iris model, make sure everything works and then add your custom changes on top.
Otherwise you will have multiple issues showing up at once for everything you did wrong along the way.

1 Like

same ques, have u solved that? if you have,would u plz tell me how?

Sorry for late message. Thank you. I did it step by step and it solved.

I solved but can’t remember exactly but like @Jaeyoung-Lim said:

  1. First check your mixer and airframe. Most importantly check mixer.
  2. Go step by step and if you are getting specific error. Committing here will be helpful.
  3. For me my sdf wasn’t good enough so be sure about your model’s sdf. Check difference with same models and be careful about PX4 version

Hi, followed the same process. The model loads up and everything looks fine, but the terminal window is stuck at

[Msg] Waiting for master.
[Msg] Connected to gazebo master @
[Msg] Publicized address: IP Address

and loads up gazebo, but the terminal window doesn’t load any more text lines. I mean usually the [MSG] loads then lines come where we put commander takeoff. unable to get that with the custom mode, checked my mavlink interface and that looks normal.

sometimes get this error as well

[Wrn] [] Queue limit reached for topic /gazebo/default/user_camera/pose, deleting message. This warning is printed only once.