Go to the documentation of this file.
1 #pragma once
3 #include <functional>
4 #include <memory>
5 #include <utility>
6 #include <vector>
18 namespace drake {
19 namespace maliput {
20 namespace multilane {
22 class ArcLane;
23 class LineLane;
25 /// An api::Segment implementation.
26 class Segment : public api::Segment {
27  public:
30  /// Constructs a new Segment.
31  ///
32  /// The Segment is not fully initialized until NewLane() is called at least
33  /// once. `junction` must remain valid for the lifetime of this class.
34  /// @param id Segment's ID.
35  /// @param junction Parent junction.
36  /// @param register_lane will be called on any new Lane instance created as
37  /// a child of the Segment.
38  /// @param road_curve A curve that defines the reference trajectory over the
39  /// segment. A child Lane object will be constructed from an offset of the
40  /// road_curve's reference curve.
41  /// @param r_min Lateral distance to the minimum extent of road_curve's curve
42  /// from where Segment's surface starts. It must be smaller or equal than
43  /// `r_max`.
44  /// @param r_max Lateral distance to the maximum extent of road_curve's curve
45  /// from where Segment's surface ends. It should be greater or equal than
46  /// `r_min`.
47  /// @param elevation_bounds The height bounds over the segment' surface.
49  const std::function<void(const api::Lane*)>& register_lane,
50  std::unique_ptr<RoadCurve> road_curve, double r_min, double r_max,
52  : id_(id),
53  junction_(junction),
54  register_lane_(register_lane),
55  road_curve_(std::move(road_curve)),
56  r_min_(r_min),
57  r_max_(r_max),
58  elevation_bounds_(elevation_bounds) {
59  DRAKE_DEMAND(road_curve_.get() != nullptr);
60  DRAKE_DEMAND(r_min <= r_max);
61  DRAKE_DEMAND(road_curve_->IsValid(r_min_, r_max_, elevation_bounds_));
63  road_curve_->linear_tolerance());
64  }
66  /// Creates a new Lane object.
67  ///
68  /// Driveable bounds of the lane will be derived based on the lateral offset
69  /// of it so as to reach `r_min` and `r_max` distances (see class constructor
70  /// for more details).
71  /// @param id Lane's ID.
72  /// @param r0 Lateral displacement of the Lane with respect to segment
73  /// RoadCurve's reference curve. It must be greater than `r_min` and smaller
74  /// than `r_max`, and be greater than the last lane's r0 displacement (if
75  /// any).
76  /// @param lane_bounds Nominal bounds of the lane, uniform along the entire
77  /// reference path. It must fit inside segments bounds when those are
78  /// translated to `r0` offset distance.
79  /// @return A Lane object.
80  Lane* NewLane(api::LaneId id, double r0, const api::RBounds& lane_bounds);
82  ~Segment() override = default;
84  private:
85  const api::SegmentId do_id() const override { return id_; }
87  const api::Junction* do_junction() const override;
89  int do_num_lanes() const override { return lanes_.size(); }
91  const api::Lane* do_lane(int index) const override;
93  // Segment's ID.
94  api::SegmentId id_;
95  // Parent junction.
96  const api::Junction* junction_{};
97  std::function<void(const api::Lane*)> register_lane_;
98  // Child Lane vector.
99  std::vector<std::unique_ptr<Lane>> lanes_;
100  // Reference trajectory over the Segment's surface.
101  std::unique_ptr<RoadCurve> road_curve_;
102  // Lateral distance to the minimum extent of road_curve_'s curve from where
103  // Segment's surface starts.
104  const double r_min_{};
105  // Lateral distance to the maximum extent of road_curve_'s curve from where
106  // Segment's surface ends.
107  const double r_max_{};
108  // Elevation bounds over the Segment's surface.
109  const api::HBounds elevation_bounds_;
110 };
112 } // namespace multilane
113 } // namespace maliput
114 } // namespace drake
Definition: bullet_model.cc:22
const RoadGeometry * road_geometry() const
Returns the RoadGeometry to which this Junction belongs.
Definition: junction.h:37
double r0
Definition: multilane_connection_test.cc:368
STL namespace.
Segment(const api::SegmentId &id, const api::Junction *junction, const std::function< void(const api::Lane *)> &register_lane, std::unique_ptr< RoadCurve > road_curve, double r_min, double r_max, const api::HBounds &elevation_bounds)
Constructs a new Segment.
Definition: segment.h:48
Base class for the multilane implementation of api::Lane.
Definition: lane.h:25
A Lane represents a lane of travel in a road network.
Definition: lane.h:35
Definition: arc_road_curve.cc:11
double linear_tolerance() const
Returns the tolerance guaranteed for linear measurements (positions).
Definition: road_geometry.h:120
const Junction * junction() const
Returns the Junction to which this Segment belongs.
Definition: segment.h:37
Provides Drake&#39;s assertion implementation.
Lane * NewLane(api::LaneId id, double r0, const api::RBounds &lane_bounds)
Creates a new Lane object.
Definition: segment.cc:11
#define DRAKE_DEMAND(condition)
Evaluates condition and iff the value is false will trigger an assertion failure with a message showi...
Definition: drake_assert.h:45
const api::HBounds elevation_bounds
Definition: multilane_line_road_curve_test.cc:34
An api::Segment implementation.
Definition: segment.h:26
Bounds in the lateral dimension (r component) of a Lane-frame, consisting of a pair of minimum and ma...
Definition: lane_data.h:315
Bounds in the elevation dimension (h component) of a Lane-frame, consisting of a pair of minimum and ...
Definition: lane_data.h:360
A Segment represents a bundle of adjacent Lanes which share a continuously traversable road surface...
Definition: segment.h:27
A Junction is a closed set of Segments which have physically coplanar road surfaces, in the sense that RoadPositions with the same h value (height above surface) in the domains of two Segments map to the same GeoPosition.
Definition: junction.h:27
TypeSpecificIdentifier< class Segment > SegmentId
Persistent identifier for a Segment element.
Definition: segment.h:17
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
Provides careful macros to selectively enable or disable the special member functions for copy-constr...