|
|
|
@ -162,6 +162,8 @@ bool FlightTaskOrbit::activate(const vehicle_local_position_setpoint_s &last_set
@@ -162,6 +162,8 @@ bool FlightTaskOrbit::activate(const vehicle_local_position_setpoint_s &last_set
|
|
|
|
|
_center = Vector2f(_position); |
|
|
|
|
_center(0) -= _r; |
|
|
|
|
_initial_heading = _yaw; |
|
|
|
|
_slew_rate_yaw.setForcedValue(_yaw); |
|
|
|
|
_slew_rate_yaw.setSlewRate(math::radians(_param_mpc_yawrauto_max.get())); |
|
|
|
|
|
|
|
|
|
// need a valid position and velocity
|
|
|
|
|
ret = ret && PX4_ISFINITE(_position(0)) |
|
|
|
@ -196,6 +198,9 @@ bool FlightTaskOrbit::update()
@@ -196,6 +198,9 @@ bool FlightTaskOrbit::update()
|
|
|
|
|
generate_circle_yaw_setpoints(center_to_position); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Apply yaw smoothing
|
|
|
|
|
_yaw_setpoint = _slew_rate_yaw.update(_yaw_setpoint, _deltatime); |
|
|
|
|
|
|
|
|
|
// publish information to UI
|
|
|
|
|
sendTelemetry(); |
|
|
|
|
|
|
|
|
@ -204,16 +209,18 @@ bool FlightTaskOrbit::update()
@@ -204,16 +209,18 @@ bool FlightTaskOrbit::update()
|
|
|
|
|
|
|
|
|
|
void FlightTaskOrbit::generate_circle_approach_setpoints(const Vector2f ¢er_to_position) |
|
|
|
|
{ |
|
|
|
|
const Vector2f start_to_circle = (_r - center_to_position.norm()) * center_to_position.unit_or_zero(); |
|
|
|
|
|
|
|
|
|
if (_circle_approach_line.isEndReached()) { |
|
|
|
|
// calculate target point on circle and plan a line trajectory
|
|
|
|
|
const Vector2f start_to_circle = (_r - center_to_position.norm()) * center_to_position.unit_or_zero(); |
|
|
|
|
const Vector2f closest_circle_point = Vector2f(_position) + start_to_circle; |
|
|
|
|
const Vector3f target = Vector3f(closest_circle_point(0), closest_circle_point(1), _position(2)); |
|
|
|
|
_circle_approach_line.setLineFromTo(_position, target); |
|
|
|
|
_circle_approach_line.setSpeed(_param_mpc_xy_cruise.get()); |
|
|
|
|
_yaw_setpoint = atan2f(start_to_circle(1), start_to_circle(0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_yaw_setpoint = atan2f(start_to_circle(1), start_to_circle(0)); |
|
|
|
|
|
|
|
|
|
// follow the planned line and switch to orbiting once the circle is reached
|
|
|
|
|
_circle_approach_line.generateSetpoints(_position_setpoint, _velocity_setpoint); |
|
|
|
|
_in_circle_approach = !_circle_approach_line.isEndReached(); |
|
|
|
|