|
|
|
@ -97,7 +97,11 @@ void Copter::throw_run()
@@ -97,7 +97,11 @@ void Copter::throw_run()
|
|
|
|
|
|
|
|
|
|
// initialise the demanded height to 3m above the throw height
|
|
|
|
|
// we want to rapidly clear surrounding obstacles
|
|
|
|
|
pos_control.set_alt_target(inertial_nav.get_altitude() + 300); |
|
|
|
|
if (g2.throw_type == ThrowType_Drop) { |
|
|
|
|
pos_control.set_alt_target(inertial_nav.get_altitude() - 100); |
|
|
|
|
} else { |
|
|
|
|
pos_control.set_alt_target(inertial_nav.get_altitude() + 300); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// set the initial velocity of the height controller demand to the measured velocity if it is going up
|
|
|
|
|
// if it is going down, set it to zero to enforce a very hard stop
|
|
|
|
@ -200,8 +204,13 @@ bool Copter::throw_detected()
@@ -200,8 +204,13 @@ bool Copter::throw_detected()
|
|
|
|
|
// Check for high speed (note get_inertial_nav methods use a cm length scale)
|
|
|
|
|
bool high_speed = inertial_nav.get_velocity().length() > 500.0f; |
|
|
|
|
|
|
|
|
|
// check for upwards trajectory
|
|
|
|
|
bool gaining_height = inertial_nav.get_velocity().z > 50.0f; |
|
|
|
|
// check for upwards or downwards trajectory (airdrop)
|
|
|
|
|
bool changing_height; |
|
|
|
|
if (g2.throw_type == ThrowType_Drop) { |
|
|
|
|
changing_height = inertial_nav.get_velocity().z < -50.0f; |
|
|
|
|
} else { |
|
|
|
|
changing_height = inertial_nav.get_velocity().z > 50.0f; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Check the vertical acceleraton is greater than 0.25g
|
|
|
|
|
bool free_falling = ahrs.get_accel_ef().z > -0.25 * GRAVITY_MSS; |
|
|
|
@ -209,8 +218,8 @@ bool Copter::throw_detected()
@@ -209,8 +218,8 @@ bool Copter::throw_detected()
|
|
|
|
|
// Check if the accel length is < 1.0g indicating that any throw action is complete and the copter has been released
|
|
|
|
|
bool no_throw_action = ins.get_accel().length() < 1.0f * GRAVITY_MSS; |
|
|
|
|
|
|
|
|
|
// High velocity or free-fall combined with incresing height indicate a possible throw release
|
|
|
|
|
bool possible_throw_detected = (free_falling || high_speed) && gaining_height && no_throw_action; |
|
|
|
|
// High velocity or free-fall combined with incresing height indicate a possible air-drop or throw release
|
|
|
|
|
bool possible_throw_detected = (free_falling || high_speed) && changing_height && no_throw_action; |
|
|
|
|
|
|
|
|
|
// Record time and vertical velocity when we detect the possible throw
|
|
|
|
|
if (possible_throw_detected && ((AP_HAL::millis() - throw_free_fall_start_ms) > 500)) { |
|
|
|
|