mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 08:03:34 +08:00
navigator fix code style
This commit is contained in:
@@ -66,22 +66,22 @@ orb_advert_t actuator_pub_fd;
|
||||
|
||||
MissionBlock::MissionBlock(Navigator *navigator, const char *name) :
|
||||
NavigatorMode(navigator, name),
|
||||
_mission_item({0}),
|
||||
_waypoint_position_reached(false),
|
||||
_waypoint_yaw_reached(false),
|
||||
_time_first_inside_orbit(0),
|
||||
_action_start(0),
|
||||
_time_wp_reached(0),
|
||||
_actuators{},
|
||||
_actuator_pub(nullptr),
|
||||
_cmd_pub(nullptr),
|
||||
_param_loiter_min_alt(this, "MIS_LTRMIN_ALT", false),
|
||||
_param_yaw_timeout(this, "MIS_YAW_TMT", false),
|
||||
_param_yaw_err(this, "MIS_YAW_ERR", false),
|
||||
_param_vtol_wv_land(this, "VT_WV_LND_EN", false),
|
||||
_param_vtol_wv_takeoff(this, "VT_WV_TKO_EN", false),
|
||||
_param_vtol_wv_loiter(this, "VT_WV_LTR_EN", false),
|
||||
_param_force_vtol(this, "NAV_FORCE_VT", false)
|
||||
_mission_item( {0}),
|
||||
_waypoint_position_reached(false),
|
||||
_waypoint_yaw_reached(false),
|
||||
_time_first_inside_orbit(0),
|
||||
_action_start(0),
|
||||
_time_wp_reached(0),
|
||||
_actuators{},
|
||||
_actuator_pub(nullptr),
|
||||
_cmd_pub(nullptr),
|
||||
_param_loiter_min_alt(this, "MIS_LTRMIN_ALT", false),
|
||||
_param_yaw_timeout(this, "MIS_YAW_TMT", false),
|
||||
_param_yaw_err(this, "MIS_YAW_ERR", false),
|
||||
_param_vtol_wv_land(this, "VT_WV_LND_EN", false),
|
||||
_param_vtol_wv_takeoff(this, "VT_WV_TKO_EN", false),
|
||||
_param_vtol_wv_loiter(this, "VT_WV_LTR_EN", false),
|
||||
_param_force_vtol(this, "NAV_FORCE_VT", false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -94,80 +94,83 @@ MissionBlock::is_mission_item_reached()
|
||||
{
|
||||
/* handle non-navigation or indefinite waypoints */
|
||||
switch (_mission_item.nav_cmd) {
|
||||
case NAV_CMD_DO_SET_SERVO:
|
||||
case NAV_CMD_DO_SET_SERVO:
|
||||
return true;
|
||||
|
||||
case NAV_CMD_LAND: /* fall through */
|
||||
case NAV_CMD_VTOL_LAND:
|
||||
return _navigator->get_land_detected()->landed;
|
||||
|
||||
case NAV_CMD_IDLE: /* fall through */
|
||||
case NAV_CMD_LOITER_UNLIMITED:
|
||||
return false;
|
||||
|
||||
case NAV_CMD_DO_LAND_START:
|
||||
case NAV_CMD_DO_DIGICAM_CONTROL:
|
||||
case NAV_CMD_IMAGE_START_CAPTURE:
|
||||
case NAV_CMD_IMAGE_STOP_CAPTURE:
|
||||
case NAV_CMD_VIDEO_START_CAPTURE:
|
||||
case NAV_CMD_VIDEO_STOP_CAPTURE:
|
||||
case NAV_CMD_DO_MOUNT_CONFIGURE:
|
||||
case NAV_CMD_DO_MOUNT_CONTROL:
|
||||
case NAV_CMD_DO_SET_ROI:
|
||||
case NAV_CMD_ROI:
|
||||
case NAV_CMD_DO_SET_CAM_TRIGG_DIST:
|
||||
return true;
|
||||
|
||||
case NAV_CMD_DO_VTOL_TRANSITION:
|
||||
|
||||
/*
|
||||
* We wait half a second to give the transition command time to propagate.
|
||||
* Then monitor the transition status for completion.
|
||||
*/
|
||||
if (hrt_absolute_time() - _action_start > 500000 &&
|
||||
!_navigator->get_vstatus()->in_transition_mode) {
|
||||
|
||||
_action_start = 0;
|
||||
return true;
|
||||
|
||||
case NAV_CMD_LAND: /* fall through */
|
||||
case NAV_CMD_VTOL_LAND:
|
||||
return _navigator->get_land_detected()->landed;
|
||||
|
||||
case NAV_CMD_IDLE: /* fall through */
|
||||
case NAV_CMD_LOITER_UNLIMITED:
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
case NAV_CMD_DO_LAND_START:
|
||||
case NAV_CMD_DO_DIGICAM_CONTROL:
|
||||
case NAV_CMD_IMAGE_START_CAPTURE:
|
||||
case NAV_CMD_IMAGE_STOP_CAPTURE:
|
||||
case NAV_CMD_VIDEO_START_CAPTURE:
|
||||
case NAV_CMD_VIDEO_STOP_CAPTURE:
|
||||
case NAV_CMD_DO_MOUNT_CONFIGURE:
|
||||
case NAV_CMD_DO_MOUNT_CONTROL:
|
||||
case NAV_CMD_DO_SET_ROI:
|
||||
case NAV_CMD_ROI:
|
||||
case NAV_CMD_DO_SET_CAM_TRIGG_DIST:
|
||||
return true;
|
||||
case NAV_CMD_DO_CHANGE_SPEED:
|
||||
return true;
|
||||
|
||||
case NAV_CMD_DO_VTOL_TRANSITION:
|
||||
/*
|
||||
* We wait half a second to give the transition command time to propagate.
|
||||
* Then monitor the transition status for completion.
|
||||
*/
|
||||
if (hrt_absolute_time() - _action_start > 500000 &&
|
||||
!_navigator->get_vstatus()->in_transition_mode) {
|
||||
|
||||
_action_start = 0;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
case NAV_CMD_DO_CHANGE_SPEED:
|
||||
return true;
|
||||
|
||||
default:
|
||||
/* do nothing, this is a 3D waypoint */
|
||||
break;
|
||||
default:
|
||||
/* do nothing, this is a 3D waypoint */
|
||||
break;
|
||||
}
|
||||
|
||||
hrt_abstime now = hrt_absolute_time();
|
||||
|
||||
if ((_navigator->get_land_detected()->landed == false)
|
||||
&& !_waypoint_position_reached) {
|
||||
&& !_waypoint_position_reached) {
|
||||
|
||||
float dist = -1.0f;
|
||||
float dist_xy = -1.0f;
|
||||
float dist_z = -1.0f;
|
||||
|
||||
float altitude_amsl = _mission_item.altitude_is_relative
|
||||
? _mission_item.altitude + _navigator->get_home_position()->alt
|
||||
: _mission_item.altitude;
|
||||
? _mission_item.altitude + _navigator->get_home_position()->alt
|
||||
: _mission_item.altitude;
|
||||
|
||||
dist = get_distance_to_point_global_wgs84(_mission_item.lat, _mission_item.lon, altitude_amsl,
|
||||
_navigator->get_global_position()->lat,
|
||||
_navigator->get_global_position()->lon,
|
||||
_navigator->get_global_position()->alt,
|
||||
&dist_xy, &dist_z);
|
||||
_navigator->get_global_position()->lat,
|
||||
_navigator->get_global_position()->lon,
|
||||
_navigator->get_global_position()->alt,
|
||||
&dist_xy, &dist_z);
|
||||
|
||||
/* FW special case for NAV_CMD_WAYPOINT to achieve altitude via loiter */
|
||||
if (!_navigator->get_vstatus()->is_rotary_wing &&
|
||||
(_mission_item.nav_cmd == NAV_CMD_WAYPOINT)) {
|
||||
(_mission_item.nav_cmd == NAV_CMD_WAYPOINT)) {
|
||||
|
||||
struct position_setpoint_s *curr_sp = &_navigator->get_position_setpoint_triplet()->current;
|
||||
|
||||
/* close to waypoint, but altitude error greater than twice acceptance */
|
||||
if ((dist >= 0.0f)
|
||||
&& (dist_z > 2 * _navigator->get_altitude_acceptance_radius())
|
||||
&& (dist_xy < 2 * _navigator->get_loiter_radius())) {
|
||||
&& (dist_z > 2 * _navigator->get_altitude_acceptance_radius())
|
||||
&& (dist_xy < 2 * _navigator->get_loiter_radius())) {
|
||||
|
||||
/* SETPOINT_TYPE_POSITION -> SETPOINT_TYPE_LOITER */
|
||||
if (curr_sp->type == position_setpoint_s::SETPOINT_TYPE_POSITION) {
|
||||
@@ -176,13 +179,14 @@ MissionBlock::is_mission_item_reached()
|
||||
curr_sp->loiter_direction = 1;
|
||||
_navigator->set_position_setpoint_triplet_updated();
|
||||
}
|
||||
|
||||
} else {
|
||||
/* restore SETPOINT_TYPE_POSITION */
|
||||
if (curr_sp->type == position_setpoint_s::SETPOINT_TYPE_LOITER) {
|
||||
/* loiter acceptance criteria required to revert back to SETPOINT_TYPE_POSITION */
|
||||
if ((dist >= 0.0f)
|
||||
&& (dist_z < _navigator->get_loiter_radius())
|
||||
&& (dist_xy <= _navigator->get_loiter_radius() * 1.2f)) {
|
||||
&& (dist_z < _navigator->get_loiter_radius())
|
||||
&& (dist_xy <= _navigator->get_loiter_radius() * 1.2f)) {
|
||||
|
||||
curr_sp->type = position_setpoint_s::SETPOINT_TYPE_POSITION;
|
||||
_navigator->set_position_setpoint_triplet_updated();
|
||||
@@ -192,7 +196,7 @@ MissionBlock::is_mission_item_reached()
|
||||
}
|
||||
|
||||
if ((_mission_item.nav_cmd == NAV_CMD_TAKEOFF || _mission_item.nav_cmd == NAV_CMD_VTOL_TAKEOFF)
|
||||
&& _navigator->get_vstatus()->is_rotary_wing) {
|
||||
&& _navigator->get_vstatus()->is_rotary_wing) {
|
||||
|
||||
/* We want to avoid the edge case where the acceptance radius is bigger or equal than
|
||||
* the altitude of the takeoff waypoint above home. Otherwise, we do not really follow
|
||||
@@ -211,18 +215,20 @@ MissionBlock::is_mission_item_reached()
|
||||
|
||||
/* require only altitude for takeoff for multicopter */
|
||||
if (_navigator->get_global_position()->alt >
|
||||
altitude_amsl - altitude_acceptance_radius) {
|
||||
altitude_amsl - altitude_acceptance_radius) {
|
||||
_waypoint_position_reached = true;
|
||||
}
|
||||
|
||||
} else if (_mission_item.nav_cmd == NAV_CMD_TAKEOFF) {
|
||||
/* for takeoff mission items use the parameter for the takeoff acceptance radius */
|
||||
if (dist >= 0.0f && dist <= _navigator->get_acceptance_radius()
|
||||
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
|
||||
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
|
||||
_waypoint_position_reached = true;
|
||||
}
|
||||
|
||||
} else if (!_navigator->get_vstatus()->is_rotary_wing &&
|
||||
(_mission_item.nav_cmd == NAV_CMD_LOITER_UNLIMITED ||
|
||||
_mission_item.nav_cmd == NAV_CMD_LOITER_TIME_LIMIT)) {
|
||||
(_mission_item.nav_cmd == NAV_CMD_LOITER_UNLIMITED ||
|
||||
_mission_item.nav_cmd == NAV_CMD_LOITER_TIME_LIMIT)) {
|
||||
/* Loiter mission item on a non rotary wing: the aircraft is going to circle the
|
||||
* coordinates with a radius equal to the loiter_radius field. It is not flying
|
||||
* through the waypoint center.
|
||||
@@ -230,15 +236,16 @@ MissionBlock::is_mission_item_reached()
|
||||
* radius (+ some margin). Time inside and turn count is handled elsewhere.
|
||||
*/
|
||||
if (dist >= 0.0f && dist <= _navigator->get_acceptance_radius(fabsf(_mission_item.loiter_radius) * 1.2f)
|
||||
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
|
||||
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
|
||||
|
||||
_waypoint_position_reached = true;
|
||||
|
||||
} else {
|
||||
_time_first_inside_orbit = 0;
|
||||
}
|
||||
|
||||
} else if (!_navigator->get_vstatus()->is_rotary_wing &&
|
||||
(_mission_item.nav_cmd == NAV_CMD_LOITER_TO_ALT)) {
|
||||
(_mission_item.nav_cmd == NAV_CMD_LOITER_TO_ALT)) {
|
||||
|
||||
|
||||
// NAV_CMD_LOITER_TO_ALT only uses mission item altitude once it's in the loiter
|
||||
@@ -252,13 +259,13 @@ MissionBlock::is_mission_item_reached()
|
||||
dist_z = -1.0f;
|
||||
|
||||
dist = get_distance_to_point_global_wgs84(_mission_item.lat, _mission_item.lon, curr_sp->alt,
|
||||
_navigator->get_global_position()->lat,
|
||||
_navigator->get_global_position()->lon,
|
||||
_navigator->get_global_position()->alt,
|
||||
&dist_xy, &dist_z);
|
||||
_navigator->get_global_position()->lat,
|
||||
_navigator->get_global_position()->lon,
|
||||
_navigator->get_global_position()->alt,
|
||||
&dist_xy, &dist_z);
|
||||
|
||||
if (dist >= 0.0f && dist <= _navigator->get_acceptance_radius(fabsf(_mission_item.loiter_radius) * 1.2f)
|
||||
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
|
||||
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
|
||||
|
||||
// now set the loiter to the final altitude in the NAV_CMD_LOITER_TO_ALT mission item
|
||||
curr_sp->alt = altitude_amsl;
|
||||
@@ -267,7 +274,7 @@ MissionBlock::is_mission_item_reached()
|
||||
|
||||
} else {
|
||||
if (dist >= 0.0f && dist <= _navigator->get_acceptance_radius(fabsf(_mission_item.loiter_radius) * 1.2f)
|
||||
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
|
||||
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
|
||||
|
||||
_waypoint_position_reached = true;
|
||||
|
||||
@@ -277,16 +284,18 @@ MissionBlock::is_mission_item_reached()
|
||||
|
||||
if (next_sp.valid) {
|
||||
_mission_item.yaw = get_bearing_to_next_waypoint(_navigator->get_global_position()->lat,
|
||||
_navigator->get_global_position()->lon,
|
||||
next_sp.lat, next_sp.lon);
|
||||
_navigator->get_global_position()->lon,
|
||||
next_sp.lat, next_sp.lon);
|
||||
|
||||
_waypoint_yaw_reached = false;
|
||||
|
||||
} else {
|
||||
_waypoint_yaw_reached = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
/* for normal mission items used their acceptance radius */
|
||||
float mission_acceptance_radius = _navigator->get_acceptance_radius(_mission_item.acceptance_radius);
|
||||
@@ -297,7 +306,7 @@ MissionBlock::is_mission_item_reached()
|
||||
}
|
||||
|
||||
if (dist >= 0.0f && dist <= mission_acceptance_radius
|
||||
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
|
||||
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
|
||||
_waypoint_position_reached = true;
|
||||
}
|
||||
}
|
||||
@@ -313,23 +322,23 @@ MissionBlock::is_mission_item_reached()
|
||||
if (_waypoint_position_reached && !_waypoint_yaw_reached) {
|
||||
|
||||
if ((_navigator->get_vstatus()->is_rotary_wing
|
||||
|| (_mission_item.nav_cmd == NAV_CMD_LOITER_TO_ALT && _mission_item.force_heading))
|
||||
&& PX4_ISFINITE(_mission_item.yaw)) {
|
||||
|| (_mission_item.nav_cmd == NAV_CMD_LOITER_TO_ALT && _mission_item.force_heading))
|
||||
&& PX4_ISFINITE(_mission_item.yaw)) {
|
||||
|
||||
/* check yaw if defined only for rotary wing except takeoff */
|
||||
float yaw_err = _wrap_pi(_mission_item.yaw - _navigator->get_global_position()->yaw);
|
||||
|
||||
/* accept yaw if reached or if timeout is set in which case we ignore not forced headings */
|
||||
if (fabsf(yaw_err) < math::radians(_param_yaw_err.get())
|
||||
|| (_param_yaw_timeout.get() >= FLT_EPSILON && !_mission_item.force_heading)) {
|
||||
|| (_param_yaw_timeout.get() >= FLT_EPSILON && !_mission_item.force_heading)) {
|
||||
|
||||
_waypoint_yaw_reached = true;
|
||||
}
|
||||
|
||||
/* if heading needs to be reached, the timeout is enabled and we don't make it, abort mission */
|
||||
if (!_waypoint_yaw_reached && _mission_item.force_heading &&
|
||||
(_param_yaw_timeout.get() >= FLT_EPSILON) &&
|
||||
(now - _time_wp_reached >= (hrt_abstime)_param_yaw_timeout.get() * 1e6f)) {
|
||||
(_param_yaw_timeout.get() >= FLT_EPSILON) &&
|
||||
(now - _time_wp_reached >= (hrt_abstime)_param_yaw_timeout.get() * 1e6f)) {
|
||||
|
||||
_navigator->set_mission_failure("unable to reach heading within timeout");
|
||||
}
|
||||
@@ -348,12 +357,12 @@ MissionBlock::is_mission_item_reached()
|
||||
|
||||
/* check if the MAV was long enough inside the waypoint orbit */
|
||||
if ((Navigator::get_time_inside(_mission_item) < FLT_EPSILON) ||
|
||||
(now - _time_first_inside_orbit >= (hrt_abstime)(Navigator::get_time_inside(_mission_item) * 1e6f))) {
|
||||
(now - _time_first_inside_orbit >= (hrt_abstime)(Navigator::get_time_inside(_mission_item) * 1e6f))) {
|
||||
|
||||
// exit xtrack location
|
||||
if (_mission_item.loiter_exit_xtrack &&
|
||||
(_mission_item.nav_cmd == NAV_CMD_LOITER_TIME_LIMIT ||
|
||||
_mission_item.nav_cmd == NAV_CMD_LOITER_TO_ALT)) {
|
||||
(_mission_item.nav_cmd == NAV_CMD_LOITER_TIME_LIMIT ||
|
||||
_mission_item.nav_cmd == NAV_CMD_LOITER_TO_ALT)) {
|
||||
|
||||
// reset lat/lon of loiter waypoint so vehicle exits on a tangent
|
||||
struct position_setpoint_s *curr_sp = &_navigator->get_position_setpoint_triplet()->current;
|
||||
@@ -399,15 +408,16 @@ MissionBlock::mission_item_to_vehicle_command(const struct mission_item_s *item,
|
||||
// The camera commands are not processed on the autopilot but will be
|
||||
// sent to the mavlink links to other components.
|
||||
switch (item->nav_cmd) {
|
||||
case NAV_CMD_IMAGE_START_CAPTURE:
|
||||
case NAV_CMD_IMAGE_STOP_CAPTURE:
|
||||
case NAV_CMD_VIDEO_START_CAPTURE:
|
||||
case NAV_CMD_VIDEO_STOP_CAPTURE:
|
||||
cmd->target_component = 100; // MAV_COMP_ID_CAMERA
|
||||
break;
|
||||
default:
|
||||
cmd->target_component = _navigator->get_vstatus()->component_id;
|
||||
break;
|
||||
case NAV_CMD_IMAGE_START_CAPTURE:
|
||||
case NAV_CMD_IMAGE_STOP_CAPTURE:
|
||||
case NAV_CMD_VIDEO_START_CAPTURE:
|
||||
case NAV_CMD_VIDEO_STOP_CAPTURE:
|
||||
cmd->target_component = 100; // MAV_COMP_ID_CAMERA
|
||||
break;
|
||||
|
||||
default:
|
||||
cmd->target_component = _navigator->get_vstatus()->component_id;
|
||||
break;
|
||||
}
|
||||
|
||||
cmd->source_system = _navigator->get_vstatus()->system_id;
|
||||
@@ -463,20 +473,20 @@ MissionBlock::item_contains_position(const struct mission_item_s *item)
|
||||
{
|
||||
// XXX: maybe extend that check onto item properties
|
||||
if (item->nav_cmd == NAV_CMD_DO_JUMP ||
|
||||
item->nav_cmd == NAV_CMD_DO_CHANGE_SPEED ||
|
||||
item->nav_cmd == NAV_CMD_DO_SET_SERVO ||
|
||||
item->nav_cmd == NAV_CMD_DO_LAND_START ||
|
||||
item->nav_cmd == NAV_CMD_DO_DIGICAM_CONTROL ||
|
||||
item->nav_cmd == NAV_CMD_IMAGE_START_CAPTURE ||
|
||||
item->nav_cmd == NAV_CMD_IMAGE_STOP_CAPTURE ||
|
||||
item->nav_cmd == NAV_CMD_VIDEO_START_CAPTURE ||
|
||||
item->nav_cmd == NAV_CMD_VIDEO_STOP_CAPTURE ||
|
||||
item->nav_cmd == NAV_CMD_DO_MOUNT_CONFIGURE ||
|
||||
item->nav_cmd == NAV_CMD_DO_MOUNT_CONTROL ||
|
||||
item->nav_cmd == NAV_CMD_DO_SET_ROI ||
|
||||
item->nav_cmd == NAV_CMD_ROI ||
|
||||
item->nav_cmd == NAV_CMD_DO_SET_CAM_TRIGG_DIST ||
|
||||
item->nav_cmd == NAV_CMD_DO_VTOL_TRANSITION) {
|
||||
item->nav_cmd == NAV_CMD_DO_CHANGE_SPEED ||
|
||||
item->nav_cmd == NAV_CMD_DO_SET_SERVO ||
|
||||
item->nav_cmd == NAV_CMD_DO_LAND_START ||
|
||||
item->nav_cmd == NAV_CMD_DO_DIGICAM_CONTROL ||
|
||||
item->nav_cmd == NAV_CMD_IMAGE_START_CAPTURE ||
|
||||
item->nav_cmd == NAV_CMD_IMAGE_STOP_CAPTURE ||
|
||||
item->nav_cmd == NAV_CMD_VIDEO_START_CAPTURE ||
|
||||
item->nav_cmd == NAV_CMD_VIDEO_STOP_CAPTURE ||
|
||||
item->nav_cmd == NAV_CMD_DO_MOUNT_CONFIGURE ||
|
||||
item->nav_cmd == NAV_CMD_DO_MOUNT_CONTROL ||
|
||||
item->nav_cmd == NAV_CMD_DO_SET_ROI ||
|
||||
item->nav_cmd == NAV_CMD_ROI ||
|
||||
item->nav_cmd == NAV_CMD_DO_SET_CAM_TRIGG_DIST ||
|
||||
item->nav_cmd == NAV_CMD_DO_VTOL_TRANSITION) {
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -497,7 +507,7 @@ MissionBlock::mission_item_to_position_setpoint(const struct mission_item_s *ite
|
||||
sp->alt = item->altitude_is_relative ? item->altitude + _navigator->get_home_position()->alt : item->altitude;
|
||||
sp->yaw = item->yaw;
|
||||
sp->loiter_radius = (fabsf(item->loiter_radius) > NAV_EPSILON_POSITION) ? fabsf(item->loiter_radius) :
|
||||
_navigator->get_loiter_radius();
|
||||
_navigator->get_loiter_radius();
|
||||
sp->loiter_direction = (item->loiter_radius > 0) ? 1 : -1;
|
||||
sp->acceptance_radius = item->acceptance_radius;
|
||||
sp->disable_mc_yaw_control = item->disable_mc_yaw;
|
||||
@@ -514,33 +524,40 @@ MissionBlock::mission_item_to_position_setpoint(const struct mission_item_s *ite
|
||||
// set pitch and ensure that the hold time is zero
|
||||
sp->pitch_min = item->pitch_min;
|
||||
|
||||
// fall through
|
||||
// fall through
|
||||
case NAV_CMD_VTOL_TAKEOFF:
|
||||
sp->type = position_setpoint_s::SETPOINT_TYPE_TAKEOFF;
|
||||
if(_navigator->get_vstatus()->is_vtol && _param_vtol_wv_takeoff.get()){
|
||||
|
||||
if (_navigator->get_vstatus()->is_vtol && _param_vtol_wv_takeoff.get()) {
|
||||
sp->disable_mc_yaw_control = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case NAV_CMD_LAND:
|
||||
case NAV_CMD_VTOL_LAND:
|
||||
sp->type = position_setpoint_s::SETPOINT_TYPE_LAND;
|
||||
|
||||
if (_navigator->get_vstatus()->is_vtol && _param_vtol_wv_land.get()) {
|
||||
sp->disable_mc_yaw_control = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case NAV_CMD_LOITER_TO_ALT:
|
||||
// initially use current altitude, and switch to mission item altitude once in loiter position
|
||||
sp->alt = math::max(_navigator->get_global_position()->alt, _navigator->get_home_position()->alt + _param_loiter_min_alt.get());
|
||||
sp->alt = math::max(_navigator->get_global_position()->alt,
|
||||
_navigator->get_home_position()->alt + _param_loiter_min_alt.get());
|
||||
|
||||
// fall through
|
||||
// fall through
|
||||
case NAV_CMD_LOITER_TIME_LIMIT:
|
||||
case NAV_CMD_LOITER_UNLIMITED:
|
||||
sp->type = position_setpoint_s::SETPOINT_TYPE_LOITER;
|
||||
|
||||
if (_navigator->get_vstatus()->is_vtol && _param_vtol_wv_loiter.get()) {
|
||||
sp->disable_mc_yaw_control = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -601,7 +618,8 @@ MissionBlock::set_loiter_item(struct mission_item_s *item, float min_clearance)
|
||||
}
|
||||
|
||||
void
|
||||
MissionBlock::set_follow_target_item(struct mission_item_s *item, float min_clearance, follow_target_s & target, float yaw)
|
||||
MissionBlock::set_follow_target_item(struct mission_item_s *item, float min_clearance, follow_target_s &target,
|
||||
float yaw)
|
||||
{
|
||||
if (_navigator->get_land_detected()->landed) {
|
||||
/* landed, don't takeoff, but switch to IDLE mode */
|
||||
@@ -619,6 +637,7 @@ MissionBlock::set_follow_target_item(struct mission_item_s *item, float min_clea
|
||||
|
||||
if (min_clearance > 8.0f) {
|
||||
item->altitude += min_clearance;
|
||||
|
||||
} else {
|
||||
item->altitude += 8.0f; // if min clearance is bad set it to 8.0 meters (well above the average height of a person)
|
||||
}
|
||||
@@ -658,12 +677,14 @@ MissionBlock::set_land_item(struct mission_item_s *item, bool at_current_locatio
|
||||
|
||||
/* VTOL transition to RW before landing */
|
||||
if (_navigator->get_vstatus()->is_vtol && !_navigator->get_vstatus()->is_rotary_wing &&
|
||||
_param_force_vtol.get() == 1) {
|
||||
_param_force_vtol.get() == 1) {
|
||||
struct vehicle_command_s cmd = {};
|
||||
cmd.command = NAV_CMD_DO_VTOL_TRANSITION;
|
||||
cmd.param1 = vtol_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_queue(ORB_ID(vehicle_command), &cmd, vehicle_command_s::ORB_QUEUE_LENGTH);
|
||||
}
|
||||
@@ -678,7 +699,8 @@ MissionBlock::set_land_item(struct mission_item_s *item, bool at_current_locatio
|
||||
item->lon = _navigator->get_global_position()->lon;
|
||||
item->yaw = _navigator->get_global_position()->yaw;
|
||||
|
||||
/* use home position */
|
||||
/* use home position */
|
||||
|
||||
} else {
|
||||
item->lat = _navigator->get_home_position()->lat;
|
||||
item->lon = _navigator->get_home_position()->lon;
|
||||
|
||||
Reference in New Issue
Block a user