Go to the documentation of this file.
1 #pragma once
3 #include <memory>
4 #include <utility>
5 #include <vector>
16 namespace drake {
17 namespace maliput {
18 namespace multilane {
20 class ArcLane;
21 class LineLane;
23 /// An api::Segment implementation.
24 class Segment : public api::Segment {
25  public:
28  /// Constructs a new Segment.
29  ///
30  /// The Segment is not fully initialized until NewLane() is called at least
31  /// once. `junction` must remain valid for the lifetime of this class.
32  /// @param id Segment's ID.
33  /// @param junction Parent junction.
34  /// @param road_curve A curve that defines the reference trajectory over the
35  /// segment. A child Lane object will be constructed from an offset of the
36  /// road_curve's reference curve.
37  /// @param r_min Lateral distance to the minimum extent of road_curve's curve
38  /// from where Segment's surface starts. It must be smaller or equal than
39  /// `r_max`.
40  /// @param r_max Lateral distance to the maximum extent of road_curve's curve
41  /// from where Segment's surface ends. It should be greater or equal than
42  /// `r_min`.
43  /// @param elevation_bounds The height bounds over the segment' surface.
44  Segment(const api::SegmentId& id, api::Junction* junction,
45  std::unique_ptr<RoadCurve> road_curve, double r_min, double r_max,
46  const api::HBounds& elevation_bounds)
47  : id_(id),
48  junction_(junction),
49  road_curve_(std::move(road_curve)),
50  r_min_(r_min),
51  r_max_(r_max),
52  elevation_bounds_(elevation_bounds) {
53  DRAKE_DEMAND(road_curve_.get() != nullptr);
54  DRAKE_DEMAND(r_min <= r_max);
55  DRAKE_DEMAND(road_curve_->IsValid(r_min_, r_max_, elevation_bounds_));
56  }
58  /// Creates a new Lane object.
59  ///
60  /// Driveable bounds of the lane will be derived based on the lateral offset
61  /// of it so as to reach `r_min` and `r_max` distances (see class constructor
62  /// for more details).
63  /// @param id Lane's ID.
64  /// @param r0 Lateral displacement of the Lane with respect to segment
65  /// RoadCurve's reference curve. It must be greater than `r_min` and smaller
66  /// than `r_max`, and be greater than the last lane's r0 displacement (if
67  /// any).
68  /// @param lane_bounds Nominal bounds of the lane, uniform along the entire
69  /// reference path. It must fit inside segments bounds when those are
70  /// translated to `r0` offset distance.
71  /// @return A Lane object.
72  Lane* NewLane(api::LaneId id, double r0, const api::RBounds& lane_bounds);
74  ~Segment() override = default;
76  private:
77  const api::SegmentId do_id() const override { return id_; }
79  const api::Junction* do_junction() const override;
81  int do_num_lanes() const override { return lanes_.size(); }
83  const api::Lane* do_lane(int index) const override;
85  // Segment's ID.
86  api::SegmentId id_;
87  // Parent junction.
88  api::Junction* junction_{};
89  // Child Lane vector.
90  std::vector<std::unique_ptr<Lane>> lanes_;
91  // Reference trajectory over the Segment's surface.
92  std::unique_ptr<RoadCurve> road_curve_;
93  // Lateral distance to the minimum extent of road_curve_'s curve from where
94  // Segment's surface starts.
95  const double r_min_{};
96  // Lateral distance to the maximum extent of road_curve_'s curve from where
97  // Segment's surface ends.
98  const double r_max_{};
99  // Elevation bounds over the Segment's surface.
100  const api::HBounds elevation_bounds_;
101 };
103 } // namespace multilane
104 } // namespace maliput
105 } // namespace drake
Definition: automotive_demo.cc:88
STL namespace.
Defines an interface for a path in a Segment object surface.
Definition: road_curve.h:92
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:34
Definition: arc_road_curve.cc:11
TypeSpecificIdentifier<T> represents an identifier specifically identifying an entity of type T...
Definition: type_specific_identifier.h:38
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
An api::Segment implementation.
Definition: segment.h:24
Bounds in the lateral dimension (r component) of a Lane-frame, consisting of a pair of minimum and ma...
Definition: lane_data.h:298
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
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
An api::Junction implementation.
Definition: junction.h:18
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...