mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-20 03:13:44 +08:00
navigator: don't takeoff in loiter on ground
This fixes the following corner case: 1. Upload a mission. 2. Set mission mode. 3. Set loiter mode. 4. Arm. At this point it will shoot up and go to the takeoff waypoint even though we're not in mission but in loiter mode. The fix makes sure that the triplet is reset to invalid (and idle) in loiter mode if we're landed and disarmed. It will lead to the vehcle sit in idle on the ground until you issue a start mission (or takeoff) command.
This commit is contained in:
@@ -102,15 +102,25 @@ Loiter::on_active()
|
||||
void
|
||||
Loiter::set_loiter_position()
|
||||
{
|
||||
// not setting loiter position until armed
|
||||
if (_navigator->get_vstatus()->arming_state != vehicle_status_s::ARMING_STATE_ARMED ||
|
||||
_loiter_pos_set) {
|
||||
if (_navigator->get_vstatus()->arming_state != vehicle_status_s::ARMING_STATE_ARMED &&
|
||||
_navigator->get_land_detected()->landed) {
|
||||
|
||||
// Not setting loiter position if disarmed and landed, instead mark the current
|
||||
// setpoint as invalid and idle (both, just to be sure).
|
||||
|
||||
_navigator->set_can_loiter_at_sp(false);
|
||||
_navigator->get_position_setpoint_triplet()->current.type = position_setpoint_s::SETPOINT_TYPE_IDLE;
|
||||
_navigator->set_position_setpoint_triplet_updated();
|
||||
_loiter_pos_set = false;
|
||||
return;
|
||||
|
||||
} else {
|
||||
_loiter_pos_set = true;
|
||||
} else if (_loiter_pos_set) {
|
||||
// Already set, nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
_loiter_pos_set = true;
|
||||
|
||||
// set current mission item to loiter
|
||||
set_loiter_item(&_mission_item, _param_min_alt.get());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user