bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
box_world.h
Go to the documentation of this file.
1#ifndef BITSIM_PLANNING_BOX_WORLD_H
2#define BITSIM_PLANNING_BOX_WORLD_H
3
6
7#include <array>
8#include <vector>
9
10namespace bitsim
11{
12namespace planning
13{
14
29{
30 public:
31 using Point = std::array<real_t, 2>;
32
34 struct Box
35 {
37 };
38
40 struct RayHit
41 {
42 bool hit;
44 };
45
55 const Point &start, const Point &goal);
56
57 real_t width() const noexcept { return width_; }
58 real_t height() const noexcept { return height_; }
59 real_t robot_radius() const noexcept { return robot_radius_; }
60 const std::vector<Box> &obstacles() const noexcept { return obstacles_; }
61 const Point &start() const noexcept { return start_; }
62 const Point &goal() const noexcept { return goal_; }
63
68 bool is_free(const Point &p) const { return is_free(p, robot_radius_); }
69 bool is_free(const Point &p, real_t radius) const;
70
77 {
78 return occupancy_grid(cell_size, robot_radius_);
79 }
80 OccupancyGrid occupancy_grid(real_t cell_size, real_t margin) const;
81
87 RayHit ray_cast(const Point &origin, real_t angle, real_t max_range) const;
88
93 static BoxWorld warehouse();
94
95 private:
96 real_t width_;
97 real_t height_;
98 std::vector<Box> obstacles_;
99 real_t robot_radius_;
100 Point start_;
101 Point goal_;
102};
103
104} // namespace planning
105} // namespace bitsim
106
107#endif // BITSIM_PLANNING_BOX_WORLD_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
A rectangular slice of the plane with axis-aligned box obstacles, a start and a goal.
Definition box_world.h:29
bool is_free(const Point &p) const
True if a disc of the given radius centred at p touches no obstacle and no outer wall....
Definition box_world.h:68
static BoxWorld warehouse()
The warehouse of the grid_planning and rrt examples: 8 x 5 m, a 0.25 m robot, five shelves and a wall...
Definition box_world.cpp:152
std::array< real_t, 2 > Point
Definition box_world.h:31
OccupancyGrid occupancy_grid(real_t cell_size) const
The world as an OccupancyGrid of square cells, with the obstacles and the outer walls grown by margin...
Definition box_world.h:76
real_t robot_radius() const noexcept
Definition box_world.h:59
const Point & goal() const noexcept
Definition box_world.h:62
RayHit ray_cast(const Point &origin, real_t angle, real_t max_range) const
Cast a ray from origin in the direction angle (radians, measured from the x axis) and return the dist...
Definition box_world.cpp:112
const std::vector< Box > & obstacles() const noexcept
Definition box_world.h:60
real_t width() const noexcept
Definition box_world.h:57
BoxWorld(real_t width, real_t height, std::vector< Box > obstacles, real_t robot_radius, const Point &start, const Point &goal)
Definition box_world.cpp:14
real_t height() const noexcept
Definition box_world.h:58
const Point & start() const noexcept
Definition box_world.h:61
A rectangle of the plane cut into square cells, each free or occupied.
Definition occupancy_grid.h:43
Definition a_star_search.cpp:8
Definition dc_motor_backend_base.h:9
double real_t
real_t
Definition bitsim_types.h:20
An axis-aligned box [x0, x1] x [y0, y1] [m].
Definition box_world.h:35
real_t y1
Definition box_world.h:36
real_t x1
Definition box_world.h:36
real_t x0
Definition box_world.h:36
real_t y0
Definition box_world.h:36
What a range beam found: whether it struck anything within reach, and how far away.
Definition box_world.h:41
real_t distance
the distance to the obstacle or wall, or max_range on a miss [m]
Definition box_world.h:43
bool hit
false if the beam reached max_range without striking anything
Definition box_world.h:42