Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RRT* #26

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Prev Previous commit
clang-format on rrt_star.hh
  • Loading branch information
pranavjad committed Sep 9, 2024
commit a56d00256340751331d4bf897622e89813447944
16 changes: 10 additions & 6 deletions src/impl/vamp/planning/rrt_star.hh
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ namespace vamp::planning
}
};

const auto build_path = [&result, &buffer_index, &parent](const Configuration &goal, const std::size_t last_config_idx)
const auto build_path = [&result, &buffer_index, &parent](
const Configuration &goal, const std::size_t last_config_idx)
{
result.path.emplace_back(goal);
result.path.emplace_back(buffer_index(last_config_idx));
auto current = last_config_idx;
while (parent[current] != current) {
while (parent[current] != current)
{
auto parent_idx = parent[current];
result.path.emplace_back(buffer_index(parent_idx));
current = parent_idx;
Expand Down Expand Up @@ -127,7 +129,7 @@ namespace vamp::planning
std::vector<std::pair<std::size_t, Configuration>> goal_motions;
float best_path_cost = std::numeric_limits<float>::max();
std::pair<std::size_t, Configuration> best_goal_motion;

// main loop
std::size_t iter = 0;
std::vector<std::pair<NNNode<dimension>, float>> near;
Expand Down Expand Up @@ -175,7 +177,8 @@ namespace vamp::planning
settings.range);
tree.nearest(near, NNFloatArray<dimension>{new_configuration_ptr}, card, rrt_radius);

// initialize variables to keep track of the min cost neighbor and the cost of that neighbor
// initialize variables to keep track of the min cost neighbor and the cost of that
// neighbor
auto min_neighbor = nearest_node;
float min_cost = cost[nearest_node.index] + nearest_distance;

Expand Down Expand Up @@ -252,7 +255,8 @@ namespace vamp::planning
// loop through goal nodes to find the best solution
for (const auto &[end_node_idx, goal] : goal_motions)
{
const float cur_cost = cost[end_node_idx] + goal.distance(buffer_index(end_node_idx));
const float cur_cost =
cost[end_node_idx] + goal.distance(buffer_index(end_node_idx));
if (cur_cost < best_path_cost)
{
best_path_cost = cur_cost;
Expand All @@ -262,7 +266,7 @@ namespace vamp::planning
}
}
}

if (not settings.force_max_iters)
{
result.nanoseconds = vamp::utils::get_elapsed_nanoseconds(start_time);
Expand Down