Skip to content

Commit

Permalink
Added adjustment for speed
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjesl committed Jan 28, 2023
1 parent 0da5ad2 commit 764056b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
7 changes: 7 additions & 0 deletions inc/glnav_dijkstra.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ namespace glnav
{
if(result[i].first == next) throw std::runtime_error("Loop detected");
}

// Set the speed
const Q delta_cost = this->__map.cost(result.back().first) - this->__map.cost(next);
const Q distance = path<T>(result.back().first, next).length();
result.back().second = distance / delta_cost;

// Set the new waypoint
result.push_back(next, 1);
}

Expand Down
19 changes: 17 additions & 2 deletions inc/glnav_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace glnav
__seed(seed)
{ }

using std::deque<std::pair<point<T>, Q> >::empty;
using std::deque<std::pair<point<T>, Q> >::size;
using std::deque<std::pair<point<T>, Q> >::clear;
using std::deque<std::pair<point<T>, Q> >::operator[];
Expand Down Expand Up @@ -54,14 +55,28 @@ namespace glnav
return std::deque<std::pair<point<T>, Q> >::pop_back();
}

std::pair<point<T>, Q> front()
std::pair<point<T>, Q> & front()
{
assert_version(*this, this->__seed);

return std::deque<std::pair<point<T>, Q> >::front();
}

std::pair<point<T>, Q> back()
std::pair<point<T>, Q> & back()
{
assert_version(*this, this->__seed);

return std::deque<std::pair<point<T>, Q> >::back();
}

const std::pair<point<T>, Q> & front() const
{
assert_version(*this, this->__seed);

return std::deque<std::pair<point<T>, Q> >::front();
}

const std::pair<point<T>, Q> & back() const
{
assert_version(*this, this->__seed);

Expand Down

0 comments on commit 764056b

Please sign in to comment.