Unwanted rotation at high throttle

Hi everyone !

I am having a trouble with a drone. The drone has a good behaviour at low speed. However, for a high throttle input (without any roll, pitch or yaw command), and so a bit of speed, the drone is very unstable in ACRO mode. Indeed it turns backwards like if there was a pitch command (so the front wing is higher than the back wing). It also rotates on the right, like if there was a roll command. This rotation is very quick and can become more than 90° (even almost upside-down drone) is 2-3 second.
In STABILIZED mode, I still have the problem but it is less important as the Pixhawk controls the angle (instead of rotation speed in ACRO), causing only a drift (instead of a complete rotation).

Here is flight log where you can see the problem in STABILIZED and ACRO : https://logs.px4.io/plot_app?log=4fd57545-c059-40a5-a229-187eb2c33c26

The pilot performs vertical accelerations (see Manual control inputs) and we see that Roll/Pitch or Rollrate/Pitchrate deviate from the setpoint without any correction from the Pixhawk.

Do you guys have any idea of the cause of the problem ?

Here is the setup I use :

  • Pixhawk 4
  • UAVCAN communication for the motors. Main mixer (IO).
  • VESCs as motor controllers.

The drone is imbalanced in yaw but we tried on a balanced drone and had the same problem.

Thank you in advance for your help !

1 Like

Hi @rem ,
Cool project! I remember that the UAVCAN mapping from raw value to duty cycle on the VESC does not exactly correcpond to the full range we’re sending from the PX4 side. In my case, the Idle speed sent by the autopilot was not enough for the motor to spin and the 10-20 last percents didn’t change the rpm anymore.
This latter effect can cause loss of attitude control since the mixer doesn’t know that the motors are saturated.

Is that maybe your issue?

Also, if I remember correctly, there are two different controllers in VESC that produce a different behavior at low and high rpm. This changes the add a nonlinear component to the problem during maneuvers.

Hi @bresch,
I did not know this difference in range covering, thank you ! This could effectively be the issue, I will check that.

Hi @bresch,
Indeed the mapping seems to be the problem. I could solve it with PPM control by adjusting maximum and minimum PWM values in VescTool.
However, with UAVCAN, I did not find where to change the mapping into the VESC firmware. For the moment, the VESCs output full throttle at 87% of the RC stick, so the last 13% of the throttle command don’t change the RPM and cause instability during vertical accelerations.
Did you manage to adapt UAVCAN mapping with your setup ?

@rem I just hacked the uavcan mixer in PX4… Then I tested but unfortunately I had to drop the project for something else. It was flying quite well and I’m still convinced that VESC is awesome.
I’m planning to take back the project soon and if you have a nice solution, please make a PR and I’ll be happy to review and test it.

@rem I didn’t test it yet (be careful, test it without props first!), but this should give you the possibility to set the correct min and max output values: https://github.com/PX4/Firmware/pull/13372

1 Like

Hi @bresch, thanks for your work on this issue !
I will test your solution with Raw command this afternoon.

On my side, I tried to do it with RPM command (replacing the “cmd” by “rpm” in esc.cpp), and writing the same command line as you did : float scaled = (outputs[i] + 1.0F) * 0.5F * delta_cmd + cmd_min;
However, I had some problems during tests in MC stabilized mode (when I increase until max throttle, no problem but when I decrease until throttle min, it remains at too high RPM for around 1s and then effectively reaches the cmd_min setpoint). No problem in ACRO though.

Is there an advantage to use Raw command instead of RPM one ?

I had some problems during tests in MC stabilized mode (when I increase until max throttle, no problem but when I decrease until throttle min, it remains at too high RPM for around 1s and then effectively reaches the cmd_min setpoint). No problem in ACRO though.

In stabilized there is a minimum thrust defined by this parameter: MPC_MANTHR_MIN
The thrust goes to that value until the vehicle detects landing and then goes to 0 (that’s why it takes about 1s to go to the lowest value). Here is the code. You can set that parameter lower or even 0 if you want to be able to reach min thrust when the throttle stick is at zero.

Is there an advantage to use Raw command instead of RPM one ?

RAW is easier to use because it maps to duty-cycle in VESC and you don’t need to tune the RPM controller. However, if you have the RPM loop tuned, you can have better performance with the RPM command. If you’re using the RPM command, don’t forget to use THR_MDL_FAC to linearize the thrust curve.
I think we should add a parameter to be able to choose if we want to send RPM or RAW messages.

In stabilized there is a minimum thrust defined by this parameter: MPC_MANTHR_MIN

Thanks, I didn’t know that!

When I use raw command, it looks like all my VESCs are not mapped the same way. In this log, you can see that the output of the Pixhawk is equal for all the motors : .
However, the resulting RPM are different :

With RPM control (and THR_MDL_FAC to 0), it seems to work quite well without propellers and the motors can reach their maximum of 100000 ERPM. But with propellers, when I try a vertical acceleration, the motors seem to “saturate” (with propellers, the maximum ERPM reachable is 85000, tested on a bench test). See this flight log. In actuator outputs, you see that the Output 2 is at maximum to compensate the unwanted rotation of the drone, and Output 3 is a bit lower to allow to re-establish the equilibrium.
But the RPM does not follow this command :

Here, the motor 3 (output 2 of Pixhawk) is not faster than motor 4 (output 3) as it should be.

It could be the motors that are not powerful enough, or something else in the firmware of the VESCs that limits the RPM with propellers (keeping in mind that we can reach max RPM without propellers). Let me know if you have an idea.