Drake
regions.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 
8 
9 namespace drake {
10 namespace maliput {
11 namespace api {
12 namespace rules {
13 
14 
15 /// Directed, inclusive longitudinal (s value) range from s0 to s1.
16 class SRange {
17  public:
19 
20  /// Default constructor: initializes s0 and s1 to zero.
21  SRange() = default;
22 
23  /// Constructs range [s0 --> s1].
24  SRange(double s0, double s1) : s0_(s0), s1_(s1) {}
25 
26  /// Gets s0 value.
27  double s0() const { return s0_; }
28 
29  /// Gets s1 value.
30  double s1() const { return s1_; }
31 
32  /// Sets s0 value.
33  void set_s0(double s0) { s0_ = s0; }
34 
35  /// Sets s1 value.
36  void set_s1(double s1) { s1_ = s1; }
37 
38  private:
39  double s0_{0.};
40  double s1_{0.};
41 };
42 
43 
44 /// Directed longitudinal range of a specific Lane, identified by a LaneId.
45 class LaneSRange {
46  public:
48 
49  /// Constructs a LaneSRange as `s_range` on Lane `lane_id`.
50  LaneSRange(const LaneId& lane_id, const SRange& s_range)
51  : lane_id_(lane_id), s_range_(s_range) {}
52 
53  /// Gets the LaneId.
54  const LaneId& lane_id() const { return lane_id_; }
55 
56  /// Gets the SRange.
57  SRange s_range() const { return s_range_; }
58 
59  private:
60  LaneId lane_id_;
61  SRange s_range_;
62 };
63 
64 
65 /// A longitudinal route, possibly spanning multiple (end-to-end) lanes.
66 ///
67 /// The sequence of LaneSRanges should be contiguous. (In other words,
68 /// taken as a Lane-space path with r=0 and h=0, it should present a
69 /// G1-continuous curve.)
70 // TODO(maddog@tri.global) Figure out if there would be any loss or gain of
71 // utility if the contiguity requirement were removed.
72 class LaneSRoute {
73  public:
75 
76  /// Default constructor: constructs an empty route.
77  LaneSRoute() = default;
78 
79  /// Constructs a LaneSRoute from the given sequence of LaneSRanges.
80  explicit LaneSRoute(const std::vector<LaneSRange>& ranges)
81  : ranges_(ranges) {}
82 
83  /// Returns the sequence of LaneSRanges.
84  const std::vector<LaneSRange>& ranges() const { return ranges_; }
85 
86  // TODO(maddog@tri.global) Implement a "CheckInvariants()" method which
87  // ensures contiguity (with respect to a specified
88  // RoadGeometry).
89 
90  private:
91  std::vector<LaneSRange> ranges_;
92 };
93 
94 
95 } // namespace rules
96 } // namespace api
97 } // namespace maliput
98 } // namespace drake
const std::vector< LaneSRange > & ranges() const
Returns the sequence of LaneSRanges.
Definition: regions.h:84
Definition: automotive_demo.cc:90
void set_s0(double s0)
Sets s0 value.
Definition: regions.h:33
SRange(double s0, double s1)
Constructs range [s0 –> s1].
Definition: regions.h:24
optional< int > lane_id
Definition: loader.cc:45
#define DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Classname)
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN defaults the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:57
Directed, inclusive longitudinal (s value) range from s0 to s1.
Definition: regions.h:16
void set_s1(double s1)
Sets s1 value.
Definition: regions.h:36
double s0() const
Gets s0 value.
Definition: regions.h:27
A longitudinal route, possibly spanning multiple (end-to-end) lanes.
Definition: regions.h:72
const LaneId & lane_id() const
Gets the LaneId.
Definition: regions.h:54
LaneSRoute(const std::vector< LaneSRange > &ranges)
Constructs a LaneSRoute from the given sequence of LaneSRanges.
Definition: regions.h:80
SRange()=default
Default constructor: initializes s0 and s1 to zero.
double s1() const
Gets s1 value.
Definition: regions.h:30
Directed longitudinal range of a specific Lane, identified by a LaneId.
Definition: regions.h:45
SRange s_range() const
Gets the SRange.
Definition: regions.h:57
LaneSRange(const LaneId &lane_id, const SRange &s_range)
Constructs a LaneSRange as s_range on Lane lane_id.
Definition: regions.h:50
Provides careful macros to selectively enable or disable the special member functions for copy-constr...