|
|
@ -609,29 +609,39 @@ MulticopterPositionControl::task_main() |
|
|
|
/* AUTO */ |
|
|
|
/* AUTO */ |
|
|
|
if (_mission_items.current_valid) { |
|
|
|
if (_mission_items.current_valid) { |
|
|
|
struct mission_item_s item = _mission_items.current; |
|
|
|
struct mission_item_s item = _mission_items.current; |
|
|
|
map_projection_project(item.lat, item.lon, &_pos_sp(0), &_pos_sp(1)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO home altitude can be != ref_alt, check home_position topic
|
|
|
|
if (item.nav_cmd == NAV_CMD_TAKEOFF) { |
|
|
|
_pos_sp(2) = -(item.altitude_is_relative ? item.altitude : item.altitude - ref_alt); |
|
|
|
/* use current position setpoint or current position */ |
|
|
|
|
|
|
|
if (reset_sp_xy) { |
|
|
|
|
|
|
|
reset_sp_xy = false; |
|
|
|
|
|
|
|
_pos_sp(0) = _pos(0); |
|
|
|
|
|
|
|
_pos_sp(1) = _pos(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (_mission_items.current.nav_cmd == NAV_CMD_TAKEOFF) { |
|
|
|
|
|
|
|
/* add gap for takeoff setpoint */ |
|
|
|
/* add gap for takeoff setpoint */ |
|
|
|
_pos_sp(2) -= 0.5f * _params.vel_max(2) / _params.pos_p(2); |
|
|
|
_pos_sp(2) -= 0.5f * _params.vel_max(2) / _params.pos_p(2); |
|
|
|
} |
|
|
|
reset_sp_z = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
map_projection_project(item.lat, item.lon, &_pos_sp(0), &_pos_sp(1)); |
|
|
|
|
|
|
|
|
|
|
|
_att_sp.yaw_body = _mission_items.current.yaw; |
|
|
|
// TODO home altitude can be != ref_alt, check home_position topic
|
|
|
|
|
|
|
|
_pos_sp(2) = -(item.altitude_is_relative ? item.altitude : item.altitude - ref_alt); |
|
|
|
|
|
|
|
|
|
|
|
/* in case of interrupted mission don't go to waypoint but stay at current position */ |
|
|
|
_att_sp.yaw_body = _mission_items.current.yaw; |
|
|
|
reset_sp_xy = true; |
|
|
|
|
|
|
|
reset_sp_z = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* in case of interrupted mission don't go to waypoint but stay at current position */ |
|
|
|
|
|
|
|
reset_sp_xy = true; |
|
|
|
|
|
|
|
reset_sp_z = true; |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
/* no waypoint, loiter, reset position setpoint if needed */ |
|
|
|
/* no waypoint, loiter, reset position setpoint if needed */ |
|
|
|
if (reset_sp_xy) { |
|
|
|
if (reset_sp_xy) { |
|
|
|
|
|
|
|
reset_sp_xy = false; |
|
|
|
_pos_sp(0) = _pos(0); |
|
|
|
_pos_sp(0) = _pos(0); |
|
|
|
_pos_sp(1) = _pos(1); |
|
|
|
_pos_sp(1) = _pos(1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (reset_sp_z) { |
|
|
|
if (reset_sp_z) { |
|
|
|
|
|
|
|
reset_sp_z = false; |
|
|
|
_pos_sp(2) = _pos(2); |
|
|
|
_pos_sp(2) = _pos(2); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|