27
27
28
28
#include < vector>
29
29
#include < unordered_map>
30
+ #include < unordered_set>
30
31
#include < optional>
32
+ #include < iostream>
31
33
32
34
namespace rmf_traffic {
33
35
namespace agv {
@@ -37,10 +39,80 @@ class Graph
37
39
{
38
40
public:
39
41
40
- class Waypoint
42
+ // / Properties related to lifts (elevators) that exist in the graph
43
+ class LiftProperties
44
+ {
45
+ public:
46
+ // / Get the name of the lift.
47
+ const std::string& name () const ;
48
+
49
+ // / Get the (x, y) location of the lift in RMF canonical coordinates.
50
+ Eigen::Vector2d location () const ;
51
+
52
+ // / Get the orientation (in radians) of the lift in RMF canonical
53
+ // / coordinates.
54
+ double orientation () const ;
55
+
56
+ // / Get the dimensions of the lift, aligned with the lift's local (x, y)
57
+ // / coordinates.
58
+ Eigen::Vector2d dimensions () const ;
59
+
60
+ // / Get whether the specified position, given in RMF canonical coordinates,
61
+ // / is inside the lift. The envelope will expand the footprint of the lift
62
+ // / that is used in the calculation.
63
+ bool is_in_lift (Eigen::Vector2d position, double envelope = 0.0 ) const ;
64
+
65
+ // / Constructor
66
+ LiftProperties (
67
+ std::string name,
68
+ Eigen::Vector2d location,
69
+ double orientations,
70
+ Eigen::Vector2d dimensions);
71
+
72
+ class Implementation ;
73
+ private:
74
+ rmf_utils::impl_ptr<Implementation> _pimpl;
75
+ };
76
+ using LiftPropertiesPtr = std::shared_ptr<LiftProperties>;
77
+
78
+ class DoorProperties
41
79
{
42
80
public:
81
+ // / Get the name of the door.
82
+ const std::string& name () const ;
83
+
84
+ // / Get the start position of the door.
85
+ Eigen::Vector2d start () const ;
86
+
87
+ // / Get the end position of the door.
88
+ Eigen::Vector2d end () const ;
89
+
90
+ // / Get the name of the map that this door is on.
91
+ const std::string& map () const ;
92
+
93
+ // / Check if the line formed by p0 -> p1 intersects this door.
94
+ bool intersects (
95
+ Eigen::Vector2d p0,
96
+ Eigen::Vector2d p1,
97
+ double envelope = 0.0 ) const ;
98
+
99
+ // / Constructor
100
+ DoorProperties (
101
+ std::string name,
102
+ Eigen::Vector2d start,
103
+ Eigen::Vector2d end,
104
+ std::string map);
105
+
106
+ class Implementation ;
107
+ private:
108
+ rmf_utils::impl_ptr<Implementation> _pimpl;
109
+ };
110
+ using DoorPropertiesPtr = std::shared_ptr<DoorProperties>;
43
111
112
+ // / Properties assigned to each waypoint (vertex) in the graph
113
+ class Waypoint
114
+ {
115
+ public:
44
116
// / Get the name of the map that this Waypoint exists on.
45
117
const std::string& get_map_name () const ;
46
118
@@ -79,7 +151,6 @@ class Graph
79
151
// / Set this Waypoint to be a parking spot.
80
152
Waypoint& set_parking_spot (bool _is_parking_spot);
81
153
82
-
83
154
// / Returns true if this Waypoint is a charger spot. Robots are routed to
84
155
// / these spots when their batteries charge levels drop below the threshold
85
156
// / value.
@@ -88,6 +159,14 @@ class Graph
88
159
// / Set this Waypoint to be a parking spot.
89
160
Waypoint& set_charger (bool _is_charger);
90
161
162
+ // / If this waypoint is inside the lift then this will return a pointer to
163
+ // / the properties of the lift. Otherwise this will be a nullptr.
164
+ LiftPropertiesPtr in_lift () const ;
165
+
166
+ // / Set the properties of the lift that the waypoint is inside of, or
167
+ // / provide a nullptr if it is not inside a lift.
168
+ Waypoint& set_in_lift (LiftPropertiesPtr properties);
169
+
91
170
// / The index of this waypoint within the Graph. This cannot be changed
92
171
// / after the waypoint is created.
93
172
std::size_t index () const ;
@@ -119,6 +198,25 @@ class Graph
119
198
const std::string& name_format = " %s" ,
120
199
const std::string& index_format = " #%d" ) const ;
121
200
201
+ // / Get the mutex group that this waypoint is associated with. An empty
202
+ // / string implies that it is not associated with any mutex group.
203
+ // /
204
+ // / Only one robot at a time is allowed to occupy any waypoint or lane
205
+ // / associated with a particular mutex group.
206
+ const std::string& in_mutex_group () const ;
207
+
208
+ // / Set what mutex group this waypoint is associated with. Passing in an
209
+ // / empty string will disasscoiate the waypoint from any mutex group.
210
+ Waypoint& set_in_mutex_group (std::string group_name);
211
+
212
+ // / Get a merge radius specific to this waypoint, if it has one. The radius
213
+ // / indicates that any robot within this distance of the waypoint can merge
214
+ // / onto this waypoint.
215
+ std::optional<double > merge_radius () const ;
216
+
217
+ // / Set the merge radius specific to this waypoint.
218
+ Waypoint& set_merge_radius (std::optional<double > valeu);
219
+
122
220
class Implementation ;
123
221
private:
124
222
Waypoint ();
@@ -371,8 +469,8 @@ class Graph
371
469
template <typename DerivedExecutor>
372
470
DerivedExecutor& execute (DerivedExecutor& executor) const
373
471
{
374
- return static_cast <DerivedExecutor&>(execute (
375
- static_cast <Executor&>(executor)));
472
+ return static_cast <DerivedExecutor&>(
473
+ execute ( static_cast <Executor&>(executor)));
376
474
}
377
475
378
476
// / Execute this event
@@ -468,6 +566,7 @@ class Graph
468
566
469
567
// / Construct a default set of properties
470
568
// / * speed_limit: nullopt
569
+ // / * mutex_group: ""
471
570
Properties ();
472
571
473
572
// / Get the speed limit along this lane. If a std::nullopt is returned,
@@ -478,6 +577,17 @@ class Graph
478
577
// / indicates that there is no speed limit for the lane.
479
578
Properties& speed_limit (std::optional<double > value);
480
579
580
+ // / Get the mutex group that this lane is associated with. An empty string
581
+ // / implies that it is not associated with any mutex group.
582
+ // /
583
+ // / Only one robot at a time is allowed to occupy any waypoint or lane
584
+ // / associated with a particular mutex group.
585
+ const std::string& in_mutex_group () const ;
586
+
587
+ // / Set what mutex group this lane is associated with. Passing in an
588
+ // / empty string will disassociate the lane from any mutex group.
589
+ Properties& set_in_mutex_group (std::string group_name);
590
+
481
591
class Implementation ;
482
592
private:
483
593
rmf_utils::impl_ptr<Implementation> _pimpl;
@@ -589,6 +699,28 @@ class Graph
589
699
// / const-qualified lane_from()
590
700
const Lane* lane_from (std::size_t from_wp, std::size_t to_wp) const ;
591
701
702
+ // / Add a known lift to the graph. If this lift has the same name as one
703
+ // / previously added, we will continue to use the same pointer as the original
704
+ // / and override the properties because lift names are expected to be unique.
705
+ LiftPropertiesPtr set_known_lift (LiftProperties lift);
706
+
707
+ // / Get all the known lifts.
708
+ std::vector<LiftPropertiesPtr> all_known_lifts () const ;
709
+
710
+ // / Find a known lift based on its name.
711
+ LiftPropertiesPtr find_known_lift (const std::string& name) const ;
712
+
713
+ // / Add a known door to the graph. If this door has the same name as one
714
+ // / previously added, we will continue to use the same pointer as the original
715
+ // / and override the properties because door names are expected to be unique.
716
+ DoorPropertiesPtr set_known_door (DoorProperties door);
717
+
718
+ // / Get all the known doors.
719
+ std::vector<DoorPropertiesPtr> all_known_doors () const ;
720
+
721
+ // / Find a known door based on its name.
722
+ DoorPropertiesPtr find_known_door (const std::string& name) const ;
723
+
592
724
class Implementation ;
593
725
private:
594
726
rmf_utils::impl_ptr<Implementation> _pimpl;
0 commit comments