PX4-SITL with custom URDF model, drone crash after take off

Hello,

I’m trying to achieve stable flight with a custom hexacopter model in the PX4 sitl and gazebo. I have modified the “posix_sitl.launch” in “/PX4/Firmware/launch” to point to my drone model. My own model is an URDF-File which copies most of the “typhoon_480.sdf” and converts it into urdf-syntax. This means I utilize the same plugins as the “typhoon_h480.sdf” including the same rotor arrangement. Basically I use a .urdf version of the “typhoon_h480.sdf” with my own drone model and custom parameters (for inertia, mass, rotorsize, etc)

When I open QGroundControl and give a takeoff order the drone does leave the ground, but the flight is very unstable. It immediately tilts to one direction and crashes - as you can see in the following image.

The red and blue rotors are rotating faster than all other rotors and that stays the same even after the drone topples over. I have tried swapping the control_channels for the libgazebo_mavlink_interface plugin, but the behaviour stays the same. There seems to be no relation, f.e. if I swap the channels of the blue and grey rotors, the grey rotor should behave like the blue rotor did before - but this does not happen. It always tilts in the same direction and seems to be unrelated to the channels.

Another issue: I have also tried to replace the drone collision with a simple cylinder shape, but when I do this I get “Preflight Fail: Accel Range, hold still on arming” warnings when I try to take off in QGroundControl. This does not happen when I use the 3D model file for collision.

It seems like I’m missing something important. Can someone tell me what I am missing if I want to properly set up a custom drone model?

  • I am using an URDF file instead of a SDF file. Would using an SDF file be better?
  • How do I setup the motor arrangements to properly work?
  • What are the required steps in order to get a working custom drone model? We would prefer to use the “roslaunch px4 posix_sitl.launch” instead of the “make px4_sitl gazebo” command.

If someone could help me out - that would be great.
Kind regards

@hsu-ret I don’t think PX4 SITL works with URDF files. The plugins refere to sdf files directly, so you cannot use URDF files

@Jaeyoung-Lim First I thought the same but then I looked into it - the plugins are included in < gazebo > tags, which are in sdf-syntax so the same parameters are defined. Also the rotors_description model of the iris (which is written in urdf.xacro) includes identical plugins, which are located in ~/PX4/Firmware/Tools/sitl_gazebo/models/rotors_description/urdf. So the plugins should work for URDF.

Sadly the rotors_description files seem to be especially designed for the iris and harder to adept to a hexacopter than classical sdf/urdf files.

@hsu-ret If you need an example of a hexacopter: https://github.com/PX4/sitl_gazebo/blob/master/models/typhoon_h480/typhoon_h480.sdf

I am sure you can “make” it work with urdfs, but it will not work out of the box. I recommend you work directly on a working sdf file as above so you have less unknowns at least in the beginning

That’s the same file I based my URDF file upon. It might be really some issues with the sdf/urdf plugins.

But including ros sensors in URDF syntax will be much harder then - but I will look into it.

What advantage does a sensor defined with URDF have over a sensor defined in SDF?

I usually approach this from the other direction where I find an old model that’s still using URDF and I convert it to SDF so I can easily add SDF defined sensors.

I believe URDF is technically considered a deprecated format for Gazebo as of 2016.

Mostly because of ROS, Rviz and their tf-tree respectivly. I know Gazebo states SDF as preferable.

The main question is about the plugins - can I switch between SDF/URDF syntax and use the same plugins? Do you know about this? Or does it depend on the plugins itself?

@hsu-ret Yes you can, but the plugin directly parses sdf so you always need to convert your urdf to sdf before you spawn it into gazebo https://github.com/PX4/sitl_gazebo/blob/eafc98b3eb311802200062f31698c2914c5ec22a/src/gazebo_mavlink_interface.cpp#L136

That is why we deprecated xacro because urdf/xacro doesn’t support the new syntaxes that sdf supports.

If I recall correctly my colleague tried to check the plugins via editing some console-outputs inside the if-statements to check, wether the plugins could parse the _sdf->HasElement("...") commands inside of URDF syntax, which worked, but maybe we were just lucky on that end.

If you say the urdf/xacro is deprecated - it is of course much more beneficial to change to sdf altogether. I also realized that the model files of px4-firmware/Tools/sitl_gazebo/models/rotors_description are not part of the master branch anymore - so there aren’t any urdf.xacros anymore.

Sadly this means I need to work with my test sdf file where I added a sensor which does not move with my drone, but stays on the ground even though it should be connected (I mean adding a hokouyo is fine but the velodyne vlp-16 doesn’t work at all) - but that’s out of scope here.

I will look into the sdf-files and maybe start a new thread, when I ran into errors, but for my original question of this post - it should be sufficient to note that URDF/xacro is deprecated.