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

Cut motor thrust permanently after a tumble #470

Closed

Conversation

ntamas
Copy link
Contributor

@ntamas ntamas commented Sep 13, 2019

This PR is related to #258 and the discussion therein. It extends the current tumble detector such that:

  • it stops the high-level commander from sending setpoints
  • it preserves the "tumbled" situation until the operator explicitly marks it as resolved by resetting the state of the tumble detector with a designated parameter

I'm not fully satisfied with the PR yet; the current implementation would also detect a tumble if you hold the Crazyflie upside down for a while before takeoff, and would block the takeoff itself. I'm not sure what the best way would be to address it - we could either extend the tumble detector in sitAwTuTest() to also require significant motor thrust (not only a significant roll / pitch angle), or check the motor thrust in sitAwPreThrustUpdateCallOut() and don't set the sitAwMotorThrustCut flag if the motors are not running. Suggestions are appreciated.

@krichardsson
Copy link
Contributor

What about keeping this functionality passive until taking off and activating it when leaving the ground?
Not sure how to detect that we are flying though. One suggestions could be to look at the thrust to the motors as is done in the kalman estimator https://github.com/bitcraze/crazyflie-firmware/blob/master/src/modules/src/estimator_kalman.c#L300.

@whoenig
Copy link
Contributor

whoenig commented Sep 27, 2019

  1. I think it might be better to actually use the existing flag for an emergency here, rather than adding a new one: https://github.com/bitcraze/crazyflie-firmware/blob/master/src/modules/src/stabilizer.c#L303. This way we can deal consistently with resetting from various emergencies. There is currently no CRTP packet to reset the emergency, but that could be added in the future, or we can simply expose it as parameter.

  2. As for the flight detection, I think in this case you can check if the current controller output is non-zero, as suggested. One could either pass in the current control-struct pointer to the sitAw framework (similar to the kalman filter), or use pointers to existing logging variables (similar to the led-ring deck).

  3. (slight sidetrack from this issue). I found that the current tumble detector does not work reliably when using the EKF, because it relies on the current state estimate, which in case of a crash might or might not reflect the "upside-down" state. I suggest that we change the current check, or add another condition, that checks for sensorData->acc.z < -0.5f instead. We use this check in the crazyswarm firmware (in a hacky way, see https://github.com/USC-ACTLab/crazyflie-firmware/blob/crazyswarm-next/src/modules/src/stabilizer.c#L308-L317), and it has prevented many permanent motor/prop damages after crashes.

whoenig added a commit to whoenig/crazyflie-firmware that referenced this pull request Oct 4, 2019
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.
@krichardsson
Copy link
Contributor

Closing since this was implemented in PR #482
Thanks @ntamas for your effort!

@ntamas
Copy link
Contributor Author

ntamas commented Oct 4, 2019

Thanks and sorry for the lack of response; I would have needed some more time to finish this off, but I'm glad that there's a proper solution now!

(For the record, @krichardsson meant PR #481, not PR #482).

cafeciaojoe pushed a commit to cafeciaojoe/crazyflie-firmware that referenced this pull request Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants