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.
50  const api::RoadGeometry* road_geometry);
51 
52  /// Adds a LaneEnd to the "A side" of the BranchPoint.
53  const api::LaneEnd& AddABranch(const api::LaneEnd& lane_end);
54 
55  /// Adds a LaneEnd to the "B side" of the BranchPoint.
56  const api::LaneEnd& AddBBranch(const api::LaneEnd& lane_end);
57 
58  /// Sets the default branch for @p lane_end to @p default_branch.
59  ///
60  /// The specified LaneEnds must belong to opposite sides of this BranchPoint.
61  void SetDefault(const api::LaneEnd& lane_end,
62  const api::LaneEnd& default_branch);
63 
64  ~BranchPoint() override = default;
65 
66  private:
67  const api::BranchPointId do_id() const override { return id_; }
68 
69  const api::RoadGeometry* do_road_geometry() const override;
70 
71  const api::LaneEndSet* DoGetConfluentBranches(
72  const api::LaneEnd& end) const override;
73 
74  const api::LaneEndSet* DoGetOngoingBranches(
75  const api::LaneEnd& end) const override;
76 
77  optional<api::LaneEnd> DoGetDefaultBranch(
78  const api::LaneEnd& end) const override;
79 
80  const api::LaneEndSet* DoGetASide() const override { return &a_side_; }
81 
82  const api::LaneEndSet* DoGetBSide() const override { return &b_side_; }
83 
86  LaneEndSet a_side_;
87  LaneEndSet b_side_;
88 
89  std::map<api::LaneEnd, LaneEndSet*,
90  api::LaneEnd::StrictOrder> confluent_branches_;
91  std::map<api::LaneEnd, LaneEndSet*,
92  api::LaneEnd::StrictOrder> ongoing_branches_;
93  std::map<api::LaneEnd, api::LaneEnd,
94  api::LaneEnd::StrictOrder> defaults_;
95 };
96 
97 } // namespace monolane
98 } // namespace maliput
99 } // namespace drake
std::unique_ptr< RoadGeometry > road_geometry_
Definition: dragway_test.cc:337
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:24
Definition: bullet_model.cc:22
Abstract API for the geometry of a road network, including both the network topology and the geometry...
Definition: road_geometry.h:30
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:22
An arbitrary strict complete ordering, useful for, e.g., std::map.
Definition: lane_data.h:30
Provides drake::optional as an alias for the appropriate implementation of std::optional or std::expe...
optional< api::LaneEnd::Which > end
Definition: loader.cc:42
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...