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

Fix wirenode and yaml changes #27

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ int main(int argc, char **argv)
// Planner config
auto planner_name = config["planner_name"].as<std::string>();
PlannerType planner = GetPlanner(planner_name);

// Visualizer config
auto tree_visualizer = std::make_shared<tools::Visualizer>(
map, tools::pair_double{2.0, 2.0}, 1u, "Tree Visualizer", planner_name);
auto rescale_factor = config["visualizer"]["rescale"].as<double>();
auto delay = config["visualizer"]["delay"].as<double>();

auto visualizer = std::make_shared<tools::Visualizer>(
map, tools::pair_double{rescale_factor, rescale_factor}, delay,
"Tree Visualizer", planner_name);

// Path config
auto s = config["path"]["start"];
Expand All @@ -61,11 +66,11 @@ int main(int argc, char **argv)
auto goal_node = planning::Node(g["x"].as<int>(), g["y"].as<int>());

// Visualize start and goal nodes
tree_visualizer->SetStartAndGoal(start_node, goal_node);
visualizer->SetStartAndGoal(start_node, goal_node);

while (true)
{
tree_visualizer->SetGetLogFunction(
visualizer->SetGetLogFunction(
std::bind(&planning::IPlanningWithLogging::GetLog, planner));
std::cout << "Started" << std::endl;
// Get time
Expand All @@ -79,7 +84,7 @@ int main(int argc, char **argv)
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cout << "Finished" << std::endl;
// set null to get_log_function_ to stop logging
tree_visualizer->SetGetLogFunction(nullptr);
visualizer->SetGetLogFunction(nullptr);
planner->ClearLog();
}

Expand Down
1 change: 1 addition & 0 deletions planning/grid_base/dfs/dfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Path DFS::FindPath(const Node &start_node, const Node &goal_node,

search_list.push(new_node_parent);
}
std::this_thread::sleep_for(std::chrono::microseconds(100));
}

if (search_list.empty())
Expand Down
4 changes: 4 additions & 0 deletions planning/tree_base/src/common_tree_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ WireNewNode(const int max_branch_length, const int min_branch_length,
{
return std::make_shared<NodeParent>(new_node, nearest_node, Cost{});
}
if (index == 0)
{
return std::nullptr_t();
}
auto isLengthValid{EuclideanDistance(ray[index - 1], nearest_node->node) >
min_branch_length};
auto isNodeValid{map->GetNodeState(ray[index]) != NodeState::kOccupied &&
Expand Down
5 changes: 2 additions & 3 deletions tools/include/visualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class Visualizer
{
public:
Visualizer(std::shared_ptr<planning::Map> map, pair_double size_coeff,
std::size_t kDelay, std::string window_name,
std::string planner_name);
double kDelay, std::string window_name, std::string planner_name);
~Visualizer() { window_.close(); }

void SetStartAndGoal(const planning::Node &start_node,
Expand All @@ -68,7 +67,7 @@ class Visualizer
private:
std::shared_ptr<planning::Map> map;
pair_double size_coeff_;
std::size_t kDelay_;
double kDelay_;
std::string window_name_;
std::string planner_name_;

Expand Down
2 changes: 1 addition & 1 deletion tools/src/visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace tools
{

Visualizer::Visualizer(std::shared_ptr<planning::Map> map,
pair_double size_coeff, std::size_t kDelay,
pair_double size_coeff, double kDelay,
std::string window_name, std::string planner_name)
: map(map), size_coeff_(size_coeff), kDelay_(kDelay),
window_name_(window_name), planner_name_(planner_name)
Expand Down