Drake
lane.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 
11 
12 namespace drake {
13 namespace maliput {
14 namespace rndf {
15 
16 class BranchPoint;
17 
18 /// Base class for the RNDF implementation of api::Lane.
19 ///
20 /// This is the base class for subclasses, each of which describe a
21 /// primitive reference curve in the xy ground-plane of the world frame.
22 /// The specific curve is expressed by a subclass's implementations of
23 /// private virtual functions.
24 ///
25 /// This base implementation will handle all the non-geometric stuff from the
26 /// lane. All geometric computation will be moved to each sub lane childs. See
27 /// SplineLane for an example.
28 class Lane : public api::Lane {
29  public:
31 
32  /// Constructs a Lane.
33  /// @param id is the ID of the api::Lane.
34  /// @param segment is a pointer that refers to its parent, which must remain
35  /// valid for the lifetime of this class.
36  /// @param index is the index that can be used to reference this Lane from
37  /// api::Segment::lane() call.
38  Lane(const api::LaneId& id, const api::Segment* segment, int index)
39  : id_(id), segment_(segment), index_(index) {}
40 
41  /// Sets the pointer of the BranchPoint that contains a
42  /// api::LaneEnd::Which::kStart value attached to this lane pointer.
43  /// @param bp should be a valid BranchPoint pointer.
44  void SetStartBp(BranchPoint* bp) { start_bp_ = bp; }
45 
46  /// Sets the pointer of the BranchPoint that contains a
47  /// api::LaneEnd::Which::kFinish value attached to this lane pointer.
48  /// @param bp should be a valid BranchPoint pointer.
49  void SetEndBp(BranchPoint* bp) { end_bp_ = bp; }
50 
51  /// Getter of the BranchPoint set as starting.
52  /// @return The starting BranchPoint pointer.
53  BranchPoint* start_bp() { return start_bp_; }
54 
55  /// Getter of the BranchPoint set as ending.
56  /// @return The ending BranchPoint pointer.
57  BranchPoint* end_bp() { return end_bp_; }
58 
59  ~Lane() override = default;
60 
61  private:
62  const api::LaneId do_id() const override { return id_; }
63 
64  const api::Segment* do_segment() const override;
65 
66  int do_index() const override { return index_; }
67 
68  const api::Lane* do_to_left() const override {
69  if ((segment_->num_lanes() - 1) == index_) {
70  return nullptr;
71  }
72  return segment_->lane(index_ + 1);
73  }
74 
75  const api::Lane* do_to_right() const override {
76  if (index_ == 0) {
77  return nullptr;
78  }
79  return segment_->lane(index_ - 1);
80  }
81 
82  const api::BranchPoint* DoGetBranchPoint(
83  const api::LaneEnd::Which which_end) const override;
84 
85  const api::LaneEndSet* DoGetConfluentBranches(
86  const api::LaneEnd::Which which_end) const override;
87 
88  const api::LaneEndSet* DoGetOngoingBranches(
89  const api::LaneEnd::Which which_end) const override;
90 
91  optional<api::LaneEnd> DoGetDefaultBranch(
92  const api::LaneEnd::Which which_end) const override;
93 
94  const api::LaneId id_;
95  const api::Segment* segment_{};
96  BranchPoint* start_bp_{};
97  BranchPoint* end_bp_{};
98  const int index_{};
99 };
100 
101 } // namespace rndf
102 } // namespace maliput
103 } // namespace drake
BranchPoint * end_bp()
Getter of the BranchPoint set as ending.
Definition: lane.h:57
A BranchPoint is a node in the network of a RoadGeometry at which Lanes connect to one another...
Definition: branch_point.h:67
BranchPoint * start_bp()
Getter of the BranchPoint set as starting.
Definition: lane.h:53
Definition: automotive_demo.cc:88
~Lane() override=default
An api::Segment implementation for RNDF.
Definition: segment.h:23
Definition: branch_point.cc:7
int num_lanes() const
Returns the number of Lanes contained in this Segment.
Definition: segment.h:42
A set of LaneEnds.
Definition: branch_point.h:23
A Lane represents a lane of travel in a road network.
Definition: lane.h:34
Base class for the RNDF implementation of api::Lane.
Definition: lane.h:28
stx::optional< T > optional
Definition: drake_optional.h:14
int index() const
Returns the index of this Lane within the Segment which owns it.
Definition: lane.h:47
TypeSpecificIdentifier<T> represents an identifier specifically identifying an entity of type T...
Definition: type_specific_identifier.h:38
void SetStartBp(BranchPoint *bp)
Sets the pointer of the BranchPoint that contains a api::LaneEnd::Which::kStart value attached to thi...
Definition: lane.h:44
TypeSpecificIdentifier< class Lane > LaneId
Persistent identifier for a Lane element.
Definition: lane.h:22
const Segment * segment() const
Returns the Segment to which this Lane belongs.
Definition: lane.h:44
Provides drake::optional as an alias for the appropriate implementation of std::optional or std::expe...
A Segment represents a bundle of adjacent Lanes which share a continuously traversable road surface...
Definition: segment.h:27
const Lane * lane(int index) const
Returns the Lane indexed by index.
Definition: segment.h:51
Which
Labels for the endpoints of a Lane.
Definition: lane_data.h:24
An implementation of api::BranchPoint for RNDF.
Definition: branch_point.h:40
void SetEndBp(BranchPoint *bp)
Sets the pointer of the BranchPoint that contains a api::LaneEnd::Which::kFinish value attached to th...
Definition: lane.h:49
#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...