-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Crash/tumble detection should not re-enable motors when flipped back #258
Comments
Agree, some form of freeze mode that requires a reset to fly again. |
A less intrusive option to the current codebase would be to disable the high-level commander when a tumble is detected. This would not solve the problem when a client is continuously setting new setpoints, but it would solve the cases when the Crazyflie is flying a pre-programmed sequence autonomously with the high-level commander. I think that a patch like this would essentially need to add a function to |
Pull requests are always welcome :-) |
This seems to do the trick for me; if I understand correctly the thrust is already set to zero, which should turn off the motors, all that we need is to ensure that the HL commander does not turn them back on when the drone is picked up from the floor: diff --git a/src/modules/src/sitaw.c b/src/modules/src/sitaw.c
index 87a9707..a3699a2 100644
--- a/src/modules/src/sitaw.c
+++ b/src/modules/src/sitaw.c
@@ -32,7 +32,7 @@
#include "param.h"
#include "trigger.h"
#include "sitaw.h"
-#include "commander.h"
+#include "crtp_commander_high_level.h"
/* Trigger object used to detect Free Fall situation. */
static trigger_t sitAwFFAccWZ;
@@ -138,6 +138,9 @@ static void sitAwPreThrustUpdateCallOut(setpoint_t *setpoint)
setpoint->mode.y = modeDisable;
setpoint->mode.z = modeDisable;
setpoint->thrust = 0;
+
+ /* Also stop the high-level commander */
+ crtpCommanderHighLevelStop();
}
#endif |
@ntamas, this looks like a really good addition to the current functionality. If you issue a pull request I'll merge it. If you want to put more time into it, the original issue was that the motors may start spinning again if a crashed CF (with stopped motors) is picked up. |
I'll create a PR soon. Stopping the HL controller will at least solve the part of the problem that happens when the setpoints are generated on-board (which is my use-case). Setpoints sent from an external controller are still an issue. I could add some kind of a boolean flag on top of the patch proposed above that also prevents the crash detector from allowing non-zero thrust until the Crazyflie is reset completely. |
Thinking aloud: if we add a boolean flag that cuts power to the motors, would it be okay to expose it as a settable parameter as well? This way it could be used to restore normal operation after a crash if the operator thinks it is safe to do so, without forcing a reset. |
Sounds good! Just one small modification: So in this case, the boolean flag should not be exposed directly as a parameter, instead there should be a parameter (a trigger) to reset it. The bool itself should probably be exposed as a log though, to expose the current state of the system. |
Hi @ntamas, I just noticed your PR and does it solve the issue where during flight controlled by the python lib and if a tumble occurs, the CF will still try to take off to desired position? |
Yes, that's the problem that the PR attempts to solve. Basically, once a tumble is detected, an internal flag is triggered in the firmware that prevents non-zero thrust from reaching the motors until the flag is reset by setting a certain parameter to 1. The high-level controller is also stopped when a tumble is detected. So, no matter whether you are using the high-level controller or just sending roll / pitch / yaw setpoints continuously, this should prevent the motors from spinning up again. Right now the patch has a problem, though: the same flag is triggered also when the CF is turned upside down and then back without the motors running (e.g., when you hold it in your hand). This could be a bit annoying and I am looking for guidance in the PR comments about how to resolve this in the least annoying way. |
maybe this flag is required to be enabled as a param? manually using the client or within the python lib so when flying manually, it won't annoy the user |
@NicksonYap You have a good point in that there are conflicting properties when flying manually and from a script. The firmware (as far as I can see) will not be able to understand if it is flown manually or by script so the parameter way you are suggesting would be a way to solve the problem. |
This change improves several issues with the current tumble detector: 1. The old detector was only enabled if the Kalman filter was initially enabled. If one switched dynamically to a different state estimator, this important safety feature did not engage. 2. The old detector triggered by angle, which is an estimated value. If the state estimator diverged, no tumble was detected. The new solution relies on the accelerometer instead, a direct sensor measurement. 3. The old detector was not sticky, i.e., a user might pick up a CF and it starts spinning again, see issue bitcraze#258. The new version triggers an emergencyStop instead. The emergency stop can be reset and read using the new parameter stabilizer.stop. 4. Smaller fixes: a) Add more #ifdef guards to only compile actually enabled code. b) Interface clean-ups This replaces the PR bitcraze#470. This change has been tested on a bench test and with the Crazyswarm.
fixed in #481 |
Crash/tumble detection (#248 ) is really helpful and prevents damage, but I think it can be improved a little bit. It's still potentially dangerous to re-enable the motors when the copter is flipped back up. If setpoints are still sent (e.g. a flow sequence is still running), the motors can start spinning again violently. This can cause (minor) injuries or lead to another crash, when the copter is dropped/flies away.
It would be best to cancel the running sequence or not accept setpoints until some kind of "reset"-packet is sent. Since this would be rather hard to implement (a flow sequence is most likely sent by a client and can't be canceled on the copter side), I'd recommend to kill the connection. There might be use-cases where this is inconvenient, but it's the safest option IMHO.
The text was updated successfully, but these errors were encountered: