-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Fix idle delay race-condition #11206
Conversation
I don't think it solves the root cause of the problem
why exactly does the landdetector detect a takeoff? You only can enter the smooth-takeoff part if the vehicle was armed long enough (https://github.com/PX4/Firmware/blob/master/src/modules/mc_pos_control/mc_pos_control_main.cpp#L711-L714). If not in smooth-takeoff but still landed, then you enter this if-statement, where the setpoint is reset and hence the land-detector should not see any takeoff-setpoint.
It really depends what you expect from that hysteresis. When I introduced it, the goal was to delay the arming state such that propeller have enough time to reach idle speed. In theory, the right solution would be to set the arming-state-flag to true only if the propeller reached idle speed. This would ensure that the entire system receives a true arming-state flag at the same time. |
I'm open to suggestions but #11167 looks more like a symptom of this cause to me.
Sometimes it does, sometimes it doesn't and I'm honestly not sure why. But this pr fixes the problem. And the fix makes sense to me because you don't need to start the task when you're anyways delaying the takeoff. That defeats the reason to not start the task already before arming.
I have to object for safety reasons. The
It's not to force a takeoff after the delay but to force a delay before a possible takeoff. Or what did you mean? EDIT: force-push to hopefully make CI being able to checkout again |
0247866
to
2ad7ac3
Compare
The issue to solve is / was the following: |
by the way, the entire logic also depends on what "armed" means within the autopilot. |
We're talking about the exact same intention just with different words 😉 arm -> wait for the motors to reach idle speed -> possible takeoff Is there now anything wrong with the fix (first commit) or with the names (second commit)? We can discuss that separately. |
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.
It seems correct to me to start the flight task only when the drone is fully ready for takeoff.
However, maybe MPC_SPOOLUP_TIME
might be a more precise name. What do you think?
@@ -159,7 +159,7 @@ class MulticopterPositionControl : public ModuleBase<MulticopterPositionControl> | |||
(ParamInt<px4::params::MPC_POS_MODE>) MPC_POS_MODE, | |||
(ParamInt<px4::params::MPC_AUTO_MODE>) MPC_AUTO_MODE, | |||
(ParamInt<px4::params::MPC_ALT_MODE>) MPC_ALT_MODE, | |||
(ParamFloat<px4::params::MPC_IDLE_TKO>) MPC_IDLE_TKO, /**< time constant for smooth takeoff ramp */ | |||
(ParamFloat<px4::params::MPC_TKO_DELAY>) MPC_TKO_DELAY, /**< time between arming and takeoff */ |
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 don't think this name is better. I agree with @bresch, `MPC_SPOOL_UP_TIME' or something similar would be better
I would really appreciate to find first the actual bug. In principle, there should not be any smooth-takeoff until the arming-hysteresis turns true. If this is not the case, then that is a bug that needs to be found first |
@Stifael This part gets skipped if the land detector fails: https://github.com/PX4/Firmware/blob/766f911005dc4949925a46507236c62582d54d59/src/modules/mc_pos_control/mc_pos_control_main.cpp#L739 |
This does not pass the Dronecode SDK integration test, not sure if it is supposed to or if this is orthogonal to it. |
What is the current status here? @MaEtUgR any insights? @julianoes Can we set up your test in CI? |
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.
This works with the Dronecode SDK integration hover tests, both with MPC_TKO_DELAY
set to 0 and MPC_TKO_DELAY
set to 5. However, if the delay is set too high, it will auto-disarm after arming before receiving the takeoff command.
That's something I'm aware of. This was the case before this pr and stays unchanged. The question for that is: Does someone have a motor "spool up time" of >10 seconds: https://github.com/PX4/Firmware/blob/c2e48f45ab21101a86217f6b7a515c54ac0d468f/src/modules/commander/Commander.cpp#L1747-L1748 |
is this PR still relevant, given that it does not solve the root cause? The root cause was solved here. |
Probably not 😄 |
@bresch, |
Yes, we already discussed. I'll rebase and change the name. |
2ad7ac3
to
030d6a9
Compare
030d6a9
to
2f9540d
Compare
I rebased and changed naming and description inside the second commit only. Review? |
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.
Perfect, thanks.
Context
I think I found the root cause of the problem addressed in #11167
The first commit is the fix the second is refactoring only.
Describe problem solved by the proposed pull request
The idle time configured by
MPC_IDLE_TKO
does not always get executed. There's a race-condition between arming, when the flight task gets started and the takeoff. This inconsistently results in not awaiting the configured idle time and if awaited still too abrupt takeoffs without a proper takeoff ramp. See the excellent description of @bresch in #11167.Describe your solution
The required flight task should get started at the exact time we want to take off. It was started when arming and the takeoff happened later. This change is necessary because otherwise the task produces setpoints, the land detector detects a takeoff but the takeoff did not happen yet because it's delayed by the
arm_hysteresis
(which I refactored to the nametakeoff_delay_hysteresis
because I think it better describes what it does).Test data / coverage
A lot of SITL testing