Drake
junction.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <functional>
4 #include <memory>
5 #include <vector>
6 
13 
14 namespace drake {
15 namespace maliput {
16 namespace multilane {
17 
18 /// An api::Junction implementation.
19 class Junction : public api::Junction {
20  public:
22 
23  /// Constructs an empty Junction.
24  ///
25  /// @p 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.
28  /// @p register_segment and @p register_lane will be called on any new
29  /// Segment or Lane instances created as children of the Junction.
31  const std::function<void(const api::Segment*)>& register_segment,
32  const std::function<void(const api::Lane*)>& register_lane)
33  : id_(id), road_geometry_(road_geometry),
34  register_segment_(register_segment),
35  register_lane_(register_lane) {}
36 
37  /// Creates and adds a new Segment.
38  /// @param id Segment's ID.
39  /// @param road_curve Reference trajectory over the Segment's surface.
40  /// @param r_min Lateral distance to the minimum extent of road_curve's curve
41  /// from where Segment's surface starts.
42  /// @param r_max Lateral distance to the maximum extent of road_curve's curve
43  /// from where Segment's surface ends.
44  /// @param elevation_bounds The height bounds over the segment' surface.
45  /// @return A Segment object.
47  std::unique_ptr<RoadCurve> road_curve, double r_min,
48  double r_max, const api::HBounds& elevation_bounds);
49 
50  ~Junction() override = default;
51 
52  private:
53  const api::JunctionId do_id() const override { return id_; }
54 
55  const api::RoadGeometry* do_road_geometry() const override;
56 
57  int do_num_segments() const override { return segments_.size(); }
58 
59  const api::Segment* do_segment(int index) const override {
60  return segments_[index].get();
61  }
62 
63  api::JunctionId id_;
64  const api::RoadGeometry* road_geometry_{};
65  std::function<void(const api::Segment*)> register_segment_;
66  std::function<void(const api::Lane*)> register_lane_;
67  std::vector<std::unique_ptr<Segment>> segments_;
68 };
69 
70 } // namespace multilane
71 } // namespace maliput
72 } // namespace drake
Definition: automotive_demo.cc:90
const RoadGeometry * road_geometry() const
Returns the RoadGeometry to which this Junction belongs.
Definition: junction.h:37
Segment * NewSegment(const api::SegmentId &id, std::unique_ptr< RoadCurve > road_curve, double r_min, double r_max, const api::HBounds &elevation_bounds)
Creates and adds a new Segment.
Definition: junction.cc:14
Abstract API for the geometry of a road network, including both the network topology and the geometry...
Definition: road_geometry.h:30
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:30
A Lane represents a lane of travel in a road network.
Definition: lane.h:35
Definition: arc_road_curve.cc:11
const api::HBounds elevation_bounds
Definition: multilane_line_road_curve_test.cc:34
An api::Segment implementation.
Definition: segment.h:26
TypeSpecificIdentifier< class Junction > JunctionId
Persistent identifier for a Junction element.
Definition: junction.h:17
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
An api::Junction implementation.
Definition: junction.h:19
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...