Drake
lane.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 
9 
10 namespace drake {
11 namespace maliput {
12 namespace dragway {
13 
14 // Forward declarations.
15 class BranchPoint;
16 class Segment;
17 
18 /**
19  Dragway's implementation of api::Lane. The lane is flat with a height of
20  zero.
21 
22  The following lane is implemented:
23 
24  <pre>
25  lane_bounds
26  |<------------------------------->|
27  driveable_bounds
28  |<--------------------------------------->|
29 
30  ------------------------------------------- ——— s = length()
31  | : | ^
32  | : | |
33  | : | |
34  | : | |
35  | : | |
36  | : | |
37  | : | |
38  | : | |
39  | : | |
40  | : | |
41  | : | |
42  | : | |
43  | : | |
44  | : | |
45  | : | | world
46  | : | | frame:
47  | : | |
48  | : | | X
49  | : | | ^
50  | : | | |
51  | : | v |
52  ---------------------o--------------------- ——— s = 0 Y <--o
53 
54  r_max r_min
55  |<-------------------|------------------->|
56 
57  y_offset
58  |<----------------------------------------|
59  </pre>
60 
61  The lane's frame is defined by three coordinates: (`s`, `r`, `h`). Coordinate
62  `s` is between zero and `length()`. It specifies the longitudinal traversal of
63  the lane. Coordinate `r` is a value between `r_min` and `r_max`. It specifies
64  the lateral traversal at a particular `s`. Coordinate `h` specifies the
65  height above the lane's surface at a particular `s` and `r` (the lane's
66  surface itself is always at `h = 0`). Since Dragway lanes are flat and level,
67  `z = h` for all values of `s` and `r` and, in the Dragway's case, `z = 0` for
68  the surface itself. The origin of the lane's frame is defined by the `o` along
69  the above-shown `s = 0` line.
70 
71  Note: Each dragway lane has a teleportation feature at both ends: the
72  (default) ongoing lane for LaneEnd::kFinish is LaneEnd::kStart of the same
73  lane, and vice versa.
74 **/
75 class Lane final : public api::Lane {
76  public:
78 
79  /// Constructs a dragway Lane.
80  ///
81  /// @param segment The Segment to which this lane belongs.
82  ///
83  /// @param id the lane ID. This can be any user-defined value.
84  ///
85  /// @param index The index of the lane with its Segment.
86  ///
87  /// @param length The total length of the lane.
88  ///
89  /// @param y_offset The vector from the world frame's origin to the
90  /// lane's `s = 0` and `r = 0`. This value is positive when the lane's
91  /// `s = 0` and `r = 0` is to the left of the world frame's origin, and is
92  /// negative otherwise.
93  ///
94  /// @param lane_bounds nominal bounds of the lane, uniform along the entire
95  /// reference path, which must be a subset of @p driveable_bounds.
96  ///
97  /// @param driveable_bounds The driveable bounds of the lane, uniform along
98  /// the entire reference path.
99  ///
100  /// @param elevation_bounds The elevation bounds of the lane, uniform along
101  /// the entire reference path.
102  ///
103  Lane(const Segment* segment, const api::LaneId& id, int index, double length,
104  double y_offset, const api::RBounds& lane_bounds,
107 
108  ~Lane() final = default;
109 
110  /// @name Methods that set the lanes to the left and right of this lane.
111  /// The corresponding accessors are api::Lane::to_left() and
112  /// api::Lane::to_right().
113  ///@{
114 
115  void set_lane_to_left(api::Lane* lane_to_left);
116  void set_lane_to_right(api::Lane* lane_to_right);
117 
118  ///@}
119 
120  /// Returns the y-offset of this lane's frame relative to the world frame.
121  double y_offset() const { return y_offset_; }
122 
123  private:
124  const api::LaneId do_id() const final { return id_; }
125 
126  const api::Segment* do_segment() const final;
127 
128  int do_index() const final { return index_; }
129 
130  const api::Lane* do_to_left() const final { return lane_to_left_; }
131 
132  const api::Lane* do_to_right() const final { return lane_to_right_; }
133 
134  const api::BranchPoint* DoGetBranchPoint(
135  const api::LaneEnd::Which which_end) const final;
136 
137  const api::LaneEndSet* DoGetConfluentBranches(
138  const api::LaneEnd::Which which_end) const final;
139 
140  const api::LaneEndSet* DoGetOngoingBranches(
141  const api::LaneEnd::Which which_end) const final;
142 
143  optional<api::LaneEnd> DoGetDefaultBranch(
144  const api::LaneEnd::Which which_end) const final;
145 
146  double do_length() const final { return length_; }
147 
148  api::RBounds do_lane_bounds(double) const final;
149 
150  api::RBounds do_driveable_bounds(double) const final;
151 
152  api::HBounds do_elevation_bounds(double, double) const final;
153 
154  api::LanePosition DoEvalMotionDerivatives(
156  const api::IsoLaneVelocity& velocity) const final;
157 
158  api::GeoPosition DoToGeoPosition(const api::LanePosition& lane_pos) const
159  final;
160 
161  api::GeoPositionT<AutoDiffXd> DoToGeoPositionAutoDiff(
162  const api::LanePositionT<AutoDiffXd>& lane_pos) const final;
163 
164  api::Rotation DoGetOrientation(const api::LanePosition& lane_pos) const
165  final;
166 
167  api::LanePosition DoToLanePosition(const api::GeoPosition& geo_pos,
168  api::GeoPosition* nearest_point,
169  double* distance) const final;
170 
171  api::LanePositionT<AutoDiffXd> DoToLanePositionAutoDiff(
172  const api::GeoPositionT<AutoDiffXd>& geo_pos,
173  api::GeoPositionT<AutoDiffXd>* nearest_point,
174  AutoDiffXd* distance) const final;
175 
176  template <typename T>
177  api::LanePositionT<T> ImplDoToLanePositionT(
178  const api::GeoPositionT<T>& geo_pos,
179  api::GeoPositionT<T>* nearest_point,
180  T* distance) const;
181 
182  const Segment* segment_{}; // The segment to which this lane belongs.
183  const api::LaneId id_;
184  const int index_{}; // The index of this lane within a Segment.
185  const double length_{};
186  const double y_offset_{};
187  const api::RBounds lane_bounds_;
188  const api::RBounds driveable_bounds_;
189  const api::HBounds elevation_bounds_;
190 
191  // The following variable is actually `const` after construction.
192  std::unique_ptr<api::BranchPoint> branch_point_;
193 
194  const api::Lane* lane_to_left_{};
195  const api::Lane* lane_to_right_{};
196 };
197 
198 } // namespace dragway
199 } // namespace maliput
200 } // namespace drake
Eigen::AutoDiffScalar< Eigen::VectorXd > AutoDiffXd
An autodiff variable with a dynamic number of partials.
Definition: eigen_autodiff_types.h:25
A BranchPoint is a node in the network of a RoadGeometry at which Lanes connect to one another...
Definition: branch_point.h:67
Definition: automotive_demo.cc:88
Dragway&#39;s implementation of api::Lane.
Definition: lane.h:75
This file contains abbreviated definitions for certain uses of AutoDiffScalar that are commonly used ...
const double position
Definition: robot_plan_interpolator_test.cc:65
void set_lane_to_right(api::Lane *lane_to_right)
Definition: lane.cc:51
A position in 3-dimensional geographical Cartesian space, i.e., in the world frame, consisting of three components x, y, and z.
Definition: lane_data.h:135
A set of LaneEnds.
Definition: branch_point.h:23
A Lane represents a lane of travel in a road network.
Definition: lane.h:34
stx::optional< T > optional
Definition: drake_optional.h:14
Isometric velocity vector in a Lane-frame.
Definition: lane_data.h:266
int index() const
Returns the index of this Lane within the Segment which owns it.
Definition: lane.h:47
TypeSpecificIdentifier<T> represents an identifier specifically identifying an entity of type T...
Definition: type_specific_identifier.h:38
HBounds elevation_bounds(double s, double r) const
Returns the elevation (h) bounds of the lane as a function of (s, r).
Definition: lane.h:89
const Segment * segment() const
Returns the Segment to which this Lane belongs.
Definition: lane.h:44
GeoPositionT< double > GeoPosition
Definition: lane_data.h:178
Provides drake::optional as an alias for the appropriate implementation of std::optional or std::expe...
Bounds in the lateral dimension (r component) of a Lane-frame, consisting of a pair of minimum and ma...
Definition: lane_data.h:298
A 3-dimensional rotation.
Definition: lane_data.h:52
double y_offset() const
Returns the y-offset of this lane&#39;s frame relative to the world frame.
Definition: lane.h:121
Bounds in the elevation dimension (h component) of a Lane-frame, consisting of a pair of minimum and ...
Definition: lane_data.h:343
A Segment represents a bundle of adjacent Lanes which share a continuously traversable road surface...
Definition: segment.h:27
Which
Labels for the endpoints of a Lane.
Definition: lane_data.h:24
double length() const
Returns the arc-length of the Lane along its reference curve.
Definition: lane.h:69
RBounds driveable_bounds(double s) const
Returns the driveable lateral (r) bounds of the lane as a function of s.
Definition: lane.h:83
RBounds lane_bounds(double s) const
Returns the nominal lateral (r) bounds for the lane as a function of s.
Definition: lane.h:75
#define DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:33
Vector6< double > velocity
Definition: pose_smoother.cc:29
Dragway&#39;s implementation of api::Segment.
Definition: segment.h:55
void set_lane_to_left(api::Lane *lane_to_left)
Definition: lane.cc:47