|
|
|
@ -104,10 +104,7 @@ void AC_Circle::init()
@@ -104,10 +104,7 @@ void AC_Circle::init()
|
|
|
|
|
stage = 0; |
|
|
|
|
is_cw_turn = true; |
|
|
|
|
_circle_8_finish = false; |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
======= |
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "--- AC_Circle x:%.2f,y:%.2f \n",_center.x,_center.y);
|
|
|
|
|
>>>>>>> 098f02907d... 增加绕8字功能,一键8字,航线起飞和返航8字 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// set_circle_rate - set circle rate in degrees per second
|
|
|
|
@ -143,24 +140,14 @@ bool AC_Circle::turn_2_circle()
@@ -143,24 +140,14 @@ bool AC_Circle::turn_2_circle()
|
|
|
|
|
_angular_vel -= fabsf(_angular_accel) * dt; |
|
|
|
|
_angular_vel = MAX(_angular_vel, _angular_vel_max); |
|
|
|
|
} |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
|
|
======= |
|
|
|
|
>>>>>>> 098f02907d... 增加绕8字功能,一键8字,航线起飞和返航8字 |
|
|
|
|
//更新目标角和总的角度 update the target angle and total angle traveled
|
|
|
|
|
float angle_change = _angular_vel * dt; |
|
|
|
|
float _fabs_total; // circle count,float
|
|
|
|
|
// calculate target position
|
|
|
|
|
Vector3f target; |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
const Vector3f curr_pos = _inav.get_position(); |
|
|
|
|
Vector3f new_pos; |
|
|
|
|
float bearing_rad = atan2f(curr_pos.y-_center.y,curr_pos.x-_center.x); |
|
|
|
|
======= |
|
|
|
|
Vector3f new_pos; |
|
|
|
|
// float bearing_rad = atan2f(curr_pos.y-_center.y,curr_pos.x-_center.x);
|
|
|
|
|
float bearing_rad = _ahrs.yaw; |
|
|
|
|
>>>>>>> 098f02907d... 增加绕8字功能,一键8字,航线起飞和返航8字 |
|
|
|
|
static float last_bearing_rad ;
|
|
|
|
|
const Vector3f& stopping_point = _pos_control.get_pos_target(); |
|
|
|
|
switch (stage) |
|
|
|
@ -175,16 +162,6 @@ bool AC_Circle::turn_2_circle()
@@ -175,16 +162,6 @@ bool AC_Circle::turn_2_circle()
|
|
|
|
|
_pos_control.set_target_to_stopping_point_z(); |
|
|
|
|
// get stopping point
|
|
|
|
|
// set circle center to circle_radius ahead of stopping point
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
_center.x = stopping_point.x + _radius * _ahrs.cos_yaw(); |
|
|
|
|
_center.y = stopping_point.y + _radius * _ahrs.sin_yaw(); |
|
|
|
|
_center.z = stopping_point.z; |
|
|
|
|
// calculate velocities
|
|
|
|
|
calc_velocities(true); |
|
|
|
|
// set starting angle from vehicle heading
|
|
|
|
|
init_start_angle(true); |
|
|
|
|
last_bearing_rad = bearing_rad; |
|
|
|
|
======= |
|
|
|
|
_center.x = stopping_point.x + _radius * cosf(_ahrs.yaw + M_PI_2); |
|
|
|
|
_center.y = stopping_point.y + _radius * sinf(_ahrs.yaw + M_PI_2); // 圆心调整,+ M_PI_2 圆心正前改正右
|
|
|
|
|
_center.z = stopping_point.z; |
|
|
|
@ -196,7 +173,6 @@ bool AC_Circle::turn_2_circle()
@@ -196,7 +173,6 @@ bool AC_Circle::turn_2_circle()
|
|
|
|
|
_angle = wrap_PI(_ahrs.yaw - M_PI/2); |
|
|
|
|
last_bearing_rad = _ahrs.yaw; |
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "[i]init ag::%.2f,y:%.2f,r:%.2f,d:%.2f\n",_angle,_ahrs.yaw,bearing_rad,bearing_rad * RAD_TO_DEG);
|
|
|
|
|
>>>>>>> 098f02907d... 增加绕8字功能,一键8字,航线起飞和返航8字 |
|
|
|
|
stage = 1; |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
@ -206,17 +182,6 @@ bool AC_Circle::turn_2_circle()
@@ -206,17 +182,6 @@ bool AC_Circle::turn_2_circle()
|
|
|
|
|
_angle_total += angle_change; |
|
|
|
|
_fabs_total = fabsf(get_angle_total()/M_2PI); |
|
|
|
|
target.x = _center.x + _radius * cosf(_angle); |
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
target.y = _center.y - _radius * sinf(_angle); |
|
|
|
|
if(fabs(last_bearing_rad - bearing_rad) < 0.01 && _fabs_total > 0.9){ |
|
|
|
|
_center.x = _center.x + 2 * _radius* cosf(bearing_rad); |
|
|
|
|
_center.y = _center.y + 2 * _radius* sinf(bearing_rad); |
|
|
|
|
last_bearing_rad = atan2f(curr_pos.y-_center.y,curr_pos.x-_center.x); |
|
|
|
|
is_cw_turn = false; |
|
|
|
|
// calculate velocities
|
|
|
|
|
calc_velocities(false); |
|
|
|
|
init_start_angle(false); |
|
|
|
|
======= |
|
|
|
|
target.y = _center.y + _radius * sinf(_angle); |
|
|
|
|
if(fabs(last_bearing_rad - bearing_rad) < 0.01 && _fabs_total > 0.9){ |
|
|
|
|
_center.x = stopping_point.x + _radius * cosf(_ahrs.yaw - M_PI_2); |
|
|
|
@ -228,7 +193,6 @@ bool AC_Circle::turn_2_circle()
@@ -228,7 +193,6 @@ bool AC_Circle::turn_2_circle()
|
|
|
|
|
_angle = wrap_PI(-_ahrs.yaw - M_PI_2 ); // 逆时针绕与yaw反向,-pi/2提前1/4圈
|
|
|
|
|
target.x = _center.x + _radius * cosf(_angle); |
|
|
|
|
target.y = _center.y - _radius * sinf(_angle); |
|
|
|
|
>>>>>>> 098f02907d... 增加绕8字功能,一键8字,航线起飞和返航8字 |
|
|
|
|
_angle_total = 0; |
|
|
|
|
stage = 2; |
|
|
|
|
} |
|
|
|
|