mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-12-03 23:10:46 +08:00
feat(navigator): skip automatic front transitions after a quadchute (#29625)
This commit is contained in:
1 parent
4f7e35a06a
commit
c1d5757020
9 files changed
+214
-9
No files matched your search
@@ -379,6 +379,9 @@ The parachute health failsafe is triggered when a [MAVLink parachute](../periphe
|
||||
Failsafe for when a VTOL vehicle can no longer fly in fixed-wing mode, perhaps due to the failure of a pusher motor, airspeed sensor, or control surface.
|
||||
If the failsafe is triggered, the vehicle will immediately switch to multicopter mode and execute the action defined in parameter [COM_QC_ACT](#COM_QC_ACT).
|
||||
|
||||
After a quad-chute, Mission and VTOL Takeoff mode no longer command forward transitions, as the next one would likely fail too: they skip them and fly on in multicopter mode, which has much less range.
|
||||
A forward transition commanded by the pilot or ground station allows them again; otherwise this lasts until the vehicle is rebooted.
|
||||
|
||||
::: info
|
||||
The quad-chute can also be triggered by sending a MAVLINK [MAV_CMD_DO_VTOL_TRANSITION](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_VTOL_TRANSITION) message with `param2` set to `1`.
|
||||
:::
|
||||
|
||||
@@ -195,7 +195,7 @@ Please continue reading for [upgrade instructions](#upgrade-guide).
|
||||
|
||||
### VTOL
|
||||
|
||||
- TBD
|
||||
- After a [quad-chute](../config/safety.md#quad-chute-failsafe), Mission and VTOL Takeoff mode no longer command forward transitions and continue in multicopter mode. Before, a resumed mission commanded the next transition again, which also cleared the quad-chute, and with [COM_QC_ACT](../advanced_config/parameter_reference.md#COM_QC_ACT) set to Warning a quad-chute during a mission transition left the mission waiting at that item.
|
||||
|
||||
### Fixed-wing
|
||||
|
||||
|
||||
@@ -407,9 +407,14 @@ void Mission::handleTakeoff(WorkItemType &new_work_item_type, mission_item_s nex
|
||||
_mission_item.yaw = NAN;
|
||||
}
|
||||
|
||||
/* if we just did a normal takeoff navigate to the actual waypoint now */
|
||||
if (_mission_item.nav_cmd == NAV_CMD_TAKEOFF &&
|
||||
_work_item_type == WorkItemType::WORK_ITEM_TYPE_CLIMB) {
|
||||
/* if we just did a normal takeoff, or a VTOL takeoff without transition after a quadchute, navigate to the actual waypoint now */
|
||||
if ((_mission_item.nav_cmd == NAV_CMD_TAKEOFF
|
||||
|| (_mission_item.nav_cmd == NAV_CMD_VTOL_TAKEOFF && _navigator->front_transition_inhibited()))
|
||||
&& _work_item_type == WorkItemType::WORK_ITEM_TYPE_CLIMB) {
|
||||
|
||||
if (_mission_item.nav_cmd == NAV_CMD_VTOL_TAKEOFF) {
|
||||
send_front_transition_skipped();
|
||||
}
|
||||
|
||||
_mission_item.nav_cmd = NAV_CMD_WAYPOINT;
|
||||
/* ignore yaw here, otherwise it might yaw before heading_sp_update takes over */
|
||||
@@ -470,13 +475,14 @@ void Mission::handleVtolTransition(WorkItemType &new_work_item_type, mission_ite
|
||||
{
|
||||
position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();
|
||||
|
||||
/* turn towards next waypoint before MC to FW transition */
|
||||
/* turn towards next waypoint before MC to FW transition, unless it is skipped after a quadchute */
|
||||
if (_mission_item.nav_cmd == NAV_CMD_DO_VTOL_TRANSITION
|
||||
&& _work_item_type == WorkItemType::WORK_ITEM_TYPE_DEFAULT
|
||||
&& new_work_item_type == WorkItemType::WORK_ITEM_TYPE_DEFAULT
|
||||
&& _vehicle_status_sub.get().vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING
|
||||
&& !_land_detected_sub.get().landed
|
||||
&& (num_found_items > 0u)) {
|
||||
&& (num_found_items > 0u)
|
||||
&& !_navigator->front_transition_inhibited()) {
|
||||
|
||||
new_work_item_type = WorkItemType::WORK_ITEM_TYPE_ALIGN_HEADING;
|
||||
|
||||
|
||||
@@ -130,8 +130,10 @@ MissionBlock::is_mission_item_reached_or_completed()
|
||||
&& !_navigator->get_vstatus()->in_transition_mode;
|
||||
|
||||
} else if (int(_mission_item.params[0]) == 4) {
|
||||
// transition to FW requested, only accept waypoint if vehicle state has changed accordingly
|
||||
return _navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING;
|
||||
// transition to FW requested, only accept waypoint if vehicle state has changed accordingly.
|
||||
// After a quadchute, also one during this transition, the mission continues in multicopter mode.
|
||||
return _navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING
|
||||
|| _navigator->front_transition_inhibited();
|
||||
|
||||
} else {
|
||||
// invalid vtol transition request
|
||||
@@ -539,6 +541,13 @@ MissionBlock::reset_mission_item_reached()
|
||||
_time_item_started = 0;
|
||||
}
|
||||
|
||||
void
|
||||
MissionBlock::send_front_transition_skipped()
|
||||
{
|
||||
events::send(events::ID("navigator_front_transition_skipped"), events::Log::Warning,
|
||||
"Front transition skipped after quad-chute, continuing in multicopter mode");
|
||||
}
|
||||
|
||||
void
|
||||
MissionBlock::issue_command(const mission_item_s &item)
|
||||
{
|
||||
@@ -548,6 +557,12 @@ MissionBlock::issue_command(const mission_item_s &item)
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.nav_cmd == NAV_CMD_DO_VTOL_TRANSITION && int(item.params[0]) == vtol_vehicle_status_s::VEHICLE_VTOL_STATE_FW
|
||||
&& _navigator->front_transition_inhibited()) {
|
||||
send_front_transition_skipped();
|
||||
return;
|
||||
}
|
||||
|
||||
// This is to support legacy DO_MOUNT_CONTROL as part of a mission.
|
||||
if (item.nav_cmd == NAV_CMD_DO_MOUNT_CONTROL) {
|
||||
_navigator->acquire_gimbal_control();
|
||||
|
||||
@@ -218,6 +218,8 @@ protected:
|
||||
*/
|
||||
void issue_command(const mission_item_s &item);
|
||||
|
||||
static void send_front_transition_skipped();
|
||||
|
||||
/**
|
||||
* [s] Get the time to stay that's specified in the mission item
|
||||
*/
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
#include <uORB/topics/vehicle_local_position.h>
|
||||
#include <uORB/topics/vehicle_roi.h>
|
||||
#include <uORB/topics/vehicle_status.h>
|
||||
#include <uORB/topics/vtol_vehicle_status.h>
|
||||
#include <uORB/topics/mode_completed.h>
|
||||
#include <uORB/uORB.h>
|
||||
|
||||
@@ -340,6 +341,12 @@ public:
|
||||
|
||||
bool force_vtol();
|
||||
|
||||
/**
|
||||
* After a quadchute the next front transition would likely fail too, so navigator does not command one.
|
||||
* The quadchute stays latched until a front transition is commanded (e.g. by the pilot) or the vehicle reboots.
|
||||
*/
|
||||
bool front_transition_inhibited() const { return _front_transition_inhibited; }
|
||||
|
||||
void acquire_gimbal_control();
|
||||
void release_gimbal_control();
|
||||
void set_gimbal_neutral();
|
||||
@@ -365,6 +372,7 @@ public:
|
||||
void trigger_hagl_failsafe(uint8_t nav_state);
|
||||
|
||||
private:
|
||||
friend class MissionBaseTestNavigator;
|
||||
|
||||
orb_sub_t _local_pos_sub{ORB_SUB_INVALID};
|
||||
orb_sub_t _mission_sub{ORB_SUB_INVALID};
|
||||
@@ -383,6 +391,7 @@ private:
|
||||
uORB::Subscription _pos_ctrl_landing_status_sub{ORB_ID(position_controller_landing_status)}; /**< position controller landing status subscription */
|
||||
uORB::Subscription _fw_takeoff_status_sub{ORB_ID(fixed_wing_takeoff_status)}; /**< fixed-wing takeoff status subscription */
|
||||
uORB::Subscription _vehicle_command_sub{ORB_ID(vehicle_command)}; /**< vehicle commands (onboard and offboard) */
|
||||
uORB::Subscription _vtol_vehicle_status_sub{ORB_ID(vtol_vehicle_status)};
|
||||
|
||||
uORB::Publication<geofence_result_s> _geofence_result_pub{ORB_ID(geofence_result)};
|
||||
uORB::Publication<mission_result_s> _mission_result_pub{ORB_ID(mission_result)};
|
||||
@@ -404,6 +413,7 @@ private:
|
||||
vehicle_land_detected_s _land_detected{}; /**< vehicle land_detected */
|
||||
vehicle_local_position_s _local_pos{}; /**< local vehicle position */
|
||||
vehicle_status_s _vstatus{}; /**< vehicle status */
|
||||
bool _front_transition_inhibited{false};
|
||||
|
||||
// Publications
|
||||
geofence_result_s _geofence_result{};
|
||||
|
||||
@@ -364,6 +364,12 @@ void Navigator::run()
|
||||
_takeoff_status_sub.update();
|
||||
_home_pos_sub.update(&_home_pos);
|
||||
|
||||
vtol_vehicle_status_s vtol_vehicle_status{};
|
||||
|
||||
if (_vtol_vehicle_status_sub.update(&vtol_vehicle_status)) {
|
||||
_front_transition_inhibited = vtol_vehicle_status.fixed_wing_system_failure;
|
||||
}
|
||||
|
||||
// Handle Vehicle commands
|
||||
int vehicle_command_updates = 0;
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "mission.h"
|
||||
#include "mission_base.h"
|
||||
#include "navigator.h"
|
||||
#include "vtol_takeoff.h"
|
||||
#include "support/geofence_test_helpers.h"
|
||||
#include "support/mission_route_cache_test_peer.h"
|
||||
#include "support/navigator_dataman_test.h"
|
||||
@@ -59,8 +60,10 @@
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/home_position.h>
|
||||
#include <uORB/topics/mavlink_log.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
#include <uORB/topics/vehicle_global_position.h>
|
||||
#include <uORB/topics/vehicle_land_detected.h>
|
||||
#include <uORB/topics/vtol_vehicle_status.h>
|
||||
|
||||
class MissionBaseTestPeer : public MissionBase
|
||||
{
|
||||
@@ -206,6 +209,7 @@ class MissionBaseTestNavigator : public Navigator
|
||||
{
|
||||
public:
|
||||
using Navigator::updateParams;
|
||||
void setFrontTransitionInhibited(bool inhibited) { _front_transition_inhibited = inhibited; }
|
||||
};
|
||||
|
||||
class MissionBaseFeasibilityTest : public NavigatorDatamanTestBase
|
||||
@@ -651,6 +655,161 @@ INSTANTIATE_TEST_SUITE_P(ReplacementSetpoints, MissionReplacementFeasibilityTest
|
||||
return test_info.param.name;
|
||||
});
|
||||
|
||||
// WHY: After a quadchute the next front transition would likely fail too, and its command would clear the quadchute.
|
||||
// WHAT: With the quadchute latched (true), navigator neither aligns for nor commands a front transition and goes on
|
||||
// in multicopter mode. Without it (false), the same steps command the transition.
|
||||
class QuadchuteFrontTransitionTest : public MissionBaseFeasibilityTest, public ::testing::WithParamInterface<bool>
|
||||
{
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
MissionBaseFeasibilityTest::SetUp();
|
||||
|
||||
// a VTOL hovering above home at mission altitude, facing north
|
||||
_navigator.get_vstatus()->is_vtol = true;
|
||||
_status_pub.publish(*_navigator.get_vstatus());
|
||||
_navigator.get_global_position()->timestamp = hrt_absolute_time(); // VTOL Takeoff needs a recent position
|
||||
_navigator.get_global_position()->alt = kAlt;
|
||||
_global_position_pub.publish(*_navigator.get_global_position());
|
||||
_navigator.get_land_detected()->landed = false;
|
||||
_land_detected_pub.publish(*_navigator.get_land_detected());
|
||||
_navigator.get_local_position()->heading = 0.f;
|
||||
_navigator.get_local_position()->heading_good_for_control = true;
|
||||
|
||||
_navigator.setFrontTransitionInhibited(GetParam());
|
||||
transitionCommanded(); // drop commands of earlier tests
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
_navigator.get_land_detected()->landed = true;
|
||||
_land_detected_pub.publish(*_navigator.get_land_detected());
|
||||
MissionBaseFeasibilityTest::TearDown();
|
||||
}
|
||||
|
||||
static mission_item_s waypointNorth(float north_m)
|
||||
{
|
||||
mission_item_s item = makePositionItem(kBaseLat, kBaseLon, kAlt);
|
||||
add_vector_to_global_position(kBaseLat, kBaseLon, north_m, 0.f, &item.lat, &item.lon);
|
||||
item.yaw = NAN;
|
||||
return item;
|
||||
}
|
||||
|
||||
void uploadMission(std::vector<mission_item_s> items)
|
||||
{
|
||||
for (size_t index = 0; index < items.size(); ++index) {
|
||||
items[index].autocontinue = true;
|
||||
ASSERT_TRUE(_dataman_client.writeSync(DM_KEY_WAYPOINTS_OFFBOARD_0, index,
|
||||
reinterpret_cast<uint8_t *>(&items[index]), sizeof(mission_item_s)));
|
||||
}
|
||||
|
||||
mission_s mission{};
|
||||
mission.timestamp = hrt_absolute_time();
|
||||
mission.mission_id = 2;
|
||||
mission.geofence_id = 1; // the fence of MissionBaseFeasibilityTest
|
||||
mission.mission_dataman_id = DM_KEY_WAYPOINTS_OFFBOARD_0;
|
||||
mission.count = items.size();
|
||||
_mission_pub.publish(mission);
|
||||
}
|
||||
|
||||
bool transitionCommanded()
|
||||
{
|
||||
bool commanded = false;
|
||||
vehicle_command_s vehicle_command{};
|
||||
|
||||
while (_vehicle_command_sub.update(&vehicle_command)) {
|
||||
commanded |= vehicle_command.command == vehicle_command_s::VEHICLE_CMD_DO_VTOL_TRANSITION
|
||||
&& static_cast<int>(vehicle_command.param1) == vtol_vehicle_status_s::VEHICLE_VTOL_STATE_FW;
|
||||
}
|
||||
|
||||
return commanded;
|
||||
}
|
||||
|
||||
uORB::Publication<vehicle_global_position_s> _global_position_pub{ORB_ID(vehicle_global_position)};
|
||||
uORB::Publication<vehicle_land_detected_s> _land_detected_pub{ORB_ID(vehicle_land_detected)};
|
||||
uORB::Subscription _vehicle_command_sub{ORB_ID(vehicle_command)};
|
||||
};
|
||||
|
||||
TEST_P(QuadchuteFrontTransitionTest, MissionSkipsFrontTransitionItem)
|
||||
{
|
||||
// close to home, so that the loiter circle of the last waypoint stays inside the 100 m fence
|
||||
const mission_item_s next_waypoint = waypointNorth(15.f);
|
||||
uploadMission({waypointNorth(0.f), makeVtolTransitionItem(vtol_vehicle_status_s::VEHICLE_VTOL_STATE_FW), next_waypoint});
|
||||
Mission mission{&_navigator};
|
||||
mission.run(false);
|
||||
mission.run(true);
|
||||
|
||||
mission.run(true); // on the first waypoint, the transition item comes next
|
||||
const position_setpoint_s ¤t = _navigator.get_position_setpoint_triplet()->current;
|
||||
EXPECT_EQ(PX4_ISFINITE(current.yaw), !GetParam()); // the alignment towards the next waypoint
|
||||
|
||||
mission.run(true);
|
||||
mission.run(true);
|
||||
EXPECT_EQ(transitionCommanded(), !GetParam());
|
||||
|
||||
if (!GetParam()) {
|
||||
_navigator.setFrontTransitionInhibited(true); // during the commanded transition
|
||||
mission.run(true);
|
||||
}
|
||||
|
||||
EXPECT_DOUBLE_EQ(current.lat, next_waypoint.lat); // on as a multicopter
|
||||
}
|
||||
|
||||
TEST_P(QuadchuteFrontTransitionTest, MissionVtolTakeoffInTheAirSkipsTransition)
|
||||
{
|
||||
mission_item_s vtol_takeoff = waypointNorth(10.f);
|
||||
vtol_takeoff.nav_cmd = NAV_CMD_VTOL_TAKEOFF;
|
||||
uploadMission({vtol_takeoff, waypointNorth(15.f)});
|
||||
Mission mission{&_navigator};
|
||||
mission.run(false);
|
||||
mission.run(true);
|
||||
|
||||
mission.run(true); // already at the takeoff altitude
|
||||
const position_setpoint_s ¤t = _navigator.get_position_setpoint_triplet()->current;
|
||||
|
||||
if (GetParam()) {
|
||||
// on to the takeoff waypoint as a multicopter
|
||||
EXPECT_EQ(current.type, position_setpoint_s::SETPOINT_TYPE_POSITION);
|
||||
EXPECT_DOUBLE_EQ(current.lat, vtol_takeoff.lat);
|
||||
|
||||
} else {
|
||||
EXPECT_DOUBLE_EQ(current.lat, kBaseLat); // aligns in place towards the takeoff waypoint
|
||||
}
|
||||
|
||||
mission.run(true);
|
||||
EXPECT_EQ(transitionCommanded(), !GetParam());
|
||||
}
|
||||
|
||||
TEST_P(QuadchuteFrontTransitionTest, VtolTakeoffSkipsTransition)
|
||||
{
|
||||
const mission_item_s loiter = waypointNorth(200.f);
|
||||
VtolTakeoff takeoff{&_navigator};
|
||||
takeoff.setTransitionAltitudeAbsolute(kAlt);
|
||||
takeoff.setTransitionDirection(GetParam() ? 90.f : 0.f); // after a quad-chute no alignment holds it back
|
||||
takeoff.setLoiterLocation(matrix::Vector2d(loiter.lat, loiter.lon));
|
||||
takeoff.setLoiterHeight(20.f);
|
||||
takeoff.on_activation();
|
||||
|
||||
for (int cycle = 0; cycle < 4; ++cycle) {
|
||||
takeoff.on_active();
|
||||
}
|
||||
|
||||
EXPECT_EQ(transitionCommanded(), !GetParam());
|
||||
|
||||
if (GetParam()) {
|
||||
// on to its loiter as a multicopter
|
||||
const position_setpoint_s ¤t = _navigator.get_position_setpoint_triplet()->current;
|
||||
EXPECT_EQ(current.type, position_setpoint_s::SETPOINT_TYPE_LOITER);
|
||||
EXPECT_DOUBLE_EQ(current.lat, loiter.lat);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(Quadchute, QuadchuteFrontTransitionTest, ::testing::Bool(),
|
||||
[](const ::testing::TestParamInfo<bool> &test_info)
|
||||
{
|
||||
return test_info.param ? "AfterQuadchute" : "Nominal";
|
||||
});
|
||||
|
||||
enum class MissionFeasibilityInput { Mission, Geofence, Home };
|
||||
|
||||
struct ChangedMissionInput {
|
||||
|
||||
@@ -75,7 +75,11 @@ VtolTakeoff::on_active()
|
||||
|
||||
_mission_item.nav_cmd = NAV_CMD_WAYPOINT;
|
||||
|
||||
if (!PX4_ISFINITE(_transition_direction_deg)) {
|
||||
if (_navigator->front_transition_inhibited()) {
|
||||
// nothing to align for, the transition is skipped after a quad-chute
|
||||
_mission_item.yaw = NAN;
|
||||
|
||||
} else if (!PX4_ISFINITE(_transition_direction_deg)) {
|
||||
_mission_item.yaw = wrap_pi(get_bearing_to_next_waypoint(_mission_item.lat,
|
||||
_mission_item.lon, _loiter_location(0), _loiter_location(1)));
|
||||
|
||||
|
||||
Reference in new issue
Block a user