Skip to content

Commit

Permalink
MultirotorMixer: hotfix [-1,1] scaling
Browse files Browse the repository at this point in the history
After it was mistakenly rescaled in
26bac78#diff-899d35a48340c6065702d4fa77b70f0d
#15563
  • Loading branch information
MaEtUgR authored and dagar committed Aug 27, 2020
1 parent d4296db commit bc227aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/mixer/MultirotorMixer/MultirotorMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ MultirotorMixer::MultirotorMixer(ControlCallback control_cb, uintptr_t cb_handle
_tmp_array(new float[_rotor_count])
{
for (unsigned i = 0; i < _rotor_count; ++i) {
_outputs_prev[i] = 0.f;
_outputs_prev[i] = -1.f;
}
}

Expand Down Expand Up @@ -356,7 +356,7 @@ MultirotorMixer::mix(float *outputs, unsigned space)
_thrust_factor));
}

outputs[i] = math::constrain(outputs[i], 0.f, 1.f);
outputs[i] = math::constrain((2.f * outputs[i] - 1.f), -1.f, 1.f);
}

// Slew rate limiting and saturation checking
Expand All @@ -370,7 +370,7 @@ MultirotorMixer::mix(float *outputs, unsigned space)
// clipping if airmode==roll/pitch), since in all other cases thrust will
// be reduced or boosted and we can keep the integrators enabled, which
// leads to better tracking performance.
if (outputs[i] < 0.01f) {
if (outputs[i] < -0.99f) {
if (_airmode == Airmode::disabled) {
clipping_low_roll_pitch = true;
clipping_low_yaw = true;
Expand Down
5 changes: 5 additions & 0 deletions src/lib/mixer/MultirotorMixer/test_mixer_multirotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ int main(int argc, char *argv[])
return -1;
}

// Account for MultirotorMixer outputing [-1,1] and python script [0,1]
for (unsigned i = 0; i < rotor_count; i++) {
actuator_outputs[i] = (actuator_outputs[i] + 1.f) * .5f;
}

// read expected outputs
count = 0;
float expected_output[output_max];
Expand Down

0 comments on commit bc227aa

Please sign in to comment.