Drake
junction.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 
12 
13 namespace drake {
14 namespace maliput {
15 namespace rndf {
16 
17 /// An api::Junction implementation for RNDF.
18 class Junction : public api::Junction {
19  public:
21 
22  /// Constructs an empty Junction.
23  ///
24  /// @param id is the ID of the Junction.
25  /// @param road_geometry must remain valid for the lifetime of this class,
26  /// and must refer to the RoadGeometry which will contain the newly
27  /// constructed Junction instance.
29  : id_(id), road_geometry_(road_geometry) {}
30 
31  /// Creates and adds a new Segment with the specified @p id.
32  ///
33  /// @param id is the ID of the segment.
35 
36  ~Junction() override = default;
37 
38  private:
39  const api::JunctionId do_id() const override { return id_; }
40 
41  const api::RoadGeometry* do_road_geometry() const override {
42  return road_geometry_;
43  }
44 
45  int do_num_segments() const override { return segments_.size(); }
46 
47  // Throws an exception in case the index is not in between zero and the
48  // number of segments.
49  const api::Segment* do_segment(int index) const override {
50  DRAKE_THROW_UNLESS(index >= 0 &&
51  index < static_cast<int>(segments_.size()));
52  return segments_[index].get();
53  }
54 
55  api::JunctionId id_;
56  api::RoadGeometry* road_geometry_{};
57  std::vector<std::unique_ptr<Segment>> segments_;
58 };
59 
60 } // namespace rndf
61 } // namespace maliput
62 } // namespace drake
Provides a convenient wrapper to throw an exception when a condition is unmet.
An api::RoadGeometry implementation for RNDF specification.
Definition: road_geometry.h:24
Definition: automotive_demo.cc:88
An api::Segment implementation for RNDF.
Definition: segment.h:23
const RoadGeometry * road_geometry() const
Returns the RoadGeometry to which this Junction belongs.
Definition: junction.h:37
~Junction() override=default
Definition: branch_point.cc:7
Abstract API for the geometry of a road network, including both the network topology and the geometry...
Definition: road_geometry.h:26
#define DRAKE_THROW_UNLESS(condition)
Evaluates condition and iff the value is false will throw an exception with a message showing at leas...
Definition: drake_throw.h:23
Segment * NewSegment(api::SegmentId id)
Creates and adds a new Segment with the specified id.
Definition: junction.cc:9
TypeSpecificIdentifier< class Junction > JunctionId
Persistent identifier for a Junction element.
Definition: junction.h:17
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 for RNDF.
Definition: junction.h:18
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...