[rotorcraft] separate KILL_ON_GROUND_DETECT with higher default threshold

- if KILL_ON_GROUND_DETECT is TRUE, enable killing of motors on ground detection
  used in default land block, add to your airframe file:
  <define name="KILL_ON_GROUND_DETECT" value="TRUE"/>
- THRESHOLD_GROUND_DETECT is now in m/s^2 and defaults to 25 m/s^2
This commit is contained in:
Felix Ruess
2013-02-24 01:16:27 +01:00
parent 2b8552b826
commit 3f3f5e090d
4 changed files with 12 additions and 9 deletions
+3 -1
View File
@@ -32,6 +32,8 @@
<!-- print the configuration during compiling -->
<define name="PRINT_CONFIG"/>
<define name="KILL_ON_GROUND_DETECT" value="TRUE"/>
</firmware>
<firmware name="setup">
@@ -238,7 +240,7 @@
<section name="AUTOPILOT">
<define name="MODE_MANUAL" value="AP_MODE_ATTITUDE_DIRECT"/>
<define name="MODE_AUTO1" value="AP_MODE_ATTITUDE_Z_HOLD"/>
<define name="MODE_AUTO2" value="AP_MODE_HOVER_Z_HOLD"/>
<define name="MODE_AUTO2" value="AP_MODE_NAV"/>
</section>
<section name="BAT">
+3 -2
View File
@@ -95,7 +95,8 @@ void autopilot_init(void) {
void autopilot_periodic(void) {
RunOnceEvery(NAV_PRESCALER, nav_periodic_task());
#ifdef FAILSAFE_GROUND_DETECT
#if FAILSAFE_GROUND_DETECT
INFO("Using FAILSAFE_GROUND_DETECT")
if (autopilot_mode == AP_MODE_FAILSAFE && autopilot_detect_ground) {
autopilot_set_mode(AP_MODE_KILL);
autopilot_detect_ground = FALSE;
@@ -103,7 +104,7 @@ void autopilot_periodic(void) {
#endif
/* set failsafe commands, if in FAILSAFE or KILL mode */
#ifndef FAILSAFE_GROUND_DETECT
#if !FAILSAFE_GROUND_DETECT
if (autopilot_mode == AP_MODE_KILL ||
autopilot_mode == AP_MODE_FAILSAFE) {
#else
+5 -4
View File
@@ -139,14 +139,15 @@ extern uint16_t autopilot_flight_time;
}
#endif
/** Ground detection based on accelerometers.
*/
/** Z-acceleration threshold to detect ground in m/s^2 */
#ifndef THRESHOLD_GROUND_DETECT
#define THRESHOLD_GROUND_DETECT ACCEL_BFP_OF_REAL(15.)
#define THRESHOLD_GROUND_DETECT 25.0
#endif
/** Ground detection based on vertical acceleration.
*/
static inline void DetectGroundEvent(void) {
if (autopilot_mode == AP_MODE_FAILSAFE || autopilot_detect_ground_once) {
struct NedCoor_i* accel = stateGetAccelNed_i();
struct NedCoor_f* accel = stateGetAccelNed_f();
if (accel->z < -THRESHOLD_GROUND_DETECT ||
accel->z > THRESHOLD_GROUND_DETECT) {
autopilot_detect_ground = TRUE;
+1 -2
View File
@@ -241,8 +241,7 @@ STATIC_INLINE void main_event( void ) {
GpsEvent(on_gps_event);
#endif
#ifdef FAILSAFE_GROUND_DETECT
INFO("Using FAILSAFE_GROUND_DETECT")
#if FAILSAFE_GROUND_DETECT || KILL_ON_GROUND_DETECT
DetectGroundEvent();
#endif