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