AC_Avoid: Check if origin is set before any obstacle avoidance algorithm is run

This commit is contained in:
Rishabh 2020-06-16 16:47:16 +05:30 committed by Randy Mackay
parent 8d2f2443a2
commit 34b17d0993
2 changed files with 12 additions and 11 deletions

View File

@ -37,16 +37,6 @@ AP_OADijkstra::AP_OADijkstra() :
// returns DIJKSTRA_STATE_SUCCESS and populates origin_new and destination_new if avoidance is required
AP_OADijkstra::AP_OADijkstra_State AP_OADijkstra::update(const Location &current_loc, const Location &destination, Location& origin_new, Location& destination_new)
{
// require ekf origin to have been set
struct Location ekf_origin {};
{
WITH_SEMAPHORE(AP::ahrs().get_semaphore());
if (!AP::ahrs().get_origin(ekf_origin)) {
AP::logger().Write_OADijkstra(DIJKSTRA_STATE_NOT_REQUIRED, 0, 0, 0, destination, destination);
return DIJKSTRA_STATE_NOT_REQUIRED;
}
}
WITH_SEMAPHORE(AP::fence()->polyfence().get_loaded_fence_semaphore());
// avoidance is not required if no fences

View File

@ -204,7 +204,18 @@ AP_OAPathPlanner::OA_RetState AP_OAPathPlanner::mission_avoidance(const Location
// avoidance thread that continually updates the avoidance_result structure based on avoidance_request
void AP_OAPathPlanner::avoidance_thread()
{
{
// require ekf origin to have been set
bool origin_set = false;
while (!origin_set) {
hal.scheduler->delay(500);
struct Location ekf_origin {};
{
WITH_SEMAPHORE(AP::ahrs().get_semaphore());
origin_set = AP::ahrs().get_origin(ekf_origin);
}
}
while (true) {
// if database queue needs attention, service it faster