Drake
branch_point.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 #include <vector>
6 
12 
13 namespace drake {
14 namespace maliput {
15 namespace monolane {
16 
17 class BranchPoint;
18 class Lane;
19 
20 
21 /// An implementation of LaneEndSet.
22 class LaneEndSet : public api::LaneEndSet {
23  public:
25 
26  LaneEndSet() = default;
27  ~LaneEndSet() override = default;
28 
29  /// Adds a LaneEnd.
30  void add(const api::LaneEnd& end) { ends_.push_back(end); }
31 
32  private:
33  int do_size() const override { return ends_.size(); }
34 
35  const api::LaneEnd& do_get(int index) const override { return ends_[index]; }
36 
37  std::vector<api::LaneEnd> ends_;
38 };
39 
40 
41 /// An implementation of api::BranchPoint.
42 class BranchPoint : public api::BranchPoint {
43  public:
45 
46  /// Constructs an empty BranchPoint.
47  ///
48  /// @p road_geometry must remain valid for the lifetime of this class.
49  BranchPoint(const api::BranchPointId& id, api::RoadGeometry* road_geometry);
50 
51  /// Adds a LaneEnd to the "A side" of the BranchPoint.
52  const api::LaneEnd& AddABranch(const api::LaneEnd& lane_end);
53 
54  /// Adds a LaneEnd to the "B side" of the BranchPoint.
55  const api::LaneEnd& AddBBranch(const api::LaneEnd& lane_end);
56 
57  /// Sets the default branch for @p lane_end to @p default_branch.
58  ///
59  /// The specified LaneEnds must belong to opposite sides of this BranchPoint.
60  void SetDefault(const api::LaneEnd& lane_end,
61  const api::LaneEnd& default_branch);
62 
63  ~BranchPoint() override = default;
64 
65  private:
66  const api::BranchPointId do_id() const override { return id_; }
67 
68  const api::RoadGeometry* do_road_geometry() const override;
69 
70  const api::LaneEndSet* DoGetConfluentBranches(
71  const api::LaneEnd& end) const override;
72 
73  const api::LaneEndSet* DoGetOngoingBranches(
74  const api::LaneEnd& end) const override;
75 
76  optional<api::LaneEnd> DoGetDefaultBranch(
77  const api::LaneEnd& end) const override;
78 
79  const api::LaneEndSet* DoGetASide() const override { return &a_side_; }
80 
81  const api::LaneEndSet* DoGetBSide() const override { return &b_side_; }
82 
85  LaneEndSet a_side_;
86  LaneEndSet b_side_;
87 
88  std::map<api::LaneEnd, LaneEndSet*,
89  api::LaneEnd::StrictOrder> confluent_branches_;
90  std::map<api::LaneEnd, LaneEndSet*,
91  api::LaneEnd::StrictOrder> ongoing_branches_;
92  std::map<api::LaneEnd, api::LaneEnd,
93  api::LaneEnd::StrictOrder> defaults_;
94 };
95 
96 } // namespace monolane
97 } // namespace maliput
98 } // namespace drake
std::unique_ptr< RoadGeometry > road_geometry_
Definition: dragway_test.cc:336
A BranchPoint is a node in the network of a RoadGeometry at which Lanes connect to one another...
Definition: branch_point.h:67
A specific endpoint of a specific Lane.
Definition: lane_data.h:21
Definition: automotive_demo.cc:88
Abstract API for the geometry of a road network, including both the network topology and the geometry...
Definition: road_geometry.h:26
TypeSpecificIdentifier< class BranchPoint > BranchPointId
Definition: branch_point.h:19
A set of LaneEnds.
Definition: branch_point.h:23
stx::optional< T > optional
Definition: drake_optional.h:14
An arbitrary strict complete ordering, useful for, e.g., std::map.
Definition: lane_data.h:27
Provides drake::optional as an alias for the appropriate implementation of std::optional or std::expe...
An implementation of api::BranchPoint.
Definition: branch_point.h:42
#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
An implementation of LaneEndSet.
Definition: branch_point.h:22
void add(const api::LaneEnd &end)
Adds a LaneEnd.
Definition: branch_point.h:30
Provides careful macros to selectively enable or disable the special member functions for copy-constr...