Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

navigator: allow mission items with same position (take 2) #14921

Merged
merged 1 commit into from
May 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/modules/navigator/mission_feasibility_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ MissionFeasibilityChecker::checkDistancesBetweenWaypoints(const mission_s &missi

double last_lat = (double)NAN;
double last_lon = (double)NAN;
float last_alt = NAN;
int last_cmd = 0;

/* Go through all waypoints */
Expand Down Expand Up @@ -715,15 +714,16 @@ MissionFeasibilityChecker::checkDistancesBetweenWaypoints(const mission_s &missi

/* do not allow waypoints that are literally on top of each other */

} else if ((dist_between_waypoints < 0.05f && fabsf(last_alt - mission_item.altitude) < 0.05f) ||
/* and do not allow condition gates that are at the same position as a navigation waypoint */
(dist_between_waypoints < 0.05f && (mission_item.nav_cmd == NAV_CMD_CONDITION_GATE
|| last_cmd == NAV_CMD_CONDITION_GATE))) {
/* waypoints are at the exact same position,
* which indicates an invalid mission and makes calculating
* the direction from one waypoint to another impossible. */
/* and do not allow condition gates that are at the same position as a navigation waypoint */

} else if (dist_between_waypoints < 0.05f &&
(mission_item.nav_cmd == NAV_CMD_CONDITION_GATE || last_cmd == NAV_CMD_CONDITION_GATE)) {

/* Waypoints and gate are at the exact same position, which indicates an
* invalid mission and makes calculating the direction from one waypoint
* to another impossible. */
mavlink_log_critical(_navigator->get_mavlink_log_pub(),
"Distance between waypoints too close: %d meters",
"Distance between waypoint and gate too close: %d meters",
(int)dist_between_waypoints);

_navigator->get_mission_result()->warning = true;
Expand All @@ -733,7 +733,6 @@ MissionFeasibilityChecker::checkDistancesBetweenWaypoints(const mission_s &missi

last_lat = mission_item.lat;
last_lon = mission_item.lon;
last_alt = mission_item.altitude;
last_cmd = mission_item.nav_cmd;
}

Expand Down