58 float max_distance_to_1st_waypoint,
float max_distance_between_waypoints,
68 if (!home_alt_valid) {
82 failed = failed || !
checkGeofence(mission, home_alt, home_valid);
91 failed = failed || !
checkFixedwing(mission, home_alt, land_start_req);
115 return (resTakeoff && resLanding);
128 for (
size_t i = 0; i < mission.
count; i++) {
130 const ssize_t len =
sizeof(missionitem);
137 if (missionitem.altitude_is_relative && !home_valid) {
143 missionitem.altitude = missionitem.altitude_is_relative ? missionitem.altitude + home_alt : missionitem.altitude;
161 for (
size_t i = 0; i < mission.
count; i++) {
211 for (
size_t i = 0; i < mission.
count; i++) {
264 if (missionitem.
params[0] < 0 || missionitem.
params[0] > 5) {
266 (int)missionitem.
params[0]);
273 "Actuator value %d is out of bounds -PWM_DEFAULT_MAX..PWM_DEFAULT_MAX", (int)missionitem.
params[1]);
292 bool has_takeoff =
false;
293 bool takeoff_first =
false;
294 int takeoff_index = -1;
296 for (
size_t i = 0; i < mission.
count; i++) {
321 if (takeoff_alt - 1.0
f < acceptance_radius) {
332 takeoff_first =
true;
334 }
else if (takeoff_index == -1) {
341 if (takeoff_index != -1) {
346 for (
size_t i = 0; i < (size_t)takeoff_index; i++) {
355 takeoff_first = !(missionitem.nav_cmd !=
NAV_CMD_IDLE &&
389 }
else if (!takeoff_first) {
408 bool landing_valid =
false;
410 bool land_start_found =
false;
411 size_t do_land_start_index = 0;
412 size_t landing_approach_index = 0;
414 for (
size_t i = 0; i < mission.
count; i++) {
416 const ssize_t len =
sizeof(missionitem);
425 if (land_start_found) {
430 land_start_found =
true;
431 do_land_start_index = i;
439 landing_approach_index = i - 1;
450 const bool landing_status_valid = (landing_status.get().timestamp > 0);
452 missionitem.
lat, missionitem.
lon);
454 if (landing_status_valid && (wp_distance > landing_status.get().flare_length)) {
457 const float delta_altitude = missionitem.
altitude - missionitem_previous.altitude;
459 if (delta_altitude < 0) {
461 const float horizontal_slope_displacement = landing_status.get().horizontal_slope_displacement;
462 const float slope_angle_rad = landing_status.get().slope_angle_rad;
464 horizontal_slope_displacement, slope_angle_rad);
466 if (missionitem_previous.altitude > slope_alt_req + 1.0f) {
471 missionitem.
altitude, horizontal_slope_displacement, slope_angle_rad);
474 (int)ceilf(slope_alt_req - missionitem_previous.altitude),
475 (int)ceilf(wp_distance_req - wp_distance));
492 landing_valid =
true;
507 if (land_start_req && !land_start_found) {
512 if (land_start_found && (!landing_valid || (do_land_start_index > landing_approach_index))) {
524 if (max_distance <= 0.0
f) {
530 for (
size_t i = 0; i < mission.
count; i++) {
547 mission_item.
lat, mission_item.
lon,
550 if (dist_to_1wp < max_distance) {
557 "First waypoint too far away: %d meters, %d max.",
558 (int)dist_to_1wp, (
int)max_distance);
572 if (max_distance <= 0.0
f) {
577 double last_lat = (double)NAN;
578 double last_lon = (double)NAN;
581 for (
size_t i = 0; i < mission.
count; i++) {
597 if (PX4_ISFINITE(last_lat) && PX4_ISFINITE(last_lon)) {
601 mission_item.
lat, mission_item.
lon,
604 if (dist_between_waypoints > max_distance) {
607 "Distance between waypoints too far: %d meters, %d max.",
608 (int)dist_between_waypoints, (
int)max_distance);
615 last_lat = mission_item.
lat;
616 last_lon = mission_item.
lon;
#define PWM_DEFAULT_MAX
Default maximum PWM in us.
#define mavlink_log_info(_pub, _text,...)
Send a mavlink info message (not printed to console).
bool home_position_valid()
Global position setpoint in WGS84 coordinates.
bool checkDistancesBetweenWaypoints(const mission_s &mission, float max_distance)
#define mavlink_log_critical(_pub, _text,...)
Send a mavlink critical message and print to console.
static float getLandingSlopeAbsoluteAltitude(float wp_landing_distance, float wp_landing_altitude, float horizontal_slope_displacement, float landing_slope_angle_rad)
Helper class to access missions.
Definition of geo / math functions to perform geodesic calculations.
float altitude
altitude in meters (AMSL)
float acceptance_radius
default radius in which the mission is accepted as reached in meters
bool checkMissionFeasible(const mission_s &mission, float max_distance_to_1st_waypoint, float max_distance_between_waypoints, bool land_start_req)
float get_distance_to_next_waypoint(double lat_now, double lon_now, double lat_next, double lon_next)
Returns the distance to the next waypoint in meters.
Helper class to use mission items.
struct home_position_s * get_home_position()
Getters.
bool checkFixedwing(const mission_s &mission, float home_alt, bool land_start_req)
dm_item_t
Types of items that the data manager can store.
struct vehicle_land_detected_s * get_land_detected()
Provides checks if mission is feasible given the navigation capabilities.
bool checkRotarywing(const mission_s &mission, float home_alt)
double lon
longitude in degrees
bool get_takeoff_required() const
bool checkTakeoff(const mission_s &mission, float home_alt)
Geofence & get_geofence()
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
__EXPORT ssize_t dm_read(dm_item_t item, unsigned index, void *buf, size_t count)
Retrieve from the data manager file.
bool checkFixedWingLanding(const mission_s &mission, bool land_start_req)
uint16_t nav_cmd
navigation command
bool check(const vehicle_global_position_s &global_position, const vehicle_gps_position_s &gps_position, const home_position_s home_pos, bool home_position_set)
Return whether the system obeys the geofence.
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
bool checkGeofence(const mission_s &mission, float home_alt, bool home_valid)
static float getLandingSlopeWPDistance(float slope_altitude, float wp_landing_altitude, float horizontal_slope_displacement, float landing_slope_angle_rad)
float params[7]
array to store mission command values for MAV_FRAME_MISSION
bool checkHomePositionAltitude(const mission_s &mission, float home_alt, bool home_alt_valid, bool throw_error)
struct mission_result_s * get_mission_result()
#define NAV_EPSILON_POSITION
Anything smaller than this is considered zero.
bool checkMissionItemValidity(const mission_s &mission)
static bool item_contains_position(const mission_item_s &item)
float get_default_acceptance_radius()
Returns the default acceptance radius defined by the parameter.
orb_advert_t * get_mavlink_log_pub()
struct vehicle_status_s * get_vstatus()
bool checkDistanceToFirstWaypoint(const mission_s &mission, float max_distance)
uint16_t altitude_is_relative
true if altitude is relative from start point
double lat
latitude in degrees