Skip to content

Commit

Permalink
actuator: generate an inverse mixer matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
mlyle authored and glowtape committed Apr 17, 2018
1 parent fadde18 commit 0000004
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions flight/Modules/Actuator/actuator.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static MixerSettingsMixer1TypeOptions types_mixer[MAX_MIX_ACTUATORS];
*/

static float motor_mixer[MAX_MIX_ACTUATORS * MIXERSETTINGS_MIXER1VECTOR_NUMELEM];
static float motor_mixer_inv[MAX_MIX_ACTUATORS * MIXERSETTINGS_MIXER1VECTOR_NUMELEM];

/* These are various settings objects used throughout the actuator code */
static ActuatorSettingsData actuatorSettings;
Expand Down Expand Up @@ -410,6 +411,12 @@ static void compute_mixer()
#endif
}

static bool compute_inverse_mixer()
{
return matrix_pseudoinv(motor_mixer, motor_mixer_inv,
MAX_MIX_ACTUATORS, MIXERSETTINGS_MIXER1VECTOR_NUMELEM);
}

static void fill_desired_vector(
ActuatorDesiredData *desired,
float val1, float val2,
Expand Down Expand Up @@ -782,6 +789,14 @@ static void actuator_task(void* parameters)

compute_mixer();

/* If we can't calculate a proper inverse mixer,
* set failsafe.
*/
if (compute_inverse_mixer()) {
set_failsafe();
continue;
}

MixerSettingsThrottleCurve2Get(curve2);
MixerSettingsCurve2SourceGet(&curve2_src);
settings_updated = false;
Expand Down

0 comments on commit 0000004

Please sign in to comment.