mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-22 00:28:30 -04:00
Copter: consolidate throw mode state into structure
This commit is contained in:
parent
381397c7bd
commit
595aea236a
@ -274,14 +274,6 @@ private:
|
|||||||
uint32_t start_ms;
|
uint32_t start_ms;
|
||||||
} takeoff_state;
|
} takeoff_state;
|
||||||
|
|
||||||
// throw mode state
|
|
||||||
struct {
|
|
||||||
ThrowModeStage stage;
|
|
||||||
ThrowModeStage prev_stage;
|
|
||||||
uint32_t last_log_ms;
|
|
||||||
bool nextmode_attempted;
|
|
||||||
} throw_state = {Throw_Disarmed, Throw_Disarmed, 0, false};
|
|
||||||
|
|
||||||
uint32_t precland_last_update_ms;
|
uint32_t precland_last_update_ms;
|
||||||
|
|
||||||
// altitude below which we do no navigation in auto takeoff
|
// altitude below which we do no navigation in auto takeoff
|
||||||
@ -410,9 +402,15 @@ private:
|
|||||||
// Flip
|
// Flip
|
||||||
Vector3f flip_orig_attitude; // original copter attitude before flip
|
Vector3f flip_orig_attitude; // original copter attitude before flip
|
||||||
|
|
||||||
// Throw
|
// throw mode state
|
||||||
uint32_t throw_free_fall_start_ms = 0; // system time free fall was detected
|
struct {
|
||||||
float throw_free_fall_start_velz = 0.0f;// vertical velocity when free fall was detected
|
ThrowModeStage stage;
|
||||||
|
ThrowModeStage prev_stage;
|
||||||
|
uint32_t last_log_ms;
|
||||||
|
bool nextmode_attempted;
|
||||||
|
uint32_t free_fall_start_ms; // system time free fall was detected
|
||||||
|
float free_fall_start_velz; // vertical velocity when free fall was detected
|
||||||
|
} throw_state = {Throw_Disarmed, Throw_Disarmed, 0, false, 0, 0.0f};
|
||||||
|
|
||||||
// Battery Sensors
|
// Battery Sensors
|
||||||
AP_BattMonitor battery;
|
AP_BattMonitor battery;
|
||||||
|
@ -234,13 +234,13 @@ bool Copter::throw_detected()
|
|||||||
bool possible_throw_detected = (free_falling || high_speed) && changing_height && no_throw_action;
|
bool possible_throw_detected = (free_falling || high_speed) && changing_height && no_throw_action;
|
||||||
|
|
||||||
// Record time and vertical velocity when we detect the possible throw
|
// Record time and vertical velocity when we detect the possible throw
|
||||||
if (possible_throw_detected && ((AP_HAL::millis() - throw_free_fall_start_ms) > 500)) {
|
if (possible_throw_detected && ((AP_HAL::millis() - throw_state.free_fall_start_ms) > 500)) {
|
||||||
throw_free_fall_start_ms = AP_HAL::millis();
|
throw_state.free_fall_start_ms = AP_HAL::millis();
|
||||||
throw_free_fall_start_velz = inertial_nav.get_velocity().z;
|
throw_state.free_fall_start_velz = inertial_nav.get_velocity().z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once a possible throw condition has been detected, we check for 2.5 m/s of downwards velocity change in less than 0.5 seconds to confirm
|
// Once a possible throw condition has been detected, we check for 2.5 m/s of downwards velocity change in less than 0.5 seconds to confirm
|
||||||
bool throw_condition_confirmed = ((AP_HAL::millis() - throw_free_fall_start_ms < 500) && ((inertial_nav.get_velocity().z - throw_free_fall_start_velz) < -250.0f));
|
bool throw_condition_confirmed = ((AP_HAL::millis() - throw_state.free_fall_start_ms < 500) && ((inertial_nav.get_velocity().z - throw_state.free_fall_start_velz) < -250.0f));
|
||||||
|
|
||||||
// start motors and enter the control mode if we are in continuous freefall
|
// start motors and enter the control mode if we are in continuous freefall
|
||||||
if (throw_condition_confirmed) {
|
if (throw_condition_confirmed) {
|
||||||
|
Loading…
Reference in New Issue
Block a user