Go to the documentation of this file.
1 #pragma once
9 namespace drake {
10 namespace automotive {
12 /// RoadPath converts a sequence of Maliput Lanes into a PiecewisePolynomial for
13 /// the purpose of generating a path for a car to follow. The path is created
14 /// from the start of a user-specified initial lane and direction of travel, and
15 /// proceeds in that direction until either the end of the road is reached
16 /// (there exist no ongoing lanes), or the given number of specified breaks have
17 /// been traversed. The resulting path is a cubic spline that matches the `r =
18 /// 0` coordinate of the lanes at each specified break point. The resulting
19 /// piecewise curve is C2-continuous throughout with zero first and second
20 /// derivatives at the start and end of the path.
21 ///
22 /// This class is explicitly instantiated for the following scalar types. No
23 /// other scalar types are supported.
24 /// - double
25 ///
26 /// @tparam T The vector element type, which must be a valid Eigen scalar.
27 /// Only double is supported.
28 template <typename T>
29 class RoadPath {
30  public:
33  /// Constructs a single RoadPath from a sequence of Maliput lanes based on the
34  /// following parameters:
35  /// @param initial_lane_direction contains the initial LaneDirection. This
36  /// must be a valid @p road Lane.
37  /// @param step_size is the size of each step (in the `s`-direction) between
38  /// knot points.
39  /// @param num_breaks are the number of breaks at which the knot points will
40  /// be evaluated.
41  RoadPath(const LaneDirection& initial_lane_direction, const T& step_size,
42  int num_breaks);
43  ~RoadPath();
47  /// Computes the closest `s`-position on the path to an arbitrary point in
48  /// the world frame of the provided Maliput Lanes. (Not yet implemented)
49  // TODO(jadecastro): Implement this.
50  const T GetClosestPathPosition(const Vector3<T>& geo_position,
51  const T& s_guess) const;
53  private:
54  // Traverse the road, starting from an initial LaneDirection, and build a
55  // cubic spline PiecewisePolynomial until 1) a given a number of segments has
56  // been traversed, or 2) the end of the road has been reached.
57  //
58  // If a BranchPoint is encountered in which there is more than one ongoing
59  // lane, the zero-index lane is always selected.
60  // TODO(jadecastro): Use Lane::GetDefaultBranch() to decide the ongoing Lane.
61  const trajectories::PiecewisePolynomial<T> MakePiecewisePolynomial(
62  const LaneDirection& initial_lane_direction, const T& step_size,
63  int num_breaks) const;
65  // The path representing the mid-curve of the road.
68  // First derivative of path_.
71  // Second derivative of path_.
72  trajectories::PiecewisePolynomial<T> path_double_prime_;
73 };
75 } // namespace automotive
76 } // namespace drake
This file contains abbreviated definitions for certain specializations of Eigen::Matrix that are comm...
const T GetClosestPathPosition(const Vector3< T > &geo_position, const T &s_guess) const
Computes the closest s-position on the path to an arbitrary point in the world frame of the provided ...
Definition: road_path.cc:40
Definition: automotive_demo.cc:90
RoadPath converts a sequence of Maliput Lanes into a PiecewisePolynomial for the purpose of generatin...
Definition: road_path.h:29
RoadPath(const RoadPath &)=default
Eigen::Matrix< Scalar, 3, 1 > Vector3
A column vector of size 3, templated on scalar type.
Definition: eigen_types.h:34
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN defaults the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:57
A scalar multi-variate piecewise polynomial.
Definition: piecewise_polynomial.h:47
LaneDirection holds the lane that a MaliputRailcar is traversing and the direction in which it is mov...
Definition: lane_direction.h:13
Definition: road_path.cc:32
const trajectories::PiecewisePolynomial< T > & get_path() const
Definition: road_path.cc:35
Provides careful macros to selectively enable or disable the special member functions for copy-constr...