PX4: dynamic control need for a drone

That part is slightly wrong; the physical relationship between f and PWM is as follows:
f -- linear --> omega^2 -- sqrt --> omega -- linear --> pwm
or
pwm = a1*(sqrt(a2*f + b2)) + b1. To further specify this, a2 is the propeller constant. The other variables are system specific (i.e., dependent on your motor, esc, …)
What you are observing (I do so as well), is the ESC compensating for the quadratic relationship.
So yeah, using a linear relationship works (I’m doing the same), the physics, however, would predict something else.

To test that, I’d recommend something like [this]

1 Like

@Jonathan_Wittmer Thanks for your answer. It is true the pitch and roll torques are result of the thrust forces generated by different motors. The yaw torques are reaction torques of the motors. Since they are independent, you still linearise them by
n_t = T/T_max
n_roll = tau_roll/ tau_roll_max
n_pitch = tau_roll/ tau_pitch_max
n_yaw = tau_roll/ tau_yaw_max
Am I understanding correct?

Not quite. You are really only linearizing on the force, at least for the roll and pitch torques. I’m assuming at this point you know what the mapping looks like for the torques so I will neglect that in the below algorithm. The algorithm should look something like this:
Forces and torques from PID
Convert Roll Torques to Forces on each motor: F_roll
Convert Pitch Torques to Forces on each motor: F_pitch
Convert yaw torque to force by answering: What is the force differential required to achieve torque?
F_motor = F_z (from PID) + F_roll + F_pitch + F_yaw
Some of the F_roll, F_pitch, and F_yaw will be positive and some negative so that the average of F_motor is F_z.

The linearization is in the assumption that the force to motor speed relationship is linear. Torque is defined by your body frame and needs mapped to a force since you only have control of thrust forces, not torques directly.

Dear all,

I reclaim this old post because I am interesting to the same topic of @robin-ecn! In particular, I am working in simulation right now using SITL and I successfully calculated the desired forces and torques needed to minimize the position error of my UAV. Next steps require to switch on a real platform, but now I am stuck in the final step of my controller: convert the torques to motor input. I know how to directly control the motor using ORB but I miss how to implement my own mixer… that is, how to implement the allocation matrix to obtain the needed rotation velocity and convert them in motor input.

These steps seems very simple, considering the post of @Jonathan_Wittmer but I am wandering if a more specific documentation exists on this topic. I am using a cross configuration for my quadcopter, and I am not aware about the dynamic model of the propellers… so I don’t know how to select the maximum applicable thrust!

I appreciate any kind of help on this topic!

Hello, I have a similar problem. And that is how I can find what is the total torque that is normalized?
For example for max pitch moment, is it max thrust of one motor times the arm times “2”? So if it is this way, it is considered that one motor is at full thrust and the other one is at negative full thrust that is not practical.
Another way is that I assume hovering condition and suppose that motor thrust never gets negative. In this case, max pitch moment occurs when one motor is at full thrust and the other is almost idle.
I want to know what is the rule that the flight controller use for definition of max moment.
Thanks

Hi Jonathan, I really appreciate it if you could answer my question.

Hi Mate,

I am sorry to reply so late and also sorry to tell me that I have not found the solution for this.