-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Position Control Refactoring Part 5 #13701
Conversation
bdcc15c
to
ffc35f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one comment, the reset looks good
@@ -113,7 +113,6 @@ void PositionControl::setConstraints(const vehicle_constraints_s &constraints) | |||
void PositionControl::update(const float dt) | |||
{ | |||
if (_skip_controller) { | |||
|
|||
// Already received a valid thrust set-point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you maybe extract those next lines
// Already received a valid thrust set-point.
// Limit the thrust vector.
float thr_mag = _thr_sp.length();
if (thr_mag > _lim_thr_max) {
_thr_sp = _thr_sp.normalized() * _lim_thr_max;
} else if (thr_mag < _lim_thr_min && thr_mag > FLT_EPSILON) {
_thr_sp = _thr_sp.normalized() * _lim_thr_min;
}
Into a "constrainThrustSetpoint" function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could but this snippet will be gone in the next step so I didn't want to make an effort:
https://github.com/PX4/Firmware/pull/12072/files#diff-dcd121f41884535de662c42a30c6f928R107-R120
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be one place at the end of the update sequence where thrust is limited for all cases and that one I can then break out into a function, good input 👍 :
position-control-refactoring5...acceleration-based-input#diff-dcd121f41884535de662c42a30c6f928R151-R158
ffc35f9
to
08c397a
Compare
I rebased without conflicts on master. |
@PX4/testflights can you please test this PR in all flight modes on several multicopters? |
08c397a
to
0d2e346
Compare
0d2e346
to
312e10e
Compare
Tested on NXP FMUK66 v3Modes Tested
Procedure Notes Logs Modes Tested
Procedure Notes Logs Modes Tested
Procedure Notes Logs |
Tested on Pixhawk 4 v5 f450 log: |
Tested on PixRacer V4: Maximum wind 10.2 m/sModes Tested Position Mode: Good. - Procedure Notes: Log: https://review.px4.io/plot_app?log=1221ea62-3709-4c9d-bb9a-943495a3ccc3 Log https://review.px4.io/plot_app?log=d6764bd5-f1e4-48cd-a8aa-79828a80ab2e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went again through the changes and it seems fine to me. You can merge this if the reported log files looks good to you and that CI passes.
@MaEtUgR This is because the tilt is limited to 12 degrees during the whole landing phase. Should be do like for the horizontal and vertical speed: gradually limit the tilt between alt1 and alt2 ? |
I know this issue. I mostly see when I do some crazy user test going full stick and shortly after takeoff it does a twitch because the tilt limit jumps. The problem is we can't get rid of the tilt limit, that is worse I figured out. Let's do something gradual but I'm fairly confident it's unrelated to this pr. |
Describe problem solved by this pull request
This is part 5 of the refactoring from the monster pr #12072 and should be easy to understand and review since the diff is manageable.
Describe your solution
PositionControl
library to a clear interface best shown in the unit test for it: https://github.com/PX4/Firmware/blob/6bd543156eab2ccfe639e90d9214e2e0128daa09/src/modules/mc_pos_control/PositionControl/PositionControlTest.cpp#L105-L109 with better doxygen descriptions and internal naming.!(constraints.tilt < _lim_tilt)
to(constraints.tilt > _lim_tilt)
.#include "PositiopnControl/PositionControl.hpp"
.= Vector3f(NAN, NAN, NAN);
with.setNaN();
, initialized allFlightTask
members with{}
.thrustToAttitude()
implementation.constraints.speed_xy
is not used in the controller for a long time so I remove the processing to avoid confusion. Once tasks don't use it internally for communicating speeds accross inheritance anymore we can get rid of the message field.skip_controller
flag is not yet possible with the old_interfaceMapping()
but this will be replaced in the next pr.Test data / coverage
SITL hover goto tested and unit tests pass.
Additional context
Part 4 that goes before this: #13347