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: https://github.com/PX4/sitl_gazebo/issues/110
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?
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:
Create a folder under Tools/sitl_gazebo/models for your model, let’s call it my_vehicle
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)
Create a world file in Tools/sitl_gazebo/worlds called my_vehicle.world (Again, this can be based off the iris or solo world files)
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
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:
When increasing the mass of the vehicle, also increase the inertias. I found that Gazebo does not like really small inertias.
With the larger vehicle, tweak the motor values (but you have done this already)
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:
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:
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.
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.
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
@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!
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 76motordrone.world for model found
Using: /home/xavierrocker/Desktop/PX4-Autopilot/Tools/sitl_gazebo/models/76motordrone/76motordrone.sdf
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 my_vehicle.world
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 …)
I created a world file in Tools/sitl_gazebo/worlds called my_vehicle .world
You need to remove your world file
My issues
Can not connect to QGroundControl
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.
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 @ http://127.0.0.1:11345
[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] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/user_camera/pose, deleting message. This warning is printed only once.