Drone is too heavy to takeoff in simulation - Gazebo Plugin

Hi,

I’m new to ArduPilot and I’m trying to simulate the takeoff of a quadrotor in Gazebo using Ardupilot controllers.
So, as long as I set a mass of 2 kg to my drone, it perfectly takeoff and moves around the word, but since my drone is almost 5kg heavy and it also carries a 2kg payload, I changed that in my sdf file and now the drone doesn’t takeoff anymore.
I do believe this is due to a wrong setting in the gazebo plugin for the motor simulation, but I have no idea how to change that.

This is the setting of my plugin so far:

<plugin name="arducopter_plugin" filename="libArduPilotPlugin.so">
  <fdm_addr>127.0.0.1</fdm_addr>
  <fdm_port_in>9002</fdm_port_in>
  <fdm_port_out>9003</fdm_port_out>   
  <!--  Require by APM : Only change model and gazebo from XYZ to XY-Z coordinates -->
  <modelXYZToAirplaneXForwardZDown>0 0 0 3.141593 0 0</modelXYZToAirplaneXForwardZDown>
  <gazeboXYZToNED>0 0 0 3.141593 0 0</gazeboXYZToNED>
  <imuName>quad_demo::quad::quad/imu_link::imu_sensor</imuName>
  <connectionTimeoutMaxCount>5</connectionTimeoutMaxCount>

  <control channel="0">  
    <type>VELOCITY</type>
    <offset>0</offset>
    <p_gain>0.20</p_gain>
    <i_gain>0</i_gain>
    <d_gain>0</d_gain>
    <i_max>0</i_max>
    <i_min>0</i_min>
    <cmd_max>2.5</cmd_max>
    <cmd_min>-2.5</cmd_min>
    <jointName>quad::rotor_0_joint</jointName>
    <multiplier>838</multiplier>
    <controlVelocitySlowdownSim>1</controlVelocitySlowdownSim>
  </control>

I’ve already tried to change the cmd_max and min parameters and the multiplier, with some higher values that I got from the motor’s specification (i’m using brushless motors DJI E2000) and actually, by setting:

  <cmd_max>5.1</cmd_max>
  <cmd_min>-5.1</cmd_min>
  <multiplier>6500</multiplier>

the drone does takeoff… but now it won’t stop. It keeps flying higher and higher, even if I’m trying to command it otherwise.

Unfortunately, I really need to put the real mass into simulation, but I’m struggling with this plugin!
Is there anyone who knows how to make it work? Or should I use a different plugin? Am I looking at the worng settings to change?

Appreciate any help in this and thanks in advance!

Hi @chiarls - you’ll need to look at all the dimensions of the frame to obtain something that works reasonably. This includes:

  • mass of the frame
  • the prop dimensions (which then determine the prop area and centre of pressure in the lift-drag plugins)
  • the max motor speed and expected motor speed at hover (determines the multiplier in the ArduPilotPlugin).

The multiplier is related to the motor RPM by:

RPM = 60 * multiplier / (2 * PI)

So a multiplier of 838 => 8000 RPM. If the hover throttle is 50% then the motor speed for hover is 4000 RPM. Increasing this by nearly a factor of 10 is probably not realistic.

You will also need to retune the model once you have changed the dimensions - as the parameters for the throttle. pitch, roll and yaw controllers are coupled to the frame size and mass, prop size and lift and motor speeds - much like a real vehicle.

1 Like

Hi @rhys thank you so much for the multiplier formula clarification.
So, my motor’s datasheet says that its KV is 130 rpm/V… does it mean that assuming a voltage of 50V the multiplier would be:

multiplier = 130 * 50 * (2 * PI) / 60 = 680 ?

Also, regarding the retuning of the model, the parameters that you’re talking about are

<p_gain>0.20</p_gain>
<i_gain>0</i_gain>
<d_gain>0</d_gain>

or should I look at other files for that?

That’s right - but that does seem like a low kV for a quad motor. For comparison the Iris specs given here (3DR Iris - the ready to fly UAV Quadcopter - Arduino based Arducopter UAV, the open source multi-rotor):

