mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-24 16:01:53 +08:00
feat(navigator): continue in Guided Course after the fixed-wing takeoff (#28930)
* feat(navigator): hold a commanded course after the fixed-wing takeoff A finite yaw in MAV_CMD_NAV_TAKEOFF (param4) ends the climbout in a course hold at the takeoff altitude instead of a loiter, and the vehicle stays in Takeoff mode. NaN keeps the loiter. * feat(navigator): continue in Guided Course after a course takeoff * fix(navigator): ignore lat/lon during a course-based takeoff * fix(navigator): add guard for 0 heading takeoff --------- Co-authored-by: federicomagri12 <federico.magri@auterion.com>
This commit is contained in:
1 parent
989a01382b
commit
02dbc12355
12 files changed
+148
-64
No files matched your search
@@ -22,6 +22,7 @@ This mode is suited to situations where an operator wants to guide a fixed-wing
|
||||
## Overview
|
||||
|
||||
On activation, the vehicle captures its current velocity over ground vector as the initial course bearing and holds altitude and airspeed from the moment of activation.
|
||||
A fixed-wing [Takeoff](../flight_modes_fw/takeoff.md) with a commanded course enters this mode directly after the climbout and continues on that course instead.
|
||||
The vehicle then flies that course indefinitely until the operator issues a new command.
|
||||
|
||||
There is no waypoint sequencing or autonomous path planning: the GCS guides the vehicle in real time by sending individual commands.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<img src="../../assets/site/position_fixed.svg" title="Position fix required (e.g. GPS)" width="30px" />
|
||||
|
||||
The _Takeoff_ flight mode causes the vehicle to take off to a specified height and then enter [Hold mode](../flight_modes_fw/takeoff.md).
|
||||
The _Takeoff_ flight mode causes the vehicle to take off to a specified height and then enter [Hold mode](../flight_modes_fw/hold.md), or [Guided Course mode](../flight_modes_fw/guided_course.md) on a commanded course.
|
||||
|
||||
Vehicles are [hand or catapult launched](#catapult-hand-launch) by default, but can also be [configured](#RWTO_TKOFF) to use a [runway takeoff](#runway-takeoff) when supported by the hardware.
|
||||
|
||||
@@ -34,18 +34,25 @@ Irrespective of the modality, a flight path (starting point and takeoff course)
|
||||
|
||||
- The starting point is the vehicle position when the takeoff mode is first entered.
|
||||
- The course is set to the vehicle heading on arming by default.
|
||||
If a valid waypoint latitude/longitude is set the vehicle will instead track towards the waypoint.
|
||||
If a valid waypoint latitude/longitude is set, the vehicle will instead track towards the waypoint during the climbout.
|
||||
- After the climbout the vehicle enters [Hold mode](../flight_modes_fw/hold.md).
|
||||
If a course is set (`MAV_CMD_NAV_TAKEOFF` param4, or the same field of the [VehicleCommand](../msg_docs/VehicleCommand.md) uORB topic) it instead enters [Guided Course mode](../flight_modes_fw/guided_course.md) on that course.
|
||||
- The clearance altitude is set to [MIS_TAKEOFF_ALT](#MIS_TAKEOFF_ALT) by default.
|
||||
If a valid waypoint altitude is set is set the vehicle will instead use it as the clearance altitude.
|
||||
|
||||
By default, on takeoff the aircraft will follow the line defined by the starting point and course, climbing at the maximum climb rate ([FW_T_CLMB_MAX](../advanced_config/parameter_reference.md#FW_T_CLMB_MAX)) until reaching the clearance altitude.
|
||||
Reaching the clearance altitude causes the vehicle to enter [Hold mode](../flight_modes_fw/takeoff.md).
|
||||
Reaching the clearance altitude causes the vehicle to enter [Hold mode](../flight_modes_fw/hold.md).
|
||||
|
||||
[FW_TKO_CLMB_T](#FW_TKO_CLMB_T) ends the climbout after a fixed time instead.
|
||||
The vehicle holds at whatever altitude it has reached by then, or climbs to the clearance altitude if it is still below it.
|
||||
Use it where altitude is a poor measure of when the climbout is done, such as a rocket-assisted launch.
|
||||
|
||||
If a valid waypoint target is set, using `MAV_CMD_NAV_TAKEOFF` or the [VehicleCommand](../msg_docs/VehicleCommand.md) uORB topic, the vehicle will instead track towards the waypoint, and enter [Hold mode](../flight_modes_fw/takeoff.md) after reaching the waypoint altitude (within the acceptance radius).
|
||||
If a valid waypoint target is set, using `MAV_CMD_NAV_TAKEOFF` or the [VehicleCommand](../msg_docs/VehicleCommand.md) uORB topic, the vehicle will instead track towards the waypoint, and enter [Hold mode](../flight_modes_fw/hold.md) after reaching the waypoint altitude (within the acceptance radius).
|
||||
|
||||
If a course is set in `MAV_CMD_NAV_TAKEOFF` param4 (labelled _Yaw_ in MAVLink), the vehicle enters [Guided Course mode](../flight_modes_fw/guided_course.md) after the climbout instead of Hold mode.
|
||||
It continues on that course over ground, at the same altitude Hold mode would use.
|
||||
The climbout stays straight, and the turn onto the course comes after it.
|
||||
A waypoint latitude/longitude takes precedence over the course.
|
||||
|
||||
::: tip
|
||||
If the local position is invalid or becomes invalid while executing the takeoff, the controller is not able to track a course setpoint and will instead proceed climbing while keeping the wings level until the clearance altitude is reached.
|
||||
|
||||
@@ -14,7 +14,7 @@ uint16 VEHICLE_CMD_NAV_LOITER_TURNS = 18 # Loiter around this MISSION for X turn
|
||||
uint16 VEHICLE_CMD_NAV_LOITER_TIME = 19 # Loiter around this MISSION for time. |[s] Seconds (decimal)|Unused|Radius around MISSION [m]. If positive loiter clockwise, else counter-clockwise|Desired yaw angle.|Latitude|Longitude|Altitude|
|
||||
uint16 VEHICLE_CMD_NAV_RETURN_TO_LAUNCH = 20 # Return to launch location. |Unused|Unused|Unused|Unused|Unused|Unused|Unused|
|
||||
uint16 VEHICLE_CMD_NAV_LAND = 21 # Land at location. |Unused|Unused|Unused|Desired yaw angle.|Latitude|Longitude|Altitude|
|
||||
uint16 VEHICLE_CMD_NAV_TAKEOFF = 22 # Takeoff from ground / hand. |Unused (FW pitch from FW_TKO_PITCH_MIN)|Unused|Unused|[deg] [@range 0,360] Yaw angle in NED if yaw source available, ignored otherwise|Latitude (WGS-84)|Longitude (WGS-84)|[m] Altitude AMSL|
|
||||
uint16 VEHICLE_CMD_NAV_TAKEOFF = 22 # Takeoff from ground / hand. |Unused (FW pitch from FW_TKO_PITCH_MIN)|Unused|Unused|[deg] [@range 0,360] Multicopter: yaw angle in NED if yaw source available, ignored otherwise. Fixed-wing: course over ground to continue on in Guided Course mode after the climbout (only if no latitude/longitude is set), NaN = Hold mode|Latitude (WGS-84)|Longitude (WGS-84)|[m] Altitude AMSL|
|
||||
uint16 VEHICLE_CMD_NAV_PRECLAND = 23 # Attempt a precision landing.
|
||||
uint16 VEHICLE_CMD_DO_ORBIT = 34 # Start orbiting on the circumference of a circle defined by the parameters. |[m] Radius|[m/s] Velocity|[@enum ORBIT_YAW_BEHAVIOUR] Yaw behaviour|Unused|Latitude/X|Longitude/Y|Altitude/Z|
|
||||
uint16 VEHICLE_CMD_DO_FIGUREEIGHT = 35 # Start flying on the outline of a figure eight defined by the parameters. |[m] Major radius|[m] Minor radius|[m/s] Velocity|Orientation|Latitude/X|Longitude/Y|Altitude/Z|
|
||||
|
||||
@@ -1216,6 +1216,10 @@ Commander::handle_command(const vehicle_command_s &cmd)
|
||||
case vehicle_command_s::VEHICLE_CMD_NAV_TAKEOFF: {
|
||||
/* ok, home set, use it to take off */
|
||||
if (_user_mode_intention.change(vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF, getSourceFromCommand(cmd))) {
|
||||
// fixed-wing: course to continue on after the climbout, unless a takeoff position is set (as in Navigator)
|
||||
const bool takeoff_position_valid = PX4_ISFINITE(cmd.param5) && PX4_ISFINITE(cmd.param6)
|
||||
&& (fabs(cmd.param5) > DBL_EPSILON || fabs(cmd.param6) > DBL_EPSILON);
|
||||
_takeoff_hold_course = PX4_ISFINITE(cmd.param4) && !takeoff_position_valid;
|
||||
cmd_result = vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED;
|
||||
|
||||
} else {
|
||||
@@ -2205,6 +2209,10 @@ void Commander::run()
|
||||
|
||||
void Commander::checkForMissionUpdate()
|
||||
{
|
||||
if (_takeoff_hold_course && _user_mode_intention.get() != vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF) {
|
||||
_takeoff_hold_course = false; // the commanded takeoff was left or completed
|
||||
}
|
||||
|
||||
if (_mission_result_sub.updated()) {
|
||||
const mission_result_s &mission_result = _mission_result_sub.get();
|
||||
|
||||
@@ -2244,8 +2252,16 @@ void Commander::checkForMissionUpdate()
|
||||
|
||||
if (_vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF
|
||||
|| _vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_VTOL_TAKEOFF) {
|
||||
// Transition to loiter when the takeoff is completed (force into the Loiter, if mode is not executable then failsafe).
|
||||
_user_mode_intention.change(vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER, ModeChangeSource::ModeExecutor, false, true);
|
||||
// A fixed-wing takeoff with a commanded course continues in Guided Course.
|
||||
const bool continue_on_course = _takeoff_hold_course
|
||||
&& _vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF
|
||||
&& _vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING
|
||||
&& _user_mode_intention.change(vehicle_status_s::NAVIGATION_STATE_GUIDED_COURSE, ModeChangeSource::ModeExecutor);
|
||||
|
||||
if (!continue_on_course) {
|
||||
// Transition to loiter when the takeoff is completed (force into the Loiter, if mode is not executable then failsafe).
|
||||
_user_mode_intention.change(vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER, ModeChangeSource::ModeExecutor, false, true);
|
||||
}
|
||||
|
||||
} else if (_vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION) {
|
||||
// Transition to loiter when the mission is cleared and/or finished, and we are still in mission mode.
|
||||
|
||||
@@ -290,6 +290,7 @@ private:
|
||||
bool _have_taken_off_since_arming{false};
|
||||
bool _status_changed{true};
|
||||
bool _mission_in_progress{false};
|
||||
bool _takeoff_hold_course{false}; ///< the takeoff command carried a course, continue in Guided Course
|
||||
|
||||
vehicle_land_detected_s _vehicle_land_detected{};
|
||||
|
||||
|
||||
@@ -49,20 +49,34 @@ Course::Course(Navigator *navigator) :
|
||||
void
|
||||
Course::on_activation()
|
||||
{
|
||||
// Snapshot the setpoint the previous mode left before resetting the triplet, so we can continue
|
||||
// a course that is already being flown, for example handed over by the fixed-wing takeoff.
|
||||
const position_setpoint_s previous_setpoint = _navigator->get_position_setpoint_triplet()->current;
|
||||
|
||||
// reset triplets, modes should be explicit about which fields they want to set
|
||||
_navigator->reset_triplets();
|
||||
|
||||
const vehicle_local_position_s *lpos = _navigator->get_local_position();
|
||||
const bool continue_course = previous_setpoint.valid
|
||||
&& previous_setpoint.type == position_setpoint_s::SETPOINT_TYPE_POSITION
|
||||
&& PX4_ISFINITE(previous_setpoint.course);
|
||||
|
||||
_altitude = _navigator->get_global_position()->alt;
|
||||
if (continue_course) {
|
||||
_course = previous_setpoint.course;
|
||||
_altitude = previous_setpoint.alt;
|
||||
|
||||
if (lpos->v_xy_valid) {
|
||||
_course = matrix::wrap_2pi(atan2f(lpos->vy, lpos->vx));
|
||||
} else {
|
||||
const vehicle_local_position_s *lpos = _navigator->get_local_position();
|
||||
|
||||
_altitude = _navigator->get_global_position()->alt;
|
||||
|
||||
if (lpos->v_xy_valid) {
|
||||
_course = matrix::wrap_2pi(atan2f(lpos->vy, lpos->vx));
|
||||
}
|
||||
}
|
||||
|
||||
_navigator->reset_cruising_speed();
|
||||
|
||||
update_setpoint_triplet();
|
||||
publishCourseHoldSetpoint(_course, _altitude);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -79,44 +93,6 @@ Course::set_course(float course_rad)
|
||||
}
|
||||
|
||||
_course = course_rad;
|
||||
update_setpoint_triplet();
|
||||
publishCourseHoldSetpoint(_course, _altitude);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Course::update_setpoint_triplet()
|
||||
{
|
||||
position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();
|
||||
|
||||
pos_sp_triplet->previous.valid = false;
|
||||
|
||||
pos_sp_triplet->current.valid = true;
|
||||
pos_sp_triplet->current.type = position_setpoint_s::SETPOINT_TYPE_POSITION;
|
||||
pos_sp_triplet->current.alt = _altitude;
|
||||
|
||||
// Course mode: control ground track.
|
||||
// lat/lon are not used for course guidance but FixedWingModeManager::set_control_mode_current() requires
|
||||
// PX4_ISFINITE(lat) && PX4_ISFINITE(lon) to classify the setpoint as valid and enter FW_POSCTRL_MODE_AUTO.
|
||||
// Use current position if available (including during dead-reckoning), otherwise dummy values.
|
||||
if (_navigator->get_local_position()->xy_global) {
|
||||
pos_sp_triplet->current.lat = _navigator->get_global_position()->lat;
|
||||
pos_sp_triplet->current.lon = _navigator->get_global_position()->lon;
|
||||
|
||||
} else {
|
||||
pos_sp_triplet->current.lat = 0.0;
|
||||
pos_sp_triplet->current.lon = 0.0;
|
||||
}
|
||||
|
||||
pos_sp_triplet->current.yaw = NAN;
|
||||
pos_sp_triplet->current.course = _course;
|
||||
|
||||
pos_sp_triplet->current.cruising_speed = _navigator->get_cruising_speed();
|
||||
pos_sp_triplet->current.cruising_throttle = NAN;
|
||||
pos_sp_triplet->current.loiter_radius = NAN;
|
||||
pos_sp_triplet->current.acceptance_radius = _navigator->get_acceptance_radius();
|
||||
pos_sp_triplet->current.timestamp = hrt_absolute_time();
|
||||
|
||||
pos_sp_triplet->next.valid = false;
|
||||
|
||||
_navigator->set_position_setpoint_triplet_updated();
|
||||
}
|
||||
@@ -60,14 +60,9 @@ public:
|
||||
*/
|
||||
bool set_course(float course_rad);
|
||||
|
||||
void set_altitude(float alt_amsl) { _altitude = alt_amsl; update_setpoint_triplet(); }
|
||||
void set_altitude(float alt_amsl) { _altitude = alt_amsl; publishCourseHoldSetpoint(_course, _altitude); }
|
||||
|
||||
private:
|
||||
/**
|
||||
* Update the position setpoint triplet to fly the current course.
|
||||
*/
|
||||
void update_setpoint_triplet();
|
||||
|
||||
float _course{0.f}; ///< [rad] current course bearing (ground track)
|
||||
float _altitude{0.f}; ///< [m] AMSL altitude setpoint
|
||||
};
|
||||
@@ -806,6 +806,43 @@ MissionBlock::set_takeoff_item(struct mission_item_s *item, float abs_altitude)
|
||||
item->origin = ORIGIN_ONBOARD;
|
||||
}
|
||||
|
||||
void
|
||||
MissionBlock::publishCourseHoldSetpoint(const float course_rad, const float altitude_amsl)
|
||||
{
|
||||
position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();
|
||||
|
||||
pos_sp_triplet->previous.valid = false;
|
||||
|
||||
pos_sp_triplet->current.valid = true;
|
||||
pos_sp_triplet->current.type = position_setpoint_s::SETPOINT_TYPE_POSITION;
|
||||
pos_sp_triplet->current.alt = altitude_amsl;
|
||||
|
||||
// lat/lon are not used for course guidance but FixedWingModeManager::set_control_mode_current() requires
|
||||
// PX4_ISFINITE(lat) && PX4_ISFINITE(lon) to classify the setpoint as valid and enter FW_POSCTRL_MODE_AUTO.
|
||||
// Use current position if available (including during dead-reckoning), otherwise dummy values.
|
||||
if (_navigator->get_local_position()->xy_global) {
|
||||
pos_sp_triplet->current.lat = _navigator->get_global_position()->lat;
|
||||
pos_sp_triplet->current.lon = _navigator->get_global_position()->lon;
|
||||
|
||||
} else {
|
||||
pos_sp_triplet->current.lat = 0.0;
|
||||
pos_sp_triplet->current.lon = 0.0;
|
||||
}
|
||||
|
||||
pos_sp_triplet->current.yaw = NAN;
|
||||
pos_sp_triplet->current.course = course_rad;
|
||||
|
||||
pos_sp_triplet->current.cruising_speed = _navigator->get_cruising_speed();
|
||||
pos_sp_triplet->current.cruising_throttle = NAN;
|
||||
pos_sp_triplet->current.loiter_radius = NAN;
|
||||
pos_sp_triplet->current.acceptance_radius = _navigator->get_acceptance_radius();
|
||||
pos_sp_triplet->current.timestamp = hrt_absolute_time();
|
||||
|
||||
pos_sp_triplet->next.valid = false;
|
||||
|
||||
_navigator->set_position_setpoint_triplet_updated();
|
||||
}
|
||||
|
||||
void
|
||||
MissionBlock::set_land_item(struct mission_item_s *item)
|
||||
{
|
||||
|
||||
@@ -167,6 +167,11 @@ protected:
|
||||
|
||||
void setLoiterItemCommonFields(struct mission_item_s *item);
|
||||
|
||||
/**
|
||||
* Publish a setpoint that holds a course (ground track) at an altitude, without a position target
|
||||
*/
|
||||
void publishCourseHoldSetpoint(float course_rad, float altitude_amsl);
|
||||
|
||||
/**
|
||||
* Set a takeoff mission item
|
||||
*/
|
||||
|
||||
@@ -807,8 +807,15 @@ void Navigator::run()
|
||||
// The yaw setpoint generation is handled by FlightTaskAuto.
|
||||
rep->current.yaw = NAN;
|
||||
|
||||
if (PX4_ISFINITE(cmd.param5) && PX4_ISFINITE(cmd.param6)
|
||||
&& (fabs(cmd.param5) > DBL_EPSILON || fabs(cmd.param6) > DBL_EPSILON)) {
|
||||
const bool takeoff_position_valid = PX4_ISFINITE(cmd.param5) && PX4_ISFINITE(cmd.param6)
|
||||
&& (fabs(cmd.param5) > DBL_EPSILON || fabs(cmd.param6) > DBL_EPSILON);
|
||||
|
||||
// Fixed-wing: without a takeoff position, a finite yaw field is the course to continue on after the climbout.
|
||||
// A takeoff position takes precedence, as many senders leave an unused yaw field at 0.
|
||||
const bool hold_course = PX4_ISFINITE(cmd.param4) && !takeoff_position_valid
|
||||
&& _vstatus.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING;
|
||||
|
||||
if (takeoff_position_valid) {
|
||||
rep->current.lat = cmd.param5;
|
||||
rep->current.lon = cmd.param6;
|
||||
|
||||
@@ -827,8 +834,10 @@ void Navigator::run()
|
||||
rep->next.valid = false;
|
||||
|
||||
// Fixed-wing: vehicle will takeoff towards these coordinates and establish on a loiter there
|
||||
_takeoff.setLoiterPosition(matrix::Vector2d(cmd.param5, cmd.param6));
|
||||
_takeoff.setLoiterPosition(hold_course ? matrix::Vector2d(static_cast<double>(NAN), static_cast<double>(NAN))
|
||||
: matrix::Vector2d(cmd.param5, cmd.param6));
|
||||
_takeoff.setLoiterAltitudeAmsl(cmd.param7);
|
||||
_takeoff.setHoldCourse(hold_course ? matrix::wrap_pi(math::radians(cmd.param4)) : NAN);
|
||||
|
||||
// CMD_NAV_TAKEOFF is acknowledged by commander
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "takeoff.h"
|
||||
#include "navigator.h"
|
||||
#include <px4_platform_common/events.h>
|
||||
#include <matrix/math.hpp>
|
||||
|
||||
Takeoff::Takeoff(Navigator *navigator) :
|
||||
MissionBlock(navigator, vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF)
|
||||
@@ -61,6 +62,12 @@ Takeoff::on_activation()
|
||||
_fw_takeoff_state = fw_takeoff_state::CLIMBOUT; // only used for fixed-wing takeoff
|
||||
}
|
||||
|
||||
void
|
||||
Takeoff::on_inactivation()
|
||||
{
|
||||
_hold_course = NAN; // only applies to the takeoff it was commanded with
|
||||
}
|
||||
|
||||
void
|
||||
Takeoff::on_active()
|
||||
{
|
||||
@@ -70,6 +77,30 @@ Takeoff::on_active()
|
||||
case fw_takeoff_state::CLIMBOUT: {
|
||||
if (_navigator->fw_climbout_completed(_loiter_altitude_msl)) {
|
||||
|
||||
// the climbout does not necessarily end at the takeoff altitude, and the vehicle should
|
||||
// not descend back to it if it ended up higher
|
||||
const float hold_altitude_amsl = math::max(_loiter_altitude_msl, _navigator->get_global_position()->alt);
|
||||
|
||||
if (PX4_ISFINITE(_hold_course)) {
|
||||
if (_navigator->get_local_position()->v_xy_valid) {
|
||||
publishCourseHoldSetpoint(_hold_course, hold_altitude_amsl);
|
||||
|
||||
events::send<float>(events::ID("navigator_takeoff_hold_course"), events::Log::Info,
|
||||
"Takeoff complete, continuing on course {1:.0} deg", math::degrees(matrix::wrap_2pi(_hold_course)));
|
||||
|
||||
_navigator->get_mission_result()->finished = true;
|
||||
_navigator->set_mission_result_updated();
|
||||
|
||||
_loiter_altitude_msl = NAN; // reset for next takeoff command
|
||||
|
||||
_fw_takeoff_state = fw_takeoff_state::COURSE_HANDOVER;
|
||||
break;
|
||||
}
|
||||
|
||||
events::send(events::ID("navigator_takeoff_hold_course_no_velocity"), events::Log::Warning,
|
||||
"No velocity estimate, loitering instead of holding course");
|
||||
}
|
||||
|
||||
setLoiterItemCommonFields(&_mission_item);
|
||||
|
||||
_mission_item.nav_cmd = NAV_CMD_LOITER_TIME_LIMIT;
|
||||
@@ -83,9 +114,7 @@ Takeoff::on_active()
|
||||
_mission_item.loiter_radius = _navigator->get_default_loiter_rad();
|
||||
_mission_item.acceptance_radius = _navigator->get_acceptance_radius();
|
||||
|
||||
// the climbout does not necessarily end at the loiter altitude, and the vehicle should
|
||||
// not descend back to it if it ended up higher
|
||||
_mission_item.altitude = math::max(_loiter_altitude_msl, _navigator->get_global_position()->alt);
|
||||
_mission_item.altitude = hold_altitude_amsl;
|
||||
|
||||
mission_item_to_position_setpoint(_mission_item, &pos_sp_triplet->current);
|
||||
const bool loiter_lat_valid = PX4_ISFINITE(_loiter_position_lat_lon(0))
|
||||
@@ -149,6 +178,10 @@ Takeoff::on_active()
|
||||
break;
|
||||
}
|
||||
|
||||
case fw_takeoff_state::COURSE_HANDOVER:
|
||||
// flying the course until Commander switches to Guided Course, or to Hold if that is not possible
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -52,18 +52,22 @@ public:
|
||||
|
||||
void on_activation() override;
|
||||
void on_active() override;
|
||||
void on_inactivation() override;
|
||||
|
||||
void setLoiterPosition(matrix::Vector2d loiter_location) { _loiter_position_lat_lon = loiter_location; }
|
||||
void setLoiterAltitudeAmsl(const float height_m) { _loiter_altitude_msl = height_m; }
|
||||
void setHoldCourse(const float course_rad) { _hold_course = course_rad; }
|
||||
|
||||
private:
|
||||
|
||||
enum class fw_takeoff_state {
|
||||
CLIMBOUT = 0,
|
||||
GO_TO_LOITER
|
||||
GO_TO_LOITER,
|
||||
COURSE_HANDOVER
|
||||
} _fw_takeoff_state;
|
||||
|
||||
void set_takeoff_position();
|
||||
matrix::Vector2d _loiter_position_lat_lon{static_cast<double>(NAN), static_cast<double>(NAN)};
|
||||
float _loiter_altitude_msl{NAN};
|
||||
float _hold_course{NAN}; ///< [rad] course to hold after the climbout instead of loitering, NaN = loiter
|
||||
};
|
||||
Reference in new issue
Block a user