|
|
|
@ -134,6 +134,15 @@ AP_Follow::AP_Follow() :
@@ -134,6 +134,15 @@ AP_Follow::AP_Follow() :
|
|
|
|
|
AP_Param::setup_object_defaults(this, var_info); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// restore offsets to zero if necessary, should be called when vehicle exits follow mode
|
|
|
|
|
void AP_Follow::clear_offsets_if_required() |
|
|
|
|
{ |
|
|
|
|
if (_offsets_were_zero) { |
|
|
|
|
_offset = Vector3f(); |
|
|
|
|
} |
|
|
|
|
_offsets_were_zero = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// get target's estimated location
|
|
|
|
|
bool AP_Follow::get_target_location_and_velocity(Location &loc, Vector3f &vel_ned) const |
|
|
|
|
{ |
|
|
|
@ -346,16 +355,19 @@ void AP_Follow::init_offsets_if_required(const Vector3f &dist_vec_ned)
@@ -346,16 +355,19 @@ void AP_Follow::init_offsets_if_required(const Vector3f &dist_vec_ned)
|
|
|
|
|
if (!_offset.get().is_zero()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
_offsets_were_zero = true; |
|
|
|
|
|
|
|
|
|
float target_heading_deg; |
|
|
|
|
if ((_offset_type == AP_FOLLOW_OFFSET_TYPE_RELATIVE) && get_target_heading_deg(target_heading_deg)) { |
|
|
|
|
// rotate offsets from north facing to vehicle's perspective
|
|
|
|
|
_offset = rotate_vector(-dist_vec_ned, -target_heading_deg); |
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "Relative follow offset loaded"); |
|
|
|
|
} else { |
|
|
|
|
// initialise offset in NED frame
|
|
|
|
|
_offset = -dist_vec_ned; |
|
|
|
|
// ensure offset_type used matches frame of offsets saved
|
|
|
|
|
_offset_type = AP_FOLLOW_OFFSET_TYPE_NED; |
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "N-E-D follow offset loaded"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|