Added a function transforming the motor output signal
« on: January 28, 2017, 05:57:40 pm »
Hello,

I want to add an sqrt function that transforms the motor output signal.
Background:
I want to control the thrust force of the motor, which is proportional to the square
of the rpm value. The range of the value should be between 0 and 1 such that the minimal and max
value is not changed.

I tried to add the following code at the end of the function float ProcessMixer(...) in line 611 of actuator.c:
    if (result < 0.0f) {
        return result;
    } else {
        return sqrt(result);
    }
    // was return result;
This did not have the desired effect. What is a good location in the source code to do this kind of transformation?

Uwe

Re: Added a function transforming the motor output signal
« Reply #1 on: January 28, 2017, 07:59:38 pm »
TauLabs (LP shares OP as a parent with them) coded this with the powf() function so that the curve could be changed.  They also did some research to find the correct coefficient.  I forget the values they used.  It seems they set the default to 1.0 so you must change a setting to use it.

One factor to consider is that Control pulse width does not control RPM, so the curve isn't exactly what you expect.

search for powf
https://github.com/TauLabs/TauLabs/blob/33a0ab77341957717a9ae356c5d4cf555b2e7fb0/flight/Modules/Actuator/actuator.c

search for MotorInputOutputCurveFit
https://github.com/TauLabs/TauLabs/blob/next/shared/uavobjectdefinition/actuatorsettings.xml

Re: Added a function transforming the motor output signal
« Reply #2 on: January 28, 2017, 08:10:37 pm »
I suggested that using a curve to linearize the thrust was the right thing to do instead of TPS, but it was partially a political issue with users asking why we didn't have TPA (that's what it's called in CleanFlight).

We might have slightly better control characteristics if thrust was linear.