Program Listing for File rrt.hpp¶
↰ Return to documentation for file (include/path_planning/rrt.hpp
)
#ifndef RRT_H
#define RRT_H
#include <limits>
#include <tuple>
#include <unordered_map>
#include <vector>
#include "path_planning/planner.hpp"
#include "utils/utils.hpp"
class RRT : public Planner {
public:
explicit RRT(std::vector<std::vector<int>> grid) : Planner(std::move(grid)) {}
void SetParams(const int threshold = 2, const int max_iter_x_factor = 20);
std::tuple<bool, std::vector<Node>> Plan(const Node& start,
const Node& goal) override;
private:
std::tuple<bool, Node> FindNearestPoint(Node& new_node);
bool IsAnyObstacleInPath(const Node& n_1, const Node& n_2) const;
Node GenerateRandomNode() const;
bool CheckGoalVisible(const Node& new_node);
void CreateObstacleList();
std::vector<Node> CreatePath();
private:
Node start_, goal_;
std::unordered_set<Node, NodeIdAsHash, compare_coordinates>
point_list_; // TODO: set up in cstor
std::unordered_map<Node, std::vector<Node>> near_nodes_;
std::vector<Node> obstacle_list_;
double threshold_ = 1.5; // TODO: set up in cstor
int max_iter_x_factor_ = 500; // TODO: set up in cstor
};
#endif // RRT_H