Drake
line_road_curve.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cmath>
4 #include <utility>
5 
12 #include "drake/common/unused.h"
13 
14 namespace drake {
15 namespace maliput {
16 namespace multilane {
17 
19 class LineRoadCurve : public RoadCurve {
20  public:
22 
23 
24  explicit LineRoadCurve(const Vector2<double>& xy0, const Vector2<double>& dxy,
36  : RoadCurve(elevation, superelevation),
37  p0_(xy0),
38  dp_(dxy),
39  heading_(std::atan2(dxy.y(), dxy.x())) {
40  DRAKE_DEMAND(dxy.norm() > kMinimumNorm);
41  }
42 
43  ~LineRoadCurve() override = default;
44 
45  Vector2<double> xy_of_p(double p) const override { return p0_ + p * dp_; }
46 
47  Vector2<double> xy_dot_of_p(double p) const override {
48  unused(p);
49  return dp_;
50  }
51 
52  double heading_of_p(double p) const override {
53  unused(p);
54  return heading_;
55  }
56 
57  double heading_dot_of_p(double p) const override {
58  unused(p);
59  return 0.;
60  }
61 
62  double p_scale() const override { return dp_.norm(); }
63 
65  const Vector3<double>& geo_coordinate,
66  const api::RBounds& lateral_bounds,
67  const api::HBounds& height_bounds) const override;
68 
77  bool IsValid(
78  const api::RBounds& lateral_bounds,
79  const api::HBounds& height_bounds) const override {
80  unused(lateral_bounds);
81  unused(height_bounds);
82  return true;
83  }
84 
85  private:
86  // The first point in world coordinates over the z=0 plane of the reference
87  // curve.
88  const Vector2<double> p0_{};
89  // The difference vector that joins the end point of the reference curve with
90  // the first one, p0_.
91  const Vector2<double> dp_{};
92  // The constant angle deviation of dp_ with respect to the x axis of the world
93  // frame.
94  const double heading_{};
95  // The minimum dp_ norm to avoid having issues when computing heading_.
96  static const double kMinimumNorm;
97 };
98 
99 } // namespace multilane
100 } // namespace maliput
101 } // namespace drake
Vector2< double > xy_dot_of_p(double p) const override
Computes the first derivative of the reference curve.
Definition: line_road_curve.h:47
This file contains abbreviated definitions for certain specializations of Eigen::Matrix that are comm...
Provides a convenient wrapper to throw an exception when a condition is unmet.
Definition: automotive_demo.cc:88
RoadCurve specification for a reference curve that describes a line.
Definition: line_road_curve.h:19
Expression atan2(const Expression &e1, const Expression &e2)
Definition: symbolic_expression.cc:652
Eigen::Matrix< Scalar, 2, 1 > Vector2
A column vector of size 2, templated on scalar type.
Definition: eigen_types.h:30
const CubicPolynomial & elevation() const
Definition: road_curve.h:30
double heading_dot_of_p(double p) const override
Computes the first derivative heading of the reference curve.
Definition: line_road_curve.h:57
Defines an interface for a path in a Segment object surface.
Definition: road_curve.h:24
double heading_of_p(double p) const override
Computes the heading of the reference curve.
Definition: line_road_curve.h:52
Definition: arc_road_curve.cc:11
double p_scale() const override
Computes the path length integral of the reference curve for the interval [0;1] of p...
Definition: line_road_curve.h:62
Provides Drake&#39;s assertion implementation.
#define DRAKE_DEMAND(condition)
Evaluates condition and iff the value is false will trigger an assertion failure with a message showi...
Definition: drake_assert.h:47
Vector2< double > xy_of_p(double p) const override
Computes the reference curve.
Definition: line_road_curve.h:45
Bounds in the lateral dimension (r component) of a Lane-frame, consisting of a pair of minimum and ma...
Definition: lane_data.h:274
A cubic polynomial, f(p) = a + b*p + c*p^2 + d*p^3.
Definition: cubic_polynomial.h:13
Bounds in the elevation dimension (h component) of a Lane-frame, consisting of a pair of minimum and ...
Definition: lane_data.h:309
RoadCurve(const RoadCurve &)=delete
const CubicPolynomial & superelevation() const
Definition: road_curve.h:32
LineRoadCurve(const LineRoadCurve &)=delete
#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:35
bool IsValid(const api::RBounds &lateral_bounds, const api::HBounds &height_bounds) const override
As the reference curve is a line, the curvature radius is infinity at any point in the range of p = [...
Definition: line_road_curve.h:77
void unused(const Args &...)
Documents the argument(s) as unused, placating GCC&#39;s -Wunused-parameter warning.
Definition: unused.h:53
Provides careful macros to selectively enable or disable the special member functions for copy-constr...
Vector3< double > ToCurveFrame(const Vector3< double > &geo_coordinate, const api::RBounds &lateral_bounds, const api::HBounds &height_bounds) const override
Converts a geo_coordinate in the world frame to the composed curve frame, i.e., the superposition of ...
Definition: line_road_curve.cc:11