|
bitsim
Model, simulate, estimate and control robots in C++
|
Motion planning: finding a path from a start to a goal that avoids obstacles. More...
Classes | |
| struct | bitsim::planning::SearchResult< Node > |
| What a search found. More... | |
| struct | bitsim::planning::GridCell |
| A cell of an OccupancyGrid: its column, along x, and row, along y. More... | |
| class | bitsim::planning::BoxWorld |
| A rectangular slice of the plane with axis-aligned box obstacles, a start and a goal. More... | |
| class | bitsim::planning::OccupancyGrid |
| A rectangle of the plane cut into square cells, each free or occupied. More... | |
| class | bitsim::planning::ProbabilityGrid |
| An occupancy map built from range sensors, each cell holding the probability that it is occupied. More... | |
| class | bitsim::planning::RRT |
| A rapidly exploring random tree in the plane. More... | |
Functions | |
| template<typename Node, typename Neighbours, typename Cost, typename Heuristic> | |
| SearchResult< Node > | bitsim::planning::a_star (const Node &start, const Node &goal, Neighbours neighbours, Cost cost, Heuristic heuristic, real_t weight=1.0) |
| A* search from start to goal. | |
| SearchResult< GridCell > | bitsim::planning::a_star_grid (const OccupancyGrid &grid, const GridCell &start, const GridCell &goal, bool diagonal=true, real_t weight=1.0) |
| A* on an occupancy grid, moving to the neighbours of a cell (see OccupancyGrid::neighbours) with the distance between cell centres as the cost and the straight-line distance to the goal as the heuristic, which never guesses too high. | |
| SearchResult< GridCell > | bitsim::planning::bfs_grid (const OccupancyGrid &grid, const GridCell &start, const GridCell &goal, bool diagonal=true) |
| Breadth-first search on an occupancy grid. | |
| SearchResult< GridCell > | bitsim::planning::theta_star_grid (const OccupancyGrid &grid, const GridCell &start, const GridCell &goal) |
| Theta*: any-angle search on an occupancy grid. | |
| bool | bitsim::planning::line_of_sight (const OccupancyGrid &grid, const GridCell &a, const GridCell &b) |
| Whether the straight segment between the centres of cells a and b stays clear: every cell the segment passes through is free, and it does not cut between two obstacles that meet at a corner. Used by theta_star_grid, and for drawing an any-angle path. | |
Motion planning: finding a path from a start to a goal that avoids obstacles.
| SearchResult< Node > bitsim::planning::a_star | ( | const Node & | start, |
| const Node & | goal, | ||
| Neighbours | neighbours, | ||
| Cost | cost, | ||
| Heuristic | heuristic, | ||
| real_t | weight = 1.0 ) |
A* search from start to goal.
The search keeps a list of open nodes ordered by \(f(n) = g(n) + w\,h(n)\): the cost \(g\) of the best path to n found so far, plus the weighted heuristic \(h\), a guess of the cost from n to the goal. It expands the node with the smallest f, until that is the goal. With an admissible heuristic, one that never guesses too high, and w = 1 the path found is a shortest one. With w = 0 the search is Dijkstra's algorithm, which expands more nodes; with w > 1 it expands fewer, but the path may be longer.
| start | Where to start |
| goal | Where to go |
| neighbours | neighbours(n) gives the nodes next to n, as a container of Node |
| cost | cost(a, b) is the cost of the move from a to b, which are neighbours |
| heuristic | heuristic(n, goal) guesses the cost from n to the goal |
| weight | The weight w of the heuristic |
Node needs ==, and std::hash<Node>.
| SearchResult< GridCell > bitsim::planning::a_star_grid | ( | const OccupancyGrid & | grid, |
| const GridCell & | start, | ||
| const GridCell & | goal, | ||
| bool | diagonal, | ||
| real_t | weight ) |
A* on an occupancy grid, moving to the neighbours of a cell (see OccupancyGrid::neighbours) with the distance between cell centres as the cost and the straight-line distance to the goal as the heuristic, which never guesses too high.
| SearchResult< GridCell > bitsim::planning::bfs_grid | ( | const OccupancyGrid & | grid, |
| const GridCell & | start, | ||
| const GridCell & | goal, | ||
| bool | diagonal = true ) |
Breadth-first search on an occupancy grid.
Explores the grid outward from the start in rings of equal move count, so the path it finds has the fewest moves to the goal. Every move counts the same, straight or diagonal, so the path is not the shortest in metres, and the search fans out in every direction like Dijkstra's. SearchResult::cost is the length of the path in metres, for comparison with the other searches; SearchResult::n_expanded is how many cells were taken off the queue.
| bool bitsim::planning::line_of_sight | ( | const OccupancyGrid & | grid, |
| const GridCell & | a, | ||
| const GridCell & | b ) |
Whether the straight segment between the centres of cells a and b stays clear: every cell the segment passes through is free, and it does not cut between two obstacles that meet at a corner. Used by theta_star_grid, and for drawing an any-angle path.
| SearchResult< GridCell > bitsim::planning::theta_star_grid | ( | const OccupancyGrid & | grid, |
| const GridCell & | start, | ||
| const GridCell & | goal ) |
Theta*: any-angle search on an occupancy grid.
Like A*, but each time it reaches a cell it checks whether that cell has a clear line of sight to the parent of the cell it came from. If it does, the cell's parent is set to that grandparent, so the path takes a straight shortcut at any angle instead of following the grid. The path returned is a list of corner cells with a clear straight segment between each pair, so it is shorter and smoother than the grid path of A*. The cost is the length in metres.