Drake
segment.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
7 
8 namespace drake {
9 namespace maliput {
10 namespace api {
11 
12 class Junction;
13 class Lane;
14 
15 
16 /// Persistent identifier for a Segment element.
18 
19 
20 /// A Segment represents a bundle of adjacent Lanes which share a
21 /// continuously traversable road surface. Every LanePosition on a
22 /// given Lane of a Segment has a corresponding LanePosition on each
23 /// other Lane, all with the same height-above-surface h, that all
24 /// map to the same GeoPoint in 3-space.
25 ///
26 /// Segments are grouped by Junction.
27 class Segment {
28  public:
30 
31  virtual ~Segment() = default;
32 
33  /// Returns the persistent identifier.
34  const SegmentId id() const { return do_id(); }
35 
36  /// Returns the Junction to which this Segment belongs.
37  const Junction* junction() const { return do_junction(); }
38 
39  /// Returns the number of Lanes contained in this Segment.
40  ///
41  /// Return value is non-negative.
42  int num_lanes() const { return do_num_lanes(); }
43 
44  /// Returns the Lane indexed by @p index.
45  ///
46  /// The indexing order is meaningful; numerically adjacent indices correspond
47  /// to geometrically adjacent Lanes. Indices increase "to the left", i.e.,
48  /// in the direction of increasing `r` coordinate.
49  ///
50  /// @pre @p index must be >= 0 and < num_lanes().
51  const Lane* lane(int index) const { return do_lane(index); }
52 
53  protected:
54  Segment() = default;
55 
56  private:
57  /// @name NVI implementations of the public methods.
58  /// These must satisfy the constraint/invariants of the
59  /// corresponding public methods.
60  ///@{
61  virtual const SegmentId do_id() const = 0;
62 
63  virtual const Junction* do_junction() const = 0;
64 
65  virtual int do_num_lanes() const = 0;
66 
67  virtual const Lane* do_lane(int index) const = 0;
68  ///@}
69 };
70 
71 } // namespace api
72 } // namespace maliput
73 } // namespace drake
Definition: automotive_demo.cc:88
int num_lanes() const
Returns the number of Lanes contained in this Segment.
Definition: segment.h:42
A Lane represents a lane of travel in a road network.
Definition: lane.h:34
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
const SegmentId id() const
Returns the persistent identifier.
Definition: segment.h:34
virtual ~Segment()=default
A Segment represents a bundle of adjacent Lanes which share a continuously traversable road surface...
Definition: segment.h:27
const Lane * lane(int index) const
Returns the Lane indexed by index.
Definition: segment.h:51
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
#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
Provides careful macros to selectively enable or disable the special member functions for copy-constr...