Skip to content

Commit

Permalink
Fix wirenode and yaml changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalkah committed Nov 2, 2023
1 parent c2b28d8 commit 15eb618
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
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
4 changes: 2 additions & 2 deletions tools/include/visualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Visualizer
{
public:
Visualizer(std::shared_ptr<planning::Map> map, pair_double size_coeff,
std::size_t kDelay, std::string window_name,
double kDelay, std::string window_name,
std::string planner_name);
~Visualizer() { window_.close(); }

Expand All @@ -68,7 +68,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

0 comments on commit 15eb618

Please sign in to comment.