Go to the documentation of this file.
1 #pragma once
3 #include <functional>
4 #include <memory>
5 #include <vector>
13 namespace drake {
14 namespace maliput {
15 namespace monolane {
17 /// An api::Junction implementation.
18 class Junction : public api::Junction {
19  public:
22  /// Constructs an empty Junction.
23  ///
24  /// @p road_geometry must remain valid for the lifetime of this class,
25  /// and must refer to the RoadGeometry which will contain the newly
26  /// constructed Junction instance.
27  /// @p register_segment and @p register_lane will be called on any new
28  /// Segment or Lane instances created as children of the Junction.
30  const std::function<void(const api::Segment*)>& register_segment,
31  const std::function<void(const api::Lane*)>& register_lane)
32  : id_(id), road_geometry_(road_geometry),
33  register_segment_(register_segment),
34  register_lane_(register_lane) {}
36  /// Creates and adds a new Segment with the specified @p id.
39  ~Junction() override = default;
41  private:
42  const api::JunctionId do_id() const override { return id_; }
44  const api::RoadGeometry* do_road_geometry() const override;
46  int do_num_segments() const override { return segments_.size(); }
48  const api::Segment* do_segment(int index) const override {
49  return segments_[index].get();
50  }
52  api::JunctionId id_;
53  const api::RoadGeometry* road_geometry_{};
54  std::function<void(const api::Segment*)> register_segment_;
55  std::function<void(const api::Lane*)> register_lane_;
56  std::vector<std::unique_ptr<Segment>> segments_;
57 };
59 } // namespace monolane
60 } // namespace maliput
61 } // namespace drake
Junction(const api::JunctionId &id, const api::RoadGeometry *road_geometry, const std::function< void(const api::Segment *)> &register_segment, const std::function< void(const api::Lane *)> &register_lane)
Constructs an empty Junction.
Definition: junction.h:29
Definition: bullet_model.cc:22
const RoadGeometry * road_geometry() const
Returns the RoadGeometry to which this Junction belongs.
Definition: junction.h:37
Abstract API for the geometry of a road network, including both the network topology and the geometry...
Definition: road_geometry.h:30
Segment * NewSegment(api::SegmentId id)
Creates and adds a new Segment with the specified id.
Definition: junction.cc:12
A Lane represents a lane of travel in a road network.
Definition: lane.h:35
TypeSpecificIdentifier< class Junction > JunctionId
Persistent identifier for a Junction element.
Definition: junction.h:17
An api::Segment implementation.
Definition: segment.h:20
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...