mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
safety_zone.h
1#ifndef MRS_LIB_SAFETYZONE_H
2#define MRS_LIB_SAFETYZONE_H
3
4#include <map>
5#include <memory>
6#include <mrs_lib/safety_zone/prism.h>
7#include <vector>
8#include <Eigen/Dense>
9
10namespace mrs_lib
11{
12
13namespace safety_zone
14{
15
17public:
18 SafetyZone(std::unique_ptr<Prism> &&outer_border);
19
20 // Cleaning the obstacles' memory is SafetyZone's responsibility
21 SafetyZone(std::unique_ptr<Prism> &&outer_border, std::vector<std::unique_ptr<Prism>> &&obstacles);
22
23 ~SafetyZone() = default;
24
25 // Enable/Disable safety zone
26 void enableSafetyZone(const bool enable);
27
28 bool safetyZoneEnabled(void);
29
30 // Controls, if 3d point lies within the prism
31 bool isPointValid(const Point3d &point);
32
33 // Convenient version of isPointIn(Point3d point)
34 bool isPointValid(const double px, const double py, const double pz);
35
36 // Controls, if 2d point lies within the polygon of prism (i.e. ignores max_z
37 // and min_z of all prisms)
38 bool isPointValid(const Point2d &point);
39
40 // Convenient version of isPointIn(Point2d point)
41 bool isPointValid(const double px, const double py);
42
43 // The function divides the path into smaller segments (on average 20 segments
44 // per meter) and validates each intermediate point to determine if the entire
45 // path is valid.
46 bool isPathValid(const Point3d &start, const Point3d &end);
47
48 // 2d version of isPathValid(const Point3d start, const Point3d end), i.e.
49 // ignores max_z and min_z of all prisms
50 bool isPathValid(const Point2d &start, const Point2d &end);
51
52 Prism getBorder() const;
53
54 const std::map<int, std::unique_ptr<Prism>> &getObstacles() const;
55
56 Prism getObstacle(const int index) const;
57
58 int addObstacle(std::unique_ptr<Prism> obstacle);
59
60 void deleteObstacle(const int id);
61
62 // Helper method for text representation
63 // void accept(Visitor &visitor);
64
65private:
66 std::unique_ptr<Prism> outer_border_;
67 std::map<int, std::unique_ptr<Prism>> obstacles_;
68 mutable std::mutex mutex_safety_zone_;
69 int next_obstacle_id_ = 0;
70 bool safety_zone_enabled_ = false;
71
72 // Used to discretize between start and end for the path validation
73 int _discretization_steps_ = 20;
74}; // class SafetyZone
75
76} // namespace safety_zone
77} // namespace mrs_lib
78
79#endif // MRS_LIB_SAFETYZONE_H
Definition prism.h:31
Definition safety_zone.h:16
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24