mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-01 01:00:35 +08:00
Implemented VTOL_TAKEOFF and VTOL_LAND commands
This commit is contained in:
@@ -865,6 +865,7 @@ MavlinkMissionManager::format_mavlink_mission_item(const struct mission_item_s *
|
||||
// specific item handling
|
||||
switch (mission_item->nav_cmd) {
|
||||
case NAV_CMD_TAKEOFF:
|
||||
case NAV_CMD_VTOL_TAKEOFF:
|
||||
mavlink_mission_item->param1 = mission_item->pitch_min;
|
||||
break;
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/topics/mission.h>
|
||||
#include <uORB/topics/mission_result.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
|
||||
#include "mission.h"
|
||||
#include "navigator.h"
|
||||
@@ -77,6 +78,7 @@ Mission::Mission(Navigator *navigator, const char *name) :
|
||||
_current_onboard_mission_index(-1),
|
||||
_current_offboard_mission_index(-1),
|
||||
_need_takeoff(true),
|
||||
_takeoff_vtol_transition(false),
|
||||
_mission_type(MISSION_TYPE_NONE),
|
||||
_inited(false),
|
||||
_home_inited(false),
|
||||
@@ -460,7 +462,21 @@ Mission::set_mission_items()
|
||||
}
|
||||
|
||||
/* if we just did a takeoff navigate to the actual waypoint now */
|
||||
if (_work_item_type == WORK_ITEM_TYPE_TAKEOFF) {
|
||||
if (_work_item_type == WORK_ITEM_TYPE_TAKEOFF) {
|
||||
|
||||
/* handle VTOL TAKEOFF command */
|
||||
if(_takeoff_vtol_transition){
|
||||
struct vehicle_command_s cmd = {};
|
||||
cmd.command = NAV_CMD_DO_VTOL_TRANSITION;
|
||||
cmd.param1 = vehicle_status_s::VEHICLE_VTOL_STATE_FW;
|
||||
if (_cmd_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_command), _cmd_pub, &cmd);
|
||||
} else {
|
||||
_cmd_pub = orb_advertise(ORB_ID(vehicle_command), &cmd);
|
||||
}
|
||||
_takeoff_vtol_transition = false;
|
||||
}
|
||||
|
||||
new_work_item_type = WORK_ITEM_TYPE_DEFAULT;
|
||||
_mission_item.nav_cmd = NAV_CMD_WAYPOINT;
|
||||
/* ignore yaw here, otherwise it might yaw before heading_sp_update takes over */
|
||||
@@ -647,11 +663,16 @@ Mission::do_need_takeoff()
|
||||
if (_need_takeoff && (
|
||||
_mission_item.nav_cmd == NAV_CMD_TAKEOFF ||
|
||||
_mission_item.nav_cmd == NAV_CMD_WAYPOINT ||
|
||||
_mission_item.nav_cmd == NAV_CMD_VTOL_TAKEOFF ||
|
||||
_mission_item.nav_cmd == NAV_CMD_LOITER_TIME_LIMIT ||
|
||||
_mission_item.nav_cmd == NAV_CMD_LOITER_TURN_COUNT ||
|
||||
_mission_item.nav_cmd == NAV_CMD_LOITER_UNLIMITED ||
|
||||
_mission_item.nav_cmd == NAV_CMD_RETURN_TO_LAUNCH)) {
|
||||
|
||||
if(_mission_item.nav_cmd == NAV_CMD_VTOL_TAKEOFF){
|
||||
_takeoff_vtol_transition = true;
|
||||
}
|
||||
|
||||
_need_takeoff = false;
|
||||
return true;
|
||||
}
|
||||
@@ -663,6 +684,18 @@ Mission::do_need_takeoff()
|
||||
bool
|
||||
Mission::do_need_move_to_land()
|
||||
{
|
||||
if(_mission_item.nav_cmd == NAV_CMD_VTOL_LAND){
|
||||
struct vehicle_command_s cmd = {};
|
||||
cmd.command = NAV_CMD_DO_VTOL_TRANSITION;
|
||||
cmd.param1 = vehicle_status_s::VEHICLE_VTOL_STATE_MC;
|
||||
if (_cmd_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_command), _cmd_pub, &cmd);
|
||||
} else {
|
||||
_cmd_pub = orb_advertise(ORB_ID(vehicle_command), &cmd);
|
||||
}
|
||||
_mission_item.nav_cmd = NAV_CMD_LAND;
|
||||
}
|
||||
|
||||
if (_navigator->get_vstatus()->is_rotary_wing && _mission_item.nav_cmd == NAV_CMD_LAND) {
|
||||
|
||||
float d_current = get_distance_to_next_waypoint(_mission_item.lat, _mission_item.lon,
|
||||
|
||||
@@ -225,6 +225,7 @@ private:
|
||||
int _current_onboard_mission_index;
|
||||
int _current_offboard_mission_index;
|
||||
bool _need_takeoff; /**< if true, then takeoff must be performed before going to the first waypoint (if needed) */
|
||||
bool _takeoff_vtol_transition; /**< if true, a vtol transition will be performed after takeoff */
|
||||
|
||||
enum {
|
||||
MISSION_TYPE_NONE,
|
||||
|
||||
@@ -242,6 +242,8 @@ bool MissionFeasibilityChecker::checkMissionItemValidity(dm_item_t dm_current, s
|
||||
missionitem.nav_cmd != NAV_CMD_LOITER_TIME_LIMIT &&
|
||||
missionitem.nav_cmd != NAV_CMD_LAND &&
|
||||
missionitem.nav_cmd != NAV_CMD_TAKEOFF &&
|
||||
missionitem.nav_cmd != NAV_CMD_VTOL_LAND &&
|
||||
missionitem.nav_cmd != NAV_CMD_VTOL_TAKEOFF &&
|
||||
missionitem.nav_cmd != NAV_CMD_PATHPLANNING &&
|
||||
missionitem.nav_cmd != NAV_CMD_DO_JUMP &&
|
||||
missionitem.nav_cmd != NAV_CMD_DO_SET_SERVO &&
|
||||
|
||||
@@ -63,6 +63,8 @@ enum NAV_CMD {
|
||||
NAV_CMD_PATHPLANNING = 81,
|
||||
NAV_CMD_FOLLOW_TARGET = 194, // temporary placeholder
|
||||
NAV_CMD_GOTO_TAREGT = 195,
|
||||
NAV_CMD_VTOL_TAKEOFF = 84,
|
||||
NAV_CMD_VTOL_LAND = 85,
|
||||
NAV_CMD_DO_JUMP = 177,
|
||||
NAV_CMD_DO_CHANGE_SPEED = 178,
|
||||
NAV_CMD_DO_SET_SERVO=183,
|
||||
|
||||
Reference in New Issue
Block a user