mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Use cos_lookup instead of sin_looup(x+90)
This commit is contained in:
parent
3982ad0046
commit
490955dbea
@ -100,12 +100,12 @@ int stabilization_relay_rate(float error, float *output, int axis, bool reinit)
|
||||
|
||||
// Project the error onto a sine and cosine of the same frequency
|
||||
// to accumulate the average amplitude
|
||||
int dT = thisTime - lastHighTime;
|
||||
uint32_t phase = 360 * dT / relay.Period[axis];
|
||||
int32_t dT = thisTime - lastHighTime;
|
||||
int32_t phase = (360 * dT) / relay.Period[axis];
|
||||
if(phase >= 360)
|
||||
phase = 1;
|
||||
phase = 0;
|
||||
accum_sin += sin_lookup_deg(phase) * error;
|
||||
accum_cos += sin_lookup_deg(phase + 90) * error;
|
||||
accum_cos += cos_lookup_deg(phase) * error;
|
||||
accumulated ++;
|
||||
|
||||
// Make sure we've had enough time since last transition then check for a change in the output
|
||||
|
Loading…
x
Reference in New Issue
Block a user