Drake
Go to the documentation of this file.
1 #pragma once
2
3 #include "drake/automotive/lane_direction.h"
5 #include "drake/common/drake_copyable.h"
6 #include "drake/common/eigen_types.h"
7 #include "drake/common/trajectories/piecewise_polynomial.h"
8
9 namespace drake {
10 namespace automotive {
11
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>
30  public:
32
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);
44
45  const PiecewisePolynomial<T>& get_path() const;
46
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)
50  const T GetClosestPathPosition(const Vector3<T>& geo_position,
51  const T& s_guess) const;
52
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 PiecewisePolynomial<T> MakePiecewisePolynomial(
62  const LaneDirection& initial_lane_direction, const T& step_size,
63  int num_breaks) const;
64
65  PiecewisePolynomial<T> path_; // The path representing the mid-curve of the
67  PiecewisePolynomial<T> path_prime_; // First derivative of path_.
68  PiecewisePolynomial<T> path_double_prime_; // Second derivative of path_.
69 };
70
71 } // namespace automotive
72 } // namespace drake
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: automotive_demo.cc:89
RoadPath converts a sequence of Maliput Lanes into a PiecewisePolynomial for the purpose of generatin...