|
|
|
@ -461,6 +461,7 @@ void AC_Avoid::adjust_velocity_inclusion_circles(float kP, float accel_cmss, Vec
@@ -461,6 +461,7 @@ void AC_Avoid::adjust_velocity_inclusion_circles(float kP, float accel_cmss, Vec
|
|
|
|
|
|
|
|
|
|
// get the margin to the fence in cm
|
|
|
|
|
const float margin_cm = fence->get_margin() * 100.0f; |
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "---- margin_cm %f ----",margin_cm ); |
|
|
|
|
|
|
|
|
|
// get stopping distance as an offset from the vehicle
|
|
|
|
|
Vector2f stopping_offset; |
|
|
|
@ -514,6 +515,8 @@ void AC_Avoid::adjust_velocity_inclusion_circles(float kP, float accel_cmss, Vec
@@ -514,6 +515,8 @@ void AC_Avoid::adjust_velocity_inclusion_circles(float kP, float accel_cmss, Vec
|
|
|
|
|
// implement stopping behaviour
|
|
|
|
|
const Vector2f stopping_point_plus_margin = position_NE_rel + stopping_offset; |
|
|
|
|
const float dist_cm = safe_sqrt(dist_sq_cm); |
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "---- dist_cm %f ----",dist_cm ); |
|
|
|
|
|
|
|
|
|
if (dist_cm >= radius_cm - margin_cm) { |
|
|
|
|
// vehicle has already breached margin around fence
|
|
|
|
|
// if stopping point is even further from center (i.e. in wrong direction) then adjust speed to zero
|
|
|
|
@ -578,6 +581,7 @@ void AC_Avoid::adjust_velocity_exclusion_circles(float kP, float accel_cmss, Vec
@@ -578,6 +581,7 @@ void AC_Avoid::adjust_velocity_exclusion_circles(float kP, float accel_cmss, Vec
|
|
|
|
|
|
|
|
|
|
// get the margin to the fence in cm
|
|
|
|
|
const float margin_cm = fence->get_margin() * 100.0f; |
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "---- margin_cm %f , speed: %f ----",margin_cm ,desired_speed); |
|
|
|
|
|
|
|
|
|
// calculate stopping distance as an offset from the vehicle (only used for BEHAVIOR_STOP)
|
|
|
|
|
// add a margin so we look forward far enough to intersect with circular fence
|
|
|
|
@ -624,6 +628,8 @@ void AC_Avoid::adjust_velocity_exclusion_circles(float kP, float accel_cmss, Vec
@@ -624,6 +628,8 @@ void AC_Avoid::adjust_velocity_exclusion_circles(float kP, float accel_cmss, Vec
|
|
|
|
|
// implement stopping behaviour
|
|
|
|
|
const Vector2f stopping_point_plus_margin = position_NE_rel + stopping_offset; |
|
|
|
|
const float dist_cm = safe_sqrt(dist_sq_cm); |
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "---- margin_cm %f ,adjust_velocity_exclusion_circles ----",dist_cm ); |
|
|
|
|
|
|
|
|
|
if (dist_cm < radius_cm + margin_cm) { |
|
|
|
|
// vehicle has already breached margin around fence
|
|
|
|
|
// if stopping point is closer to center (i.e. in wrong direction) then adjust speed to zero
|
|
|
|
|