mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-28 02:50:36 +08:00
fix(navigator): honor yaw in LAND and VTOL_LAND (#28764)
* fix(navigator): honor yaw in LAND and VTOL_LAND * fix(navigator): accept any altitude for ALIGN_TO_LAND work item mc_landing_after_transition (#24115) widens the altitude acceptance radius to FLT_MAX for WORK_ITEM_TYPE_MOVE_TO_LAND, since a VTOL back-transitioning to MC may be well above the landing altitude. The new WORK_ITEM_TYPE_ALIGN_TO_LAND work item has the same issue: a low VTOL climbs back to its current altitude to align heading before descending to land, so it needs the same unrestricted altitude acceptance or it can get stuck trying to exactly hit an altitude it isn't at. * fix(navigator): skip ROI yaw override during ALIGN_TO_LAND on_active() overrides the mission item's yaw toward the active ROI for rotary wing vehicles, excluding takeoff, VTOL transition, landing, and WORK_ITEM_TYPE_ALIGN_HEADING. WORK_ITEM_TYPE_ALIGN_TO_LAND runs with nav_cmd temporarily set to NAV_CMD_WAYPOINT, so none of those exclusions match it, and the ROI override stomps the mission-commanded landing heading before the vehicle starts descending. Exclude WORK_ITEM_TYPE_ALIGN_TO_LAND the same way WORK_ITEM_TYPE_ALIGN_HEADING already is. * test(navigator) honoring yaw during landing * fix(navigator): specifiy land_precision in handleLanding * fix(test): add RTL Align landing tests in seperate binary * docs(weathervane): weathervane is disable when yaw item is set * tests(navigator): bring RTL tests back into 1 file * refactor(navigator): remove unused setting of yaw of next waypoint --------- Signed-off-by: henrykotze <henry.kotze1996@gmail.com>
This commit is contained in:
1 parent
22b15b91fb
commit
ae4fd97df8
7 files changed
+332
-13
No files matched your search
@@ -18,8 +18,8 @@ The target yaw rate is the sum of weather vane yaw rate and user commanded yaw r
|
||||
|
||||
## Mission Mode Behaviour
|
||||
|
||||
In [Mission mode](../flight_modes_vtol/mission.md) the weather vane feature will always be active when the parameter is enabled.
|
||||
Any yaw angle commanded in a mission will be ignored.
|
||||
In [Mission mode](../flight_modes_vtol/mission.md) the weather vane feature is active (when enabled) for any mission item that does not command a yaw angle.
|
||||
If a mission item commands a yaw angle, the weather vane feature is disabled for that item and the commanded yaw is used instead.
|
||||
|
||||
<a id="configuration"></a>
|
||||
|
||||
|
||||
@@ -238,7 +238,8 @@ void Mission::setActiveMissionItems()
|
||||
_mission_item.nav_cmd == NAV_CMD_WAYPOINT;
|
||||
const bool mc_landing_after_transition = _vehicle_status_sub.get().vehicle_type ==
|
||||
vehicle_status_s::VEHICLE_TYPE_ROTARY_WING && _vehicle_status_sub.get().is_vtol &&
|
||||
new_work_item_type == WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND;
|
||||
(new_work_item_type == WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND ||
|
||||
new_work_item_type == WorkItemType::WORK_ITEM_TYPE_ALIGN_TO_LAND);
|
||||
|
||||
if (fw_on_mission_landing || mc_landing_after_transition) {
|
||||
pos_sp_triplet->current.alt_acceptance_radius = FLT_MAX;
|
||||
@@ -295,6 +296,7 @@ void Mission::setActiveMissionItems()
|
||||
|
||||
// Only set the previous position item if the current one really changed
|
||||
if ((_work_item_type != WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND) &&
|
||||
(_work_item_type != WorkItemType::WORK_ITEM_TYPE_ALIGN_TO_LAND) &&
|
||||
!position_setpoint_equal(&pos_sp_triplet->current, ¤t_setpoint_copy)) {
|
||||
pos_sp_triplet->previous = current_setpoint_copy;
|
||||
}
|
||||
|
||||
@@ -341,6 +341,7 @@ MissionBase::on_active()
|
||||
|| _mission_item.nav_cmd == NAV_CMD_DO_VTOL_TRANSITION
|
||||
|| _mission_item.nav_cmd == NAV_CMD_LAND
|
||||
|| _mission_item.nav_cmd == NAV_CMD_VTOL_LAND
|
||||
|| _work_item_type == WorkItemType::WORK_ITEM_TYPE_ALIGN_TO_LAND
|
||||
|| _work_item_type == WorkItemType::WORK_ITEM_TYPE_ALIGN_HEADING)) {
|
||||
// Mount control is disabled If the vehicle is in ROI-mode, the vehicle
|
||||
// needs to rotate such that ROI is in the field of view.
|
||||
@@ -624,13 +625,6 @@ void MissionBase::handleLanding(WorkItemType &new_work_item_type, mission_item_s
|
||||
(_mission_item.nav_cmd == NAV_CMD_VTOL_LAND) &&
|
||||
!_land_detected_sub.get().landed;
|
||||
|
||||
/* ignore yaw for landing items */
|
||||
/* XXX: if specified heading for landing is desired we could add another step before the descent
|
||||
* that aligns the vehicle first */
|
||||
if (_mission_item.nav_cmd == NAV_CMD_LAND || _mission_item.nav_cmd == NAV_CMD_VTOL_LAND) {
|
||||
_mission_item.yaw = NAN;
|
||||
}
|
||||
|
||||
/* move to land wp as fixed wing */
|
||||
if (needs_vtol_landing) {
|
||||
if (_work_item_type == WorkItemType::WORK_ITEM_TYPE_DEFAULT) {
|
||||
@@ -653,6 +647,7 @@ void MissionBase::handleLanding(WorkItemType &new_work_item_type, mission_item_s
|
||||
_mission_item.autocontinue = true;
|
||||
_mission_item.time_inside = 0.0f;
|
||||
_mission_item.vtol_back_transition = true;
|
||||
_mission_item.yaw = NAN;
|
||||
|
||||
_navigator->reset_position_setpoint(pos_sp_triplet->previous);
|
||||
}
|
||||
@@ -676,7 +671,7 @@ void MissionBase::handleLanding(WorkItemType &new_work_item_type, mission_item_s
|
||||
|
||||
/* use current mission item as next position item */
|
||||
num_found_items = 1u;
|
||||
next_mission_items[0u] = _mission_item;
|
||||
next_mission_items[0u] = _mission_item; // contains NAV_CMD_LAND
|
||||
|
||||
/*
|
||||
* Ignoring waypoint altitude:
|
||||
@@ -692,6 +687,41 @@ void MissionBase::handleLanding(WorkItemType &new_work_item_type, mission_item_s
|
||||
altitude = pos_sp_triplet->current.alt;
|
||||
}
|
||||
|
||||
_mission_item.altitude = altitude;
|
||||
_mission_item.altitude_is_relative = false;
|
||||
_mission_item.nav_cmd = NAV_CMD_WAYPOINT;
|
||||
_mission_item.autocontinue = true;
|
||||
_mission_item.yaw = NAN;
|
||||
|
||||
// have to reset here because these field were used in set_vtol_transition_item
|
||||
_mission_item.time_inside = 0.f;
|
||||
_mission_item.acceptance_radius = _navigator->get_acceptance_radius();
|
||||
|
||||
// make previous setpoint invalid, such that there will be no prev-current line following.
|
||||
// if the vehicle drifted off the path during back-transition it should just go straight to the landing point
|
||||
_navigator->reset_position_setpoint(pos_sp_triplet->previous);
|
||||
|
||||
_navigator->activate_set_gimbal_neutral_timer(hrt_absolute_time());
|
||||
|
||||
} else if ((_vehicle_status_sub.get().vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) &&
|
||||
!do_need_move_to_item() &&
|
||||
PX4_ISFINITE(_mission_item.yaw) && (_mission_item.land_precision == 0) &&
|
||||
(_work_item_type == WorkItemType::WORK_ITEM_TYPE_DEFAULT ||
|
||||
_work_item_type == WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND ||
|
||||
_work_item_type == WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND_AFTER_TRANSITION)) {
|
||||
|
||||
float altitude = _global_pos_sub.get().alt;
|
||||
|
||||
if (pos_sp_triplet->current.valid
|
||||
&& pos_sp_triplet->current.type == position_setpoint_s::SETPOINT_TYPE_POSITION) {
|
||||
altitude = pos_sp_triplet->current.alt;
|
||||
}
|
||||
|
||||
new_work_item_type = WorkItemType::WORK_ITEM_TYPE_ALIGN_TO_LAND;
|
||||
|
||||
num_found_items = 1u;
|
||||
next_mission_items[0u] = _mission_item; // contains NAV_CMD_LAND
|
||||
|
||||
_mission_item.altitude = altitude;
|
||||
_mission_item.altitude_is_relative = false;
|
||||
_mission_item.nav_cmd = NAV_CMD_WAYPOINT;
|
||||
|
||||
@@ -88,6 +88,7 @@ protected:
|
||||
WORK_ITEM_TYPE_DEFAULT, /**< default mission item */
|
||||
WORK_ITEM_TYPE_CLIMB, /**< takeoff before moving to waypoint */
|
||||
WORK_ITEM_TYPE_MOVE_TO_LAND, /**< move to land waypoint before descent */
|
||||
WORK_ITEM_TYPE_ALIGN_TO_LAND,
|
||||
WORK_ITEM_TYPE_ALIGN_HEADING, /**< align for next waypoint */
|
||||
WORK_ITEM_TYPE_TRANSITION_AFTER_TAKEOFF,
|
||||
WORK_ITEM_TYPE_MOVE_TO_LAND_AFTER_TRANSITION,
|
||||
|
||||
@@ -292,6 +292,7 @@ void RtlDirectMissionLand::setActiveMissionItems()
|
||||
|
||||
// Only set the previous position item if the current one really changed
|
||||
if ((_work_item_type != WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND) &&
|
||||
(_work_item_type != WorkItemType::WORK_ITEM_TYPE_ALIGN_TO_LAND) &&
|
||||
!position_setpoint_equal(&pos_sp_triplet->current, ¤t_setpoint_copy)) {
|
||||
pos_sp_triplet->previous = current_setpoint_copy;
|
||||
}
|
||||
@@ -303,7 +304,8 @@ void RtlDirectMissionLand::setActiveMissionItems()
|
||||
_mission_item.nav_cmd == NAV_CMD_WAYPOINT;
|
||||
const bool mc_landing_after_transition = _vehicle_status_sub.get().vehicle_type ==
|
||||
vehicle_status_s::VEHICLE_TYPE_ROTARY_WING && _vehicle_status_sub.get().is_vtol &&
|
||||
new_work_item_type == WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND;
|
||||
(new_work_item_type == WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND ||
|
||||
new_work_item_type == WorkItemType::WORK_ITEM_TYPE_ALIGN_TO_LAND);
|
||||
|
||||
if (fw_on_mission_landing || mc_landing_after_transition) {
|
||||
pos_sp_triplet->current.alt_acceptance_radius = FLT_MAX;
|
||||
|
||||
@@ -181,6 +181,7 @@ void RtlMissionFast::setActiveMissionItems()
|
||||
|
||||
// Only set the previous position item if the current one really changed
|
||||
if ((_work_item_type != WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND) &&
|
||||
(_work_item_type != WorkItemType::WORK_ITEM_TYPE_ALIGN_TO_LAND) &&
|
||||
!position_setpoint_equal(&pos_sp_triplet->current, ¤t_setpoint_copy)) {
|
||||
pos_sp_triplet->previous = current_setpoint_copy;
|
||||
}
|
||||
@@ -190,7 +191,8 @@ void RtlMissionFast::setActiveMissionItems()
|
||||
_mission_item.nav_cmd == NAV_CMD_WAYPOINT;
|
||||
const bool mc_landing_after_transition = _vehicle_status_sub.get().vehicle_type ==
|
||||
vehicle_status_s::VEHICLE_TYPE_ROTARY_WING && _vehicle_status_sub.get().is_vtol &&
|
||||
new_work_item_type == WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND;
|
||||
(new_work_item_type == WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND ||
|
||||
new_work_item_type == WorkItemType::WORK_ITEM_TYPE_ALIGN_TO_LAND);
|
||||
|
||||
if (fw_on_mission_landing || mc_landing_after_transition) {
|
||||
pos_sp_triplet->current.alt_acceptance_radius = FLT_MAX;
|
||||
|
||||
@@ -248,6 +248,12 @@ public:
|
||||
const mission_item_s &activeItem() const { return this->_mission_item; }
|
||||
bool activeItemValid() const { return this->_is_current_planned_mission_item_valid; }
|
||||
|
||||
float activeYaw() const { return this->_mission_item.yaw; }
|
||||
|
||||
using WorkItemType = typename RtlMissionType::WorkItemType;
|
||||
|
||||
WorkItemType activeWorkItemType() const { return this->_work_item_type; }
|
||||
|
||||
protected:
|
||||
bool loadMissionItemFromCache(int32_t index, mission_item_s &mission_item) override
|
||||
{
|
||||
@@ -674,6 +680,282 @@ INSTANTIATE_TEST_SUITE_P(VehicleTypes, RTLClimbUpdateTest,
|
||||
::testing::Values(vehicle_status_s::VEHICLE_TYPE_ROTARY_WING,
|
||||
vehicle_status_s::VEHICLE_TYPE_FIXED_WING)));
|
||||
|
||||
// WHY: A VTOL landing with finite yaw, must rotate before proceeding with its landing, however it must
|
||||
// also widend its acceptance heights for the landing waypoint to account for the back-transition
|
||||
// WHAT: A VTOL_LAND item with a finite yaw is driven through MOVE_TO_LAND, the back-transition,
|
||||
// ALIGN_TO_LAND, and back to VTOL_LAND.
|
||||
TEST_F(RTLTest, DirectMissionLandAlignsToCommandedYawBeforeDescending)
|
||||
{
|
||||
using WorkItemType = RtlDirectMissionLandTestPeer::WorkItemType;
|
||||
constexpr float kLandYaw = 1.2f;
|
||||
|
||||
mission_s mission{};
|
||||
mission.timestamp = hrt_absolute_time();
|
||||
mission.current_seq = 0;
|
||||
mission.count = 1;
|
||||
mission.land_start_index = 0;
|
||||
mission.land_index = 0;
|
||||
mission.mission_dataman_id = DM_KEY_WAYPOINTS_OFFBOARD_1;
|
||||
|
||||
mission_item_s land = makeSafePointItem(kBaseLat, kBaseLon, kAlt, NAV_FRAME_GLOBAL, NAV_CMD_VTOL_LAND);
|
||||
land.autocontinue = true;
|
||||
land.yaw = kLandYaw;
|
||||
|
||||
// GIVEN: A VTOL approaching its land point as a fixed wing, with a commanded landing yaw.
|
||||
// Publish the mission itself too: unlike a single activation check, this test calls
|
||||
// on_active() repeatedly, and MissionBase::updateMavlinkMission() reads the real `mission`
|
||||
// topic there. Without this, a fresh Subscription's first update() picks up whatever another
|
||||
// test last left on that (process-wide) topic and clobbers _mission with unrelated data.
|
||||
publishMission(mission);
|
||||
publishVehicleStatus(true, vehicle_status_s::VEHICLE_TYPE_FIXED_WING);
|
||||
publishGlobalPosition(kBaseLat, kBaseLon, kAlt);
|
||||
publishLandDetected(false);
|
||||
_navigator.get_mission_result()->valid = true;
|
||||
|
||||
// is_mission_item_reached_or_completed() reads the navigator's own cached vehicle state
|
||||
// rather than MissionBase's subscriptions, so both must be kept in sync by the test.
|
||||
_navigator.get_global_position()->lat = kBaseLat;
|
||||
_navigator.get_global_position()->lon = kBaseLon;
|
||||
_navigator.get_global_position()->alt = kAlt;
|
||||
_navigator.get_global_position()->timestamp = hrt_absolute_time();
|
||||
_navigator.get_land_detected()->landed = false;
|
||||
_navigator.get_vstatus()->vehicle_type = vehicle_status_s::VEHICLE_TYPE_FIXED_WING;
|
||||
_navigator.get_vstatus()->is_vtol = true;
|
||||
_navigator.get_vstatus()->in_transition_mode = false;
|
||||
|
||||
RtlDirectMissionLandTestPeer direct_mission_land{&_navigator, mission};
|
||||
direct_mission_land.loadTestMission({land});
|
||||
direct_mission_land.setRtlAlt(kAlt);
|
||||
|
||||
// WHEN: The mission activates.
|
||||
direct_mission_land.activateForTest();
|
||||
|
||||
// THEN: It moves to the land waypoint first as a fixed wing, with yaw ignored.
|
||||
ASSERT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND);
|
||||
EXPECT_EQ(direct_mission_land.activeNavCommand(), NAV_CMD_WAYPOINT);
|
||||
EXPECT_TRUE(std::isnan(direct_mission_land.activeYaw()));
|
||||
|
||||
// WHEN: The vehicle reaches the land point and requests the back-transition to multicopter.
|
||||
direct_mission_land.on_active();
|
||||
|
||||
ASSERT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND_AFTER_TRANSITION);
|
||||
EXPECT_EQ(direct_mission_land.activeNavCommand(), NAV_CMD_DO_VTOL_TRANSITION);
|
||||
|
||||
// WHEN: The back-transition completes.
|
||||
publishVehicleStatus(true, vehicle_status_s::VEHICLE_TYPE_ROTARY_WING);
|
||||
_navigator.get_vstatus()->vehicle_type = vehicle_status_s::VEHICLE_TYPE_ROTARY_WING;
|
||||
_navigator.get_vstatus()->is_vtol = true;
|
||||
_navigator.get_vstatus()->in_transition_mode = false;
|
||||
direct_mission_land.on_active();
|
||||
|
||||
// THEN: It aligns to the commanded landing yaw before descending, holding the current
|
||||
// altitude, and widens the altitude acceptance radius the same way MOVE_TO_LAND does.
|
||||
ASSERT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_ALIGN_TO_LAND);
|
||||
EXPECT_EQ(direct_mission_land.activeNavCommand(), NAV_CMD_WAYPOINT);
|
||||
EXPECT_FLOAT_EQ(direct_mission_land.activeYaw(), kLandYaw);
|
||||
EXPECT_FLOAT_EQ(_navigator.get_position_setpoint_triplet()->current.alt_acceptance_radius, FLT_MAX);
|
||||
|
||||
// WHEN: The vehicle finishes rotating to the commanded landing yaw.
|
||||
_navigator.get_local_position()->heading = kLandYaw;
|
||||
_navigator.get_local_position()->heading_good_for_control = true;
|
||||
direct_mission_land.on_active();
|
||||
|
||||
// THEN: It falls through to the real landing item with the commanded yaw intact.
|
||||
EXPECT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_DEFAULT);
|
||||
EXPECT_EQ(direct_mission_land.activeNavCommand(), NAV_CMD_VTOL_LAND);
|
||||
EXPECT_FLOAT_EQ(direct_mission_land.activeYaw(), kLandYaw);
|
||||
}
|
||||
|
||||
// WHY: With no commanded landing yaw there is nothing to align to, so the mission must
|
||||
// go straight from the back-transition to the real landing item, never stopping to rotate.
|
||||
// WHAT: A VTOL_LAND item with yaw = NaN skips ALIGN_TO_LAND entirely.
|
||||
TEST_F(RTLTest, DirectMissionLandSkipsAlignWhenYawNotCommanded)
|
||||
{
|
||||
using WorkItemType = RtlDirectMissionLandTestPeer::WorkItemType;
|
||||
|
||||
mission_s mission{};
|
||||
mission.timestamp = hrt_absolute_time();
|
||||
mission.current_seq = 0;
|
||||
mission.count = 1;
|
||||
mission.land_start_index = 0;
|
||||
mission.land_index = 0;
|
||||
mission.mission_dataman_id = DM_KEY_WAYPOINTS_OFFBOARD_1;
|
||||
|
||||
mission_item_s land = makeSafePointItem(kBaseLat, kBaseLon, kAlt, NAV_FRAME_GLOBAL, NAV_CMD_VTOL_LAND);
|
||||
land.autocontinue = true;
|
||||
land.yaw = NAN;
|
||||
|
||||
// GIVEN: A VTOL approaching its land point as a fixed wing, with no commanded landing yaw.
|
||||
publishMission(mission);
|
||||
publishVehicleStatus(true, vehicle_status_s::VEHICLE_TYPE_FIXED_WING);
|
||||
publishGlobalPosition(kBaseLat, kBaseLon, kAlt);
|
||||
publishLandDetected(false);
|
||||
_navigator.get_mission_result()->valid = true;
|
||||
|
||||
_navigator.get_global_position()->lat = kBaseLat;
|
||||
_navigator.get_global_position()->lon = kBaseLon;
|
||||
_navigator.get_global_position()->alt = kAlt;
|
||||
_navigator.get_global_position()->timestamp = hrt_absolute_time();
|
||||
_navigator.get_land_detected()->landed = false;
|
||||
_navigator.get_vstatus()->vehicle_type = vehicle_status_s::VEHICLE_TYPE_FIXED_WING;
|
||||
_navigator.get_vstatus()->is_vtol = true;
|
||||
_navigator.get_vstatus()->in_transition_mode = false;
|
||||
|
||||
RtlDirectMissionLandTestPeer direct_mission_land{&_navigator, mission};
|
||||
direct_mission_land.loadTestMission({land});
|
||||
direct_mission_land.setRtlAlt(kAlt);
|
||||
|
||||
// WHEN: The mission activates and the vehicle reaches the land point to request the
|
||||
// back-transition, exactly as in the commanded-yaw case.
|
||||
direct_mission_land.activateForTest();
|
||||
ASSERT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND);
|
||||
|
||||
direct_mission_land.on_active();
|
||||
ASSERT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND_AFTER_TRANSITION);
|
||||
EXPECT_EQ(direct_mission_land.activeNavCommand(), NAV_CMD_DO_VTOL_TRANSITION);
|
||||
|
||||
// WHEN: The back-transition completes.
|
||||
publishVehicleStatus(true, vehicle_status_s::VEHICLE_TYPE_ROTARY_WING);
|
||||
_navigator.get_vstatus()->vehicle_type = vehicle_status_s::VEHICLE_TYPE_ROTARY_WING;
|
||||
_navigator.get_vstatus()->is_vtol = true;
|
||||
_navigator.get_vstatus()->in_transition_mode = false;
|
||||
direct_mission_land.on_active();
|
||||
|
||||
// THEN: With no yaw to align to, it lands directly -- no ALIGN_TO_LAND stop in between.
|
||||
EXPECT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_DEFAULT);
|
||||
EXPECT_EQ(direct_mission_land.activeNavCommand(), NAV_CMD_VTOL_LAND);
|
||||
EXPECT_TRUE(std::isnan(direct_mission_land.activeYaw()));
|
||||
}
|
||||
|
||||
// WHY: for a pure multicopter, if a mission item defines the yaw setpoint, the multicopter should
|
||||
// rotate to the commanded yaw, before descending
|
||||
// WHAT: A LAND item with a finite yaw is driven through MOVE_TO_LAND and ALIGN_TO_LAND to LAND
|
||||
// for a pure multicopter, with no back-transition step in between.
|
||||
TEST_F(RTLTest, DirectMissionLandMcOnlyAlignsToCommandedYawBeforeDescending)
|
||||
{
|
||||
using WorkItemType = RtlDirectMissionLandTestPeer::WorkItemType;
|
||||
constexpr float kLandYaw = -0.7f;
|
||||
|
||||
mission_s mission{};
|
||||
mission.timestamp = hrt_absolute_time();
|
||||
mission.current_seq = 0;
|
||||
mission.count = 1;
|
||||
mission.land_start_index = 0;
|
||||
mission.land_index = 0;
|
||||
mission.mission_dataman_id = DM_KEY_WAYPOINTS_OFFBOARD_1;
|
||||
|
||||
mission_item_s land = makeSafePointItem(kBaseLat, kBaseLon, kAlt, NAV_FRAME_GLOBAL, NAV_CMD_LAND);
|
||||
land.autocontinue = true;
|
||||
land.yaw = kLandYaw;
|
||||
|
||||
// GIVEN: A pure multicopter (never VTOL) starting 100 m from the land point.
|
||||
const PositionYawSetpoint far_position = makePositionYawSetpointFromOffset(kBaseLat, kBaseLon, 100.f, 0.f, kAlt);
|
||||
|
||||
publishMission(mission);
|
||||
publishVehicleStatus(false, vehicle_status_s::VEHICLE_TYPE_ROTARY_WING);
|
||||
publishGlobalPosition(far_position.lat, far_position.lon, kAlt);
|
||||
publishLandDetected(false);
|
||||
_navigator.get_mission_result()->valid = true;
|
||||
|
||||
_navigator.get_global_position()->lat = far_position.lat;
|
||||
_navigator.get_global_position()->lon = far_position.lon;
|
||||
_navigator.get_global_position()->alt = kAlt;
|
||||
_navigator.get_global_position()->timestamp = hrt_absolute_time();
|
||||
_navigator.get_land_detected()->landed = false;
|
||||
_navigator.get_vstatus()->vehicle_type = vehicle_status_s::VEHICLE_TYPE_ROTARY_WING;
|
||||
_navigator.get_vstatus()->is_vtol = false;
|
||||
|
||||
RtlDirectMissionLandTestPeer direct_mission_land{&_navigator, mission};
|
||||
direct_mission_land.loadTestMission({land});
|
||||
direct_mission_land.setRtlAlt(kAlt);
|
||||
|
||||
// WHEN: The mission activates while the vehicle is still far from the land point.
|
||||
direct_mission_land.activateForTest();
|
||||
|
||||
// THEN: It moves to the land waypoint first (too far away), with yaw ignored.
|
||||
ASSERT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND);
|
||||
EXPECT_EQ(direct_mission_land.activeNavCommand(), NAV_CMD_WAYPOINT);
|
||||
EXPECT_TRUE(std::isnan(direct_mission_land.activeYaw()));
|
||||
|
||||
// WHEN: The vehicle arrives at the land point.
|
||||
publishGlobalPosition(kBaseLat, kBaseLon, kAlt);
|
||||
_navigator.get_global_position()->lat = kBaseLat;
|
||||
_navigator.get_global_position()->lon = kBaseLon;
|
||||
direct_mission_land.on_active();
|
||||
|
||||
// THEN: With no VTOL back-transition to wait for, it goes straight from MOVE_TO_LAND to
|
||||
// aligning on the commanded landing yaw while holding the current altitude.
|
||||
ASSERT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_ALIGN_TO_LAND);
|
||||
EXPECT_EQ(direct_mission_land.activeNavCommand(), NAV_CMD_WAYPOINT);
|
||||
EXPECT_FLOAT_EQ(direct_mission_land.activeYaw(), kLandYaw);
|
||||
|
||||
// WHEN: The vehicle finishes rotating to the commanded landing yaw.
|
||||
_navigator.get_local_position()->heading = kLandYaw;
|
||||
_navigator.get_local_position()->heading_good_for_control = true;
|
||||
direct_mission_land.on_active();
|
||||
|
||||
// THEN: It falls through to the real landing item with the commanded yaw intact.
|
||||
EXPECT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_DEFAULT);
|
||||
EXPECT_EQ(direct_mission_land.activeNavCommand(), NAV_CMD_LAND);
|
||||
EXPECT_FLOAT_EQ(direct_mission_land.activeYaw(), kLandYaw);
|
||||
}
|
||||
|
||||
// WHY: for a pure multicopter: no commanded yaw means no ALIGN_TO_LAND stop.
|
||||
// WHAT: A LAND item with yaw = NaN skips ALIGN_TO_LAND and lands directly after MOVE_TO_LAND.
|
||||
TEST_F(RTLTest, DirectMissionLandMcOnlySkipsAlignWhenYawNotCommanded)
|
||||
{
|
||||
using WorkItemType = RtlDirectMissionLandTestPeer::WorkItemType;
|
||||
|
||||
mission_s mission{};
|
||||
mission.timestamp = hrt_absolute_time();
|
||||
mission.current_seq = 0;
|
||||
mission.count = 1;
|
||||
mission.land_start_index = 0;
|
||||
mission.land_index = 0;
|
||||
mission.mission_dataman_id = DM_KEY_WAYPOINTS_OFFBOARD_1;
|
||||
|
||||
mission_item_s land = makeSafePointItem(kBaseLat, kBaseLon, kAlt, NAV_FRAME_GLOBAL, NAV_CMD_LAND);
|
||||
land.autocontinue = true;
|
||||
land.yaw = NAN;
|
||||
|
||||
// GIVEN: A pure multicopter (never VTOL) starting 100 m from the land point, with no
|
||||
// commanded landing yaw.
|
||||
const PositionYawSetpoint far_position = makePositionYawSetpointFromOffset(kBaseLat, kBaseLon, 100.f, 0.f, kAlt);
|
||||
|
||||
publishMission(mission);
|
||||
publishVehicleStatus(false, vehicle_status_s::VEHICLE_TYPE_ROTARY_WING);
|
||||
publishGlobalPosition(far_position.lat, far_position.lon, kAlt);
|
||||
publishLandDetected(false);
|
||||
_navigator.get_mission_result()->valid = true;
|
||||
|
||||
_navigator.get_global_position()->lat = far_position.lat;
|
||||
_navigator.get_global_position()->lon = far_position.lon;
|
||||
_navigator.get_global_position()->alt = kAlt;
|
||||
_navigator.get_global_position()->timestamp = hrt_absolute_time();
|
||||
_navigator.get_land_detected()->landed = false;
|
||||
_navigator.get_vstatus()->vehicle_type = vehicle_status_s::VEHICLE_TYPE_ROTARY_WING;
|
||||
_navigator.get_vstatus()->is_vtol = false;
|
||||
|
||||
RtlDirectMissionLandTestPeer direct_mission_land{&_navigator, mission};
|
||||
direct_mission_land.loadTestMission({land});
|
||||
direct_mission_land.setRtlAlt(kAlt);
|
||||
|
||||
// WHEN: The mission activates while still far from the land point.
|
||||
direct_mission_land.activateForTest();
|
||||
ASSERT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_MOVE_TO_LAND);
|
||||
|
||||
// WHEN: The vehicle arrives at the land point.
|
||||
publishGlobalPosition(kBaseLat, kBaseLon, kAlt);
|
||||
_navigator.get_global_position()->lat = kBaseLat;
|
||||
_navigator.get_global_position()->lon = kBaseLon;
|
||||
direct_mission_land.on_active();
|
||||
|
||||
// THEN: With no yaw to align to, it lands directly -- no ALIGN_TO_LAND stop in between.
|
||||
EXPECT_EQ(direct_mission_land.activeWorkItemType(), WorkItemType::WORK_ITEM_TYPE_DEFAULT);
|
||||
EXPECT_EQ(direct_mission_land.activeNavCommand(), NAV_CMD_LAND);
|
||||
EXPECT_TRUE(std::isnan(direct_mission_land.activeYaw()));
|
||||
}
|
||||
|
||||
// WHY: No land point means no usable approach bearing.
|
||||
// WHAT: The chooser should return an invalid loiter.
|
||||
TEST_F(RTLTest, MissionFastKeepsVtolInMulticopterMode)
|
||||
|
||||
Reference in new issue
Block a user