forked from ArduPilot/ardupilot
-
Notifications
You must be signed in to change notification settings - Fork 25
/
landing_gear.cpp
38 lines (30 loc) · 1.13 KB
/
landing_gear.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "Copter.h"
#if LANDING_GEAR_ENABLED == ENABLED
// Run landing gear controller at 10Hz
void Copter::landinggear_update()
{
// exit immediately if no landing gear output has been enabled
if (!SRV_Channels::function_assigned(SRV_Channel::k_landing_gear_control)) {
return;
}
// support height based triggering using rangefinder or altitude above ground
int32_t height_cm = flightmode->get_alt_above_ground_cm();
// use rangefinder if available
switch (rangefinder.status_orient(ROTATION_PITCH_270)) {
case RangeFinder::Status::NotConnected:
case RangeFinder::Status::NoData:
// use altitude above home for non-functioning rangefinder
break;
case RangeFinder::Status::OutOfRangeLow:
// altitude is close to zero (gear should deploy)
height_cm = 0;
break;
case RangeFinder::Status::OutOfRangeHigh:
case RangeFinder::Status::Good:
// use last good reading
height_cm = rangefinder_state.alt_cm_filt.get();
break;
}
landinggear.update(height_cm * 0.01f); // convert cm->m for update call
}
#endif // LANDING_GEAR_ENABLED