Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multicopter mixer saturation handling strategy -- continue #9062

Merged
merged 17 commits into from
Mar 23, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Multicopter mixer - Use already computed value instead of recomputing it
bresch committed Mar 23, 2018
commit 077ca2f416c51d75ffc878217082ba9420dd86fc
2 changes: 1 addition & 1 deletion src/lib/mixer/mixer_multirotor.cpp
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ MultirotorMixer::mix(float *outputs, unsigned space)
}

} else {
roll_pitch_scale = 1 / (max_out - min_out);
roll_pitch_scale = 1 / (delta_out_max);
boost = 1.0f - ((max_out - thrust) * roll_pitch_scale + thrust);
Copy link
Member

@MaEtUgR MaEtUgR Mar 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this formula is for...
When min and max are symetric with respect to the middle (thrust) then it's correct but can be simplified to boost = 0.5f - thrust;

In an asymetric case, which I suppose the math is for, the result is incorrect according to my analysis. When I find any mistake I might have made or a better solution I'll suggest it.

Copy link
Member

@MaEtUgR MaEtUgR Mar 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that the calculation here: https://github.com/PX4/Firmware/pull/9062/files#diff-40032af52ac957eae697d7d0a1856ef2R252 only scales roll and pitch (like the name suggests). This makes things unnecessary complicated when the mixer is not symetric.

If it's symetric boosting the thrust to be 0.5 is the right solution because all the authority gets used.

If it's not symetric it would be a lot easier to directly generate the correct output instead of rerunning and rescaling the whole mixer... Similar to what I did here: https://github.com/PX4/Firmware/pull/8485/files#diff-40032af52ac957eae697d7d0a1856ef2R215

Hopefully I'll get around to do a suggestion in a pr.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formula is for the asymmetric case and is from the constraint
(max_out - thrust*thrust_scale)*roll_pitch_scale + (thrust + boost)*thrust_scale = 1.0.
Assuming the thrust_scale is 1.0, the constraint is
(max_out - thrust)*roll_pitch_scale + thrust + boost = 1.0
then
boost = 1 - (max_out - thrust)*roll_pitch_scale - thrust.

It could also be simplified by using the min output:
(min_out - thrust)*roll_pitch_scale + thrust + boost = 0
which gives
boost = -(min_out - thrust)*roll_pitch_scale - thrust

Copy link
Member

@MaEtUgR MaEtUgR Mar 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bresch Yeah I found all these variants also with the min:

boost1 = 1-thrust-roll_pitch_scale*(max_out - thrust);
boost2 = -thrust -roll_pitch_scale*(min_out - thrust);

but my script still gave the wrong output and just now when I wrote with you on slack I realized my script had a mistake in it. Sorry for the churn, it's correct.

}