Skip to content

Commit

Permalink
Adjusted duplicate waypoint adjustment to avoid loops
Browse files Browse the repository at this point in the history
  • Loading branch information
derekkingston committed Aug 29, 2018
1 parent 487c6eb commit cb561cf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Tasks/TaskServiceBase.cpp
Expand Up @@ -55,7 +55,7 @@ const int64_t TaskOptionClass::m_firstImplementationRouteId{2}; // first id to u
//XML STRINGS
const std::string TaskServiceBase::m_taskOptions_XmlTag{"TaskOptions"};

bool isCollocated(afrl::cmasi::Location3D* a, afrl::cmasi::Location3D* b)
bool isColocated(afrl::cmasi::Location3D* a, afrl::cmasi::Location3D* b)
{
if(!a || !b) return false;

Expand Down Expand Up @@ -943,14 +943,19 @@ void TaskServiceBase::processImplementationRoutePlanResponseBase(const std::shar
itTaskOptionClass->second->m_firstTaskActiveWaypointID = waypointId;
}
}

// if a waypoint is co-located with the previous waypoint, replace the previous waypoint
if(!taskImplementationResponse->getTaskWaypoints().empty() &&
isCollocated(taskImplementationResponse->getTaskWaypoints().back(), waypoint))
isColocated(taskImplementationResponse->getTaskWaypoints().back(), waypoint))
{
waypointId = taskImplementationResponse->getTaskWaypoints().back()->getNumber();
int64_t nextId = taskImplementationResponse->getTaskWaypoints().back()->getNextWaypoint();
waypoint->setNumber(waypointId);
waypoint->setNextWaypoint(nextId);
delete taskImplementationResponse->getTaskWaypoints().back();
taskImplementationResponse->getTaskWaypoints().pop_back();;
taskImplementationResponse->getTaskWaypoints().pop_back();
}

taskImplementationResponse->getTaskWaypoints().push_back(waypoint);
waypointId++;
waypoint = nullptr; // gave up ownership
Expand Down

0 comments on commit cb561cf

Please sign in to comment.