VTOL Takeoff: Use VehicleCommand specified heading for VTOL transition (#24040)

* Use VehicleCommand heading for VTOL transition

* options for param2 of vehicle_cmd_nav_vtol_takeoff
This commit is contained in:
Jacopo Panerati 2025-11-25 03:46:48 -05:00 committed by GitHub
parent a6d9e114be
commit 6901bc6a01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 3 deletions

View File

@ -20,7 +20,7 @@ uint16 VEHICLE_CMD_DO_ORBIT = 34 # Start orbiting on the circumference of a circ
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|
uint16 VEHICLE_CMD_NAV_ROI = 80 # Sets the region of interest (ROI) for a sensor set or the vehicle itself. This can then be used by the vehicles control system to control the vehicle attitude and the attitude of various sensors such as cameras. |[@enum VEHICLE_ROI] Region of interest mode.|MISSION index/ target ID.|ROI index (allows a vehicle to manage multiple ROI's)|Unused|x the location of the fixed ROI (see MAV_FRAME)|y|z|
uint16 VEHICLE_CMD_NAV_PATHPLANNING = 81 # Control autonomous path planning on the MAV. |0: Disable local obstacle avoidance / local path planning (without resetting map), 1: Enable local path planning, 2: Enable and reset local path planning|0: Disable full path planning (without resetting map), 1: Enable, 2: Enable and reset map/occupancy grid, 3: Enable and reset planned route, but not occupancy grid|Unused|[deg] [@range 0, 360] Yaw angle at goal, in compass degrees|Latitude/X of goal|Longitude/Y of goal|Altitude/Z of goal|
uint16 VEHICLE_CMD_NAV_VTOL_TAKEOFF = 84 # Takeoff from ground / hand and transition to fixed wing. |Minimum pitch (if airspeed sensor present), desired pitch without sensor|Unused|Unused|Yaw angle (if magnetometer present), ignored without magnetometer|Latitude|Longitude|Altitude|
uint16 VEHICLE_CMD_NAV_VTOL_TAKEOFF = 84 # Takeoff from ground / hand and transition to fixed wing. |Minimum pitch (if airspeed sensor present), desired pitch without sensor|Transition heading, 0: Default, 3: Use specified transition heading|Unused|Yaw angle (if magnetometer present), ignored without magnetometer|Latitude|Longitude|Altitude|
uint16 VEHICLE_CMD_NAV_VTOL_LAND = 85 # Transition to MC and land at location. |Unused|Unused|Unused|Desired yaw angle.|Latitude|Longitude|Altitude|
uint16 VEHICLE_CMD_NAV_GUIDED_LIMITS = 90 # Set limits for external control. |[s] Timeout - maximum time that external controller will be allowed to control vehicle. 0 means no timeout|[m] Absolute altitude min AMSL - if vehicle moves below this alt, the command will be aborted and the mission will continue. 0 means no lower altitude limit|[m] Absolute altitude max - if vehicle moves above this alt, the command will be aborted and the mission will continue. 0 means no upper altitude limit|[m] Horizontal move limit (AMSL) - if vehicle moves more than this distance from it's location at the moment the command was executed, the command will be aborted and the mission will continue. 0 means no horizontal altitude limit|Unused|Unused|Unused|
uint16 VEHICLE_CMD_NAV_GUIDED_MASTER = 91 # Set id of master controller. |System ID|Component ID|Unused|Unused|Unused|Unused|Unused|

View File

@ -652,6 +652,10 @@ void Navigator::run()
_vtol_takeoff.setTransitionAltitudeAbsolute(cmd.param7);
if (std::fabs(cmd.param2 - 3.0f) < FLT_EPSILON) { // Specified transition direction
_vtol_takeoff.setTransitionDirection(cmd.param4);
}
// after the transition the vehicle will establish on a loiter at this position
_vtol_takeoff.setLoiterLocation(matrix::Vector2d(cmd.param5, cmd.param6));

View File

@ -71,8 +71,15 @@ VtolTakeoff::on_active()
position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();
_mission_item.nav_cmd = NAV_CMD_WAYPOINT;
_mission_item.yaw = wrap_pi(get_bearing_to_next_waypoint(_mission_item.lat,
_mission_item.lon, _loiter_location(0), _loiter_location(1)));
if (!PX4_ISFINITE(_transition_direction_deg)) {
_mission_item.yaw = wrap_pi(get_bearing_to_next_waypoint(_navigator->get_home_position()->lat,
_navigator->get_home_position()->lon, _loiter_location(0), _loiter_location(1)));
} else {
_mission_item.yaw = wrap_pi(math::radians(_transition_direction_deg));
}
_mission_item.force_heading = true;
mission_item_to_position_setpoint(_mission_item, &pos_sp_triplet->current);
pos_sp_triplet->current.cruising_speed = -1.f;

View File

@ -55,6 +55,7 @@ public:
void on_active() override;
void setTransitionAltitudeAbsolute(const float alt_amsl) {_transition_alt_amsl = alt_amsl; }
void setTransitionDirection(const float tran_bear) {_transition_direction_deg = tran_bear; }
void setLoiterLocation(matrix::Vector2d loiter_location) { _loiter_location = loiter_location; }
void setLoiterHeight(const float height_m) { _loiter_height = height_m; }
@ -73,6 +74,7 @@ private:
float _takeoff_alt_msl{0.f};
matrix::Vector2d _loiter_location;
float _loiter_height{0};
float _transition_direction_deg{NAN};
DEFINE_PARAMETERS(
(ParamFloat<px4::params::VTO_LOITER_ALT>) _param_loiter_alt