Thrust to throttle in /mavros/setpoint_raw/attitude

I have to publish a required throttle and attitude to setpoint_raw/attitude. I am unable to figure out, how a mapping between the actual thrust(force or acceleration) required and throttle can be made. Any help?

Please note that the required acceleration is computed using a guidance algorithm.
Thanks in advance!

1 Like

I am having the same question. Do you have any solution?

Yes!

I came up with a controller to provide the throttle value from the required thrust.

throttle = throttle + (a_cmd - a_curr) *k

Here, a_curr is the value from IMU (mavros/imu/data), a_cmd is the required acceleration/thrust.

The gain, k should be adjusted. I am using k = 0.00125

Thanks so much for replying.

But I have some questions for your controller.

(1) do you publish this throttle to the mavros topic ~setpoint_raw/target_attitude as its thrustļ¼Ÿ

ļ¼ˆ2ļ¼‰ if we say a_cmd is the required thrust 6N, what is the a_curr?

(3) why do you put a throttle in the right side of the equation?

(4) the thrust for the setpoint_raw/target_attitude should be in (0~1), do you saturate it later?

  1. I publish it to setpoint_raw/attitude

  2. I command it in terms of acceleration. a_cmd is the magnitude of required acceleration

  3. In each iteration, throttle is incremented or decremented based on acceleration.

  4. Yes, throttle value is saturated within 0.15 and 1.0

1 Like

But, do you find a precise model for mapping thrust into the normalised value? Also, did you try to control the torque?:grinning:

Currently working on the same. Will update once some result is obtained.

I will try as well.
Thank you very much for your help:grinning:

I found the following link:
(Static) Thrust = f(RPM).
I think it should be reasonable to calculate RPM = f(Thrust) given that equation.
(S)He also explains the derivation of the equation.
@BossHater: how did you come up with your equation?

throttle = throttle + (a_cmd - a_curr) *k

Is there any scientific background to that or is it a fit using some data?
I donā€™t want to sound rude, just wonderingā€¦

I thinks his approach is more like a P controllerā€¦It is not based on the model

@robin-ecn The only thing you need to figure out is the scaling factor between the normalized thrust and the acceleration. This is hardwawre dependent on what kind of mootrs / voltage you are using.

A good guess can be made with the hover throttle. For example, if your drone hovers at a normalized thrust value of 0.5, that means the normalized thrust value of 0.5 is going to be close to accelration value of 9.8m/s^2.

This way, the normalized thrust values can be mapped to the actual acceleration.

My bad, it obviously isā€¦
Still, maybe a function would do better?

I think it could be better to find the exact mapping. Maybe this How are pwm values set after controllers outputs are calculated for quadrotors? would be useful for you.

Thanks man.

But we are not sure the mapping is linear, right? I am not sure about that. That is why I am stepping inside of the px4 and mavros codes trying finding out the exact relation.

@robin-ecn The actuator commands corresponds to the PWM values commanded on the ESCs. The nonlinearity is not that high and I believe the performance will not be too bad even if you assume that it is linear. Given that the thrust values will not vary too much around the hovering value of the thrust commands.

Even if you manage to model the nonlinearity between the pwm and thrust generation, this will no longer hold when the drone starts to move dynamically as the thrust generated by the rotors will vary on the load and speed.

There are a lot of people testing motors and measuring thrust vs pwm values on benches so this could be a good reference for you

Thanks so much for you reply. I agree even with the correct model, it is not the case when the drone moves dynamically.

Check the actuator_control in mavros mavros_msgs/ActuatorControl Documentation.
I believe it is useful.

@robin-ecn are you by chance talking about this topic (Control Multicopter via thrust f and moments M)?

It was me as well.:joy:

Hi, Jaeyoung.

I have a question. When you said ā€œThe actuator commands corresponds to the PWM values commanded on the ESCs.ā€, you mean ā€œactuator_control provided by MAVROS are actually the PWM of the motorsā€?

Now I am trying to control the motors directly, do you have some good reference on that.

Thanks very much