1#ifndef BITSIM_PLANNING_RRT_H
2#define BITSIM_PLANNING_RRT_H
33 using Point = std::array<real_t, 2>;
77 const std::vector<Node> &
tree() const noexcept {
return tree_; }
83 std::vector<Point>
path()
const;
100 std::vector<Point>
shortcut(
const std::vector<Point> &
path)
const;
115 std::vector<Node> tree_;
117 bool reached_{
false};
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
bool is_segment_free(const Point &a, const Point &b) const
Whether the straight segment from a to b is free, checked every collision_step.
Definition rrt.cpp:100
std::vector< Point > shortcut(const std::vector< Point > &path) const
A shorter path through the same free space: from each point of the path, go straight to the furthest ...
Definition rrt.cpp:115
RRT(const Point &lower, const Point &upper, FreeTest is_free, const Parameters ¶meters, uint_t seed=42)
Definition rrt.cpp:20
static real_t length(const std::vector< Point > &path)
The length of a path [m].
Definition rrt.cpp:136
bool plan(const Point &start, const Point &goal)
Grow a tree from start to goal. Returns whether it reached the goal.
Definition rrt.cpp:35
std::array< real_t, 2 > Point
Definition rrt.h:33
std::vector< Point > path() const
The path of the last plan() from the start to the goal, both included; empty if the goal was not reac...
Definition rrt.cpp:81
std::function< bool(const Point &)> FreeTest
Whether a point is free of obstacles.
Definition rrt.h:38
uint_t n_iterations() const noexcept
The iterations the last plan() took.
Definition rrt.h:88
const std::vector< Node > & tree() const noexcept
The tree of the last plan().
Definition rrt.h:77
Definition a_star_search.cpp:8
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20
A node of the tree: where it is, and the index of its parent; the root is its own parent.
Definition rrt.h:54
uint_t parent
Definition rrt.h:56
Point p
Definition rrt.h:55
real_t goal_radius
close enough to the goal [m]
Definition rrt.h:44
real_t collision_step
how finely a branch is checked [m]
Definition rrt.h:46
real_t step
the longest branch [m]
Definition rrt.h:42
real_t goal_bias
the probability of growing towards the goal
Definition rrt.h:43
uint_t max_iterations
before giving up
Definition rrt.h:45