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 rndf {
16 
17 class BranchPoint;
18 class Lane;
19 
20 /// An implementation of LaneEndSet for RNDF.
21 class LaneEndSet : public api::LaneEndSet {
22  public:
24 
25  LaneEndSet() = default;
26  ~LaneEndSet() override = default;
27 
28  /// Adds a LaneEnd.
29  void add(const api::LaneEnd& end) { ends_.push_back(end); }
30 
31  private:
32  int do_size() const override { return ends_.size(); }
33 
34  const api::LaneEnd& do_get(int index) const override { return ends_[index]; }
35 
36  std::vector<api::LaneEnd> ends_;
37 };
38 
39 /// An implementation of api::BranchPoint for RNDF.
40 class BranchPoint : public api::BranchPoint {
41  public:
43 
44  /// Constructs an empty BranchPoint.
45  ///
46  /// @param id is the ID of the BranchPoint.
47  /// @param road_geometry is a pointer to the parent api::RoadGeometry, which
48  /// 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*, api::LaneEnd::StrictOrder>
89  confluent_branches_;
90  std::map<api::LaneEnd, LaneEndSet*, api::LaneEnd::StrictOrder>
91  ongoing_branches_;
92  std::map<api::LaneEnd, api::LaneEnd, api::LaneEnd::StrictOrder> defaults_;
93 };
94 
95 } // namespace rndf
96 } // namespace maliput
97 } // 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
~LaneEndSet() 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
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
Provides drake::optional as an alias for the appropriate implementation of std::optional or std::expe...
void add(const api::LaneEnd &end)
Adds a LaneEnd.
Definition: branch_point.h:29
An implementation of api::BranchPoint for RNDF.
Definition: branch_point.h:40
An implementation of LaneEndSet for RNDF.
Definition: branch_point.h:21
#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...