Skip to content

Commit

Permalink
Fixed precision error
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelRey committed Jun 22, 2021
1 parent 0c48db4 commit 79d655a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Planners/AStarGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ PathData AStarGenerator::findPath(const Vec3i &source_, const Vec3i &target_)
if ( discrete_world_.isOccupied(newCoordinates) ||
discrete_world_.isInClosedList(newCoordinates) )
continue;
unsigned int totalCost = current->G + ( i < 6 ? 10 : ( i < 18 ? 14 : 17) ); //This is more efficient
unsigned int totalCost = current->G + (i < 6 ? 100 : (i < 18 ? 141 : 173)); //This is more efficient

Node *successor = discrete_world_.getNodePtr(newCoordinates);

Expand Down
2 changes: 1 addition & 1 deletion src/Planners/LazyThetaStarGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace Planners
if (discrete_world_.isOccupied(newCoordinates) ||
discrete_world_.isInClosedList(newCoordinates))
continue;
unsigned int totalCost = current->G + (i < 6 ? 10 : (i < 18 ? 14 : 17)); //This is more efficient
unsigned int totalCost = current->G + (i < 6 ? 100 : (i < 18 ? 141 : 173)); //This is more efficient

Node *successor = discrete_world_.getNodePtr(newCoordinates);

Expand Down
2 changes: 1 addition & 1 deletion src/Planners/ThetaStarGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace Planners
if (discrete_world_.isOccupied(newCoordinates) ||
discrete_world_.isInClosedList(newCoordinates))
continue;
unsigned int totalCost = current->G + (i < 6 ? 10 : (i < 18 ? 14 : 17));
unsigned int totalCost = current->G + (i < 6 ? 100 : (i < 18 ? 141 : 173)); //This is more efficient

Node *successor = discrete_world_.getNodePtr(newCoordinates);

Expand Down
6 changes: 3 additions & 3 deletions src/utils/geometry_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace Planners
}
unsigned int distanceBetween2Nodes(const Node &n1, const Node &n2)
{
return static_cast<unsigned int>(10 * sqrt(pow(n1.coordinates.x - n2.coordinates.x, 2) +
pow(n1.coordinates.y - n2.coordinates.y, 2) +
pow(n1.coordinates.z - n2.coordinates.z, 2)));
return static_cast<unsigned int>(100 * sqrt(pow(n1.coordinates.x - n2.coordinates.x, 2) +
pow(n1.coordinates.y - n2.coordinates.y, 2) +
pow(n1.coordinates.z - n2.coordinates.z, 2)));
}
unsigned int distanceBetween2Nodes(const Node *n1, const Node *n2)
{
Expand Down
6 changes: 3 additions & 3 deletions src/utils/heuristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace Planners
unsigned int Heuristic::manhattan(Vec3i source_, Vec3i target_)
{
auto delta = std::move(getDelta(source_, target_));
return static_cast<unsigned int>(10 * (delta.x + delta.y + delta.z));
return static_cast<unsigned int>(100 * (delta.x + delta.y + delta.z));
}

unsigned int Heuristic::euclidean(Vec3i source_, Vec3i target_)
{
auto delta = std::move(getDelta(source_, target_));
return static_cast<unsigned int>(10 * sqrt(pow(delta.x, 2) + pow(delta.y, 2) + pow(delta.z, 2)));
return static_cast<unsigned int>(100 * sqrt(pow(delta.x, 2) + pow(delta.y, 2) + pow(delta.z, 2)));
}
unsigned int Heuristic::dikjstra(Vec3i source_, Vec3i target_)
{
Expand All @@ -28,7 +28,7 @@ namespace Planners
unsigned int Heuristic::octagonal(Vec3i source_, Vec3i target_)
{
auto delta = std::move(getDelta(source_, target_));
return 10 * (delta.x + delta.y + delta.z) + (-6) * std::min(delta.x, delta.y);
return 100 * (delta.x + delta.y + delta.z) + (-6) * std::min(delta.x, delta.y);
}

}

0 comments on commit 79d655a

Please sign in to comment.