|
|
|
@ -365,6 +365,50 @@ void AC_Circle::update()
@@ -365,6 +365,50 @@ void AC_Circle::update()
|
|
|
|
|
_pos_control.update_xy_controller(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// update - update circle controller
|
|
|
|
|
void AC_Circle::turn_yaw(const Vector3f& center) |
|
|
|
|
{ |
|
|
|
|
// calculate dt
|
|
|
|
|
float dt = _pos_control.time_since_last_xy_update(); |
|
|
|
|
if (dt >= 0.2f) { |
|
|
|
|
dt = 0.0f; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ramp angular velocity to maximum
|
|
|
|
|
if (_angular_vel < _angular_vel_max) { |
|
|
|
|
_angular_vel += fabsf(_angular_accel) * dt; |
|
|
|
|
_angular_vel = MIN(_angular_vel, _angular_vel_max); |
|
|
|
|
} |
|
|
|
|
if (_angular_vel > _angular_vel_max) { |
|
|
|
|
_angular_vel -= fabsf(_angular_accel) * dt; |
|
|
|
|
_angular_vel = MAX(_angular_vel, _angular_vel_max); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// update the target angle and total angle traveled
|
|
|
|
|
float angle_change = _angular_vel * dt; |
|
|
|
|
_angle += angle_change; |
|
|
|
|
_angle = wrap_PI(_angle); |
|
|
|
|
_angle_total += angle_change; |
|
|
|
|
|
|
|
|
|
// set target position to center
|
|
|
|
|
Vector3f target; |
|
|
|
|
target.x = center.x; |
|
|
|
|
target.y = center.y; |
|
|
|
|
target.z = _pos_control.get_alt_target(); |
|
|
|
|
|
|
|
|
|
// update position controller target
|
|
|
|
|
_pos_control.set_xy_target(target.x, target.y); |
|
|
|
|
|
|
|
|
|
// heading is same as _angle but converted to centi-degrees
|
|
|
|
|
_yaw = _angle * DEGX100; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// update position controller
|
|
|
|
|
_pos_control.update_xy_controller(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get_closest_point_on_circle - returns closest point on the circle
|
|
|
|
|
// circle's center should already have been set
|
|
|
|
|
// closest point on the circle will be placed in result
|
|
|
|
|