Skip to content

Commit

Permalink
FeasibilityChecker: only warn when first waypoint is too far, but sti…
Browse files Browse the repository at this point in the history
…ll accept mission as valid
  • Loading branch information
KonradRudin committed Aug 19, 2024
1 parent 7e45f49 commit 47d2363
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
12 changes: 5 additions & 7 deletions src/modules/navigator/MissionFeasibility/FeasibilityChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ void FeasibilityChecker::reset()
_mission_validity_failed = false;
_takeoff_failed = false;
_land_pattern_validity_failed = false;
_distance_first_waypoint_failed = false;
_distance_between_waypoints_failed = false;
_fixed_wing_land_approach_failed = false;
_takeoff_land_available_failed = false;
Expand Down Expand Up @@ -199,8 +198,8 @@ void FeasibilityChecker::doCommonChecks(mission_item_s &mission_item, const int
_distance_between_waypoints_failed = !checkDistancesBetweenWaypoints(mission_item);
}

if (!_distance_first_waypoint_failed) {
_distance_first_waypoint_failed = !checkHorizontalDistanceToFirstWaypoint(mission_item);
if (!_first_waypoint_found) {
checkHorizontalDistanceToFirstWaypoint(mission_item);
}

if (!_takeoff_failed) {
Expand Down Expand Up @@ -631,7 +630,7 @@ bool FeasibilityChecker::hasMissionBothOrNeitherTakeoffAndLanding()
bool FeasibilityChecker::checkHorizontalDistanceToFirstWaypoint(mission_item_s &mission_item)
{
if (_param_mis_dist_1wp > FLT_EPSILON &&
(_current_position_lat_lon.isAllFinite()) && !_first_waypoint_found &&
(_current_position_lat_lon.isAllFinite()) &&
MissionBlock::item_contains_position(mission_item)) {

_first_waypoint_found = true;
Expand All @@ -653,9 +652,8 @@ bool FeasibilityChecker::checkHorizontalDistanceToFirstWaypoint(mission_item_s &
mavlink_log_critical(_mavlink_log_pub,
"First waypoint too far away: %dm, %d max\t",
(int)dist_to_1wp_from_current_pos, (int)_param_mis_dist_1wp);
events::send<uint32_t, uint32_t>(events::ID("navigator_mis_first_wp_too_far"), {events::Log::Error, events::LogInternal::Info},
"First waypoint too far away: {1m} (maximum: {2m})", (uint32_t)dist_to_1wp_from_current_pos,
(uint32_t)_param_mis_dist_1wp);
events::send<uint32_t>(events::ID("navigator_mis_first_wp_far"), {events::Log::Warning, events::LogInternal::Info},
"First waypoint far away: {1m} Correct mission loaded?", (uint32_t)dist_to_1wp_from_current_pos);

return false;
}
Expand Down
12 changes: 5 additions & 7 deletions src/modules/navigator/MissionFeasibility/FeasibilityChecker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,13 @@ class FeasibilityChecker : public ModuleParams
bool someCheckFailed()
{
return _takeoff_failed ||
_distance_first_waypoint_failed ||
_distance_between_waypoints_failed ||
_land_pattern_validity_failed ||
_fixed_wing_land_approach_failed ||
_mission_validity_failed ||
_takeoff_land_available_failed;
}

/**
* @brief Reset all data
*/
void reset();

private:
orb_advert_t *_mavlink_log_pub{nullptr};

Expand All @@ -117,7 +111,6 @@ class FeasibilityChecker : public ModuleParams
bool _mission_validity_failed{false};
bool _takeoff_failed{false};
bool _land_pattern_validity_failed{false};
bool _distance_first_waypoint_failed{false};
bool _distance_between_waypoints_failed{false};
bool _fixed_wing_land_approach_failed{false};
bool _takeoff_land_available_failed{false};
Expand All @@ -142,6 +135,11 @@ class FeasibilityChecker : public ModuleParams
double _last_lon{(double)NAN};
int _last_cmd{-1};

/**
* @brief Reset all data
*/
void reset();

/**
* @brief Update data from external topics, e.g home position
*/
Expand Down
1 change: 0 additions & 1 deletion src/modules/navigator/mission_feasibility_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
*/

#include "mission_feasibility_checker.h"
#include "MissionFeasibility/FeasibilityChecker.hpp"

#include "mission_block.h"
#include "navigator.h"
Expand Down

0 comments on commit 47d2363

Please sign in to comment.