Iris Specifications

  • Motor to motor dimension: 550mm
  • Height: 100mm
  • Weight (with battery): 1282 grams
  • Average flight time: 10-15 minutes
  • 400 g (.8 lb) payload capacity
  • Battery: 3-cell 11.1 V 3.5 Ah lithium polymer with XT-60 type connector. Weight: 262 grams
  • Propellers: (2) 10 x 4.7 normal-rotation, (2) 10 x 4.7 reverse-rotation
  • Motors: AC 2830, 850 kV

which would give an unloaded motor multiplier:

multiplier = 11.1 * 850 * (2 * PI) / 60 = 988

Under load the max rpm will be lower (I’ve fixed the missing factor of 2 in my calc above as well).

The PID gains are for the velocity controller used to spin the simulated motor joints. These may need tuning if you change the motor characteristics significantly. They can be hard to tune as you need to plot the response of the joint velocity against a requested velocity command. Using the mavproxy command motortest {motor_no} 1 {pwm} {time_in_sec} is one way to do this.

The parameters for the lift drag plugin look like this:

    <plugin filename="gz-sim-lift-drag-system"
        name="gz::sim::systems::LiftDrag">
      <a0>0.3</a0>
      <alpha_stall>1.4</alpha_stall>
      <cla>4.2500</cla>
      <cda>0.10</cda>
      <cma>0.00</cma>
      <cla_stall>-0.025</cla_stall>
      <cda_stall>0.0</cda_stall>
      <cma_stall>0.0</cma_stall>
      <area>0.002</area>
      <air_density>1.2041</air_density>
      <cp>0.084 0 0</cp>
      <forward>0 1 0</forward>
      <upward>0 0 1</upward>
      <link_name>iris_with_standoffs::rotor_0</link_name>
    </plugin>

You will need to update the <area> and <cp> elements for each prop if you are using propellers different from those given in the specs above.

1 Like

These are the motors that I’m using:

I used the Iris model as starting point for my implementation and I also thought my kV was low compared to it, especially because my drone is like 4 times heavier. However, I’ve seen it fly with these motors, so I’m 100% sure they work… I just don’t know how. I’ll double check the specifications.

Thank you so much for your help!

@chiarls - based on the specs you supplied and some simple scaling, here are some settings you might try. You’ll need to adjust all the <multiplier> elements in the ArduPilot plugin and the <area> and <cp> elements in all the lift-drag plugin entries (retaining the existing signs). That may give you an initial set up that will let you tune the copter. Let us know how you get on as I’d be interested to know how well the config works.

Iris E2000
prop 10 x 4.7 21 x 7
prop diameter 254 mm 533 mm
<area> [1] 0.002 0.008
<cp> [2] 0.084 0 0 0.168 0 0
motor kV 850 130
battery voltage 11.1 52.2
rpm max 9435 6786
ang vel max 988 rad/s 710 rad/s
<multiplier> [3] 838 602
  1. Scaling prop area by 2 * 2
  2. Scaling prop diameter by 2
  3. Using a multiplier of approx. 85% ang vel max.
1 Like

Dear @rhys thank you so much!!!
It works!
The area value you provided is missing a zero, it would be 0.008, but with these parameters it works perfectly fine. The drone would takeoff and also move in a desired position.

Thank you again.

P.s. I have another problem now, but I think I will close this topic and open a new one, since it concerns the type of controller that I’m using - I developed a torque control and I need to apply it by using Ardupilot - just in case you’re interested.

Hi @rhys and @chiarls , I have similar issue here, only thing is I have heavier drone and the prop diameter about 750 mm.
So if I understand this right I can use scale by approximately 3 ?
cp * 3
multiplier I need to identify once I get motor specs, but I am not sure about the area? deos this mean I need to use 2*3 so the result would be 0.012? Unfortunately I cannot test it, until I get the motor spec, but I would like to have the other values ready for that moment :slight_smile: Can you help here, pls, or clarify? what is meant by the area? And do I need to tune the cmd max and min accordingly?

Never mind, change of inertia solved the issue :slight_smile: