Drake
segment.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <tuple>
5 #include <vector>
6 
7 #include "ignition/math/Vector3.hh"
8 
15 
16 namespace drake {
17 namespace maliput {
18 namespace rndf {
19 
20 class SplineLane;
21 
22 /// An api::Segment implementation for RNDF.
23 class Segment : public api::Segment {
24  public:
26 
27  /// Constructs a new Segment.
28  /// @param id This segment's ID.
29  /// @param junction The api::Junction that contains this Segment. It must
30  /// remain valid for the lifetime of this object.
31  Segment(const api::SegmentId& id, api::Junction* junction)
32  : id_(id), junction_(junction) {}
33 
34  /// Gives the segment a newly constructed SplineLane.
35  ///
36  /// @param id The lane's ID.
37  /// @param control_points A vector of tuples that hold the point (first
38  /// element) and the tangent (second element) at that point to construct the
39  /// spline based lane. The size should be at least two pairs.
40  /// @param width The width specified by the RNDF lane_width
41  /// parameter. Later, this value will be used to construct the
42  /// api::Lane::lane_bounds() and the api::Lane::driveable_bounds() result.
43  /// @return a pointer to a valid SplineLane that was added to this Segment.
44  /// @throws std::runtime_error When @p control_points' size is less than 2.
46  const api::LaneId& id,
47  const std::vector<std::tuple<ignition::math::Vector3d,
48  ignition::math::Vector3d>>& control_points,
49  double width);
50 
51  ~Segment() override = default;
52 
53  private:
54  const api::SegmentId do_id() const override { return id_; }
55 
56  const api::Junction* do_junction() const override { return junction_; }
57 
58  int do_num_lanes() const override { return lanes_.size(); }
59 
60  // Throws an exception if the index is not in between 0 and the size of
61  // lanes_ minus one.
62  const api::Lane* do_lane(int index) const override;
63 
64  api::SegmentId id_;
65  api::Junction* junction_{};
66  std::vector<std::unique_ptr<Lane>> lanes_;
67 };
68 
69 } // namespace rndf
70 } // namespace maliput
71 } // namespace drake
Specialization of drake::maliput::rndf::Lane with a spline curve as its reference path...
Definition: spline_lane.h:25
Definition: automotive_demo.cc:88
An api::Segment implementation for RNDF.
Definition: segment.h:23
Definition: branch_point.cc:7
std::vector< double > vector
Definition: translator_test.cc:20
A Lane represents a lane of travel in a road network.
Definition: lane.h:34
TypeSpecificIdentifier<T> represents an identifier specifically identifying an entity of type T...
Definition: type_specific_identifier.h:38
const Junction * junction() const
Returns the Junction to which this Segment belongs.
Definition: segment.h:37
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 for RNDF.
Definition: junction.h:18
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
SplineLane * NewSplineLane(const api::LaneId &id, const std::vector< std::tuple< ignition::math::Vector3d, ignition::math::Vector3d >> &control_points, double width)
Gives the segment a newly constructed SplineLane.
Definition: segment.cc:11
~Segment() override=default
Provides careful macros to selectively enable or disable the special member functions for copy-constr...