Drake
trajectory_car_params.h
Go to the documentation of this file.
1 #pragma once
2 
3 // GENERATED FILE DO NOT EDIT
4 // See drake/tools/lcm_vector_gen.py.
5 
6 #include <cmath>
7 #include <stdexcept>
8 #include <string>
9 #include <vector>
10 
11 #include <Eigen/Core>
12 
15 
16 namespace drake {
17 namespace automotive {
18 
22  static const int kNumCoordinates = 2;
23 
24  // The index of each individual coordinate.
25  static const int kMaxSpeed = 0;
26  static const int kSpeedLimitKp = 1;
27 
32  static const std::vector<std::string>& GetCoordinateNames();
33 };
34 
36 template <typename T>
38  public:
41 
46  this->set_max_speed(45.0);
47  this->set_speed_limit_kp(10.0);
48  }
49 
50  TrajectoryCarParams<T>* DoClone() const override {
51  return new TrajectoryCarParams;
52  }
53 
55 
56  const T& max_speed() const { return this->GetAtIndex(K::kMaxSpeed); }
60  void set_max_speed(const T& max_speed) {
61  this->SetAtIndex(K::kMaxSpeed, max_speed);
62  }
66  const T& speed_limit_kp() const { return this->GetAtIndex(K::kSpeedLimitKp); }
67  void set_speed_limit_kp(const T& speed_limit_kp) {
68  this->SetAtIndex(K::kSpeedLimitKp, speed_limit_kp);
69  }
71 
73  static const std::vector<std::string>& GetCoordinateNames() {
75  }
76 
78  decltype(T() < T()) IsValid() const {
79  using std::isnan;
80  auto result = (T(0) == T(0));
81  result = result && !isnan(max_speed());
82  result = result && (max_speed() >= T(0.0));
83  result = result && !isnan(speed_limit_kp());
84  result = result && (speed_limit_kp() >= T(0.0));
85  return result;
86  }
87 
88  // VectorBase override.
89  void CalcInequalityConstraint(VectorX<T>* value) const override {
90  value->resize(2);
91  (*value)[0] = max_speed() - T(0.0);
92  (*value)[1] = speed_limit_kp() - T(0.0);
93  }
94 };
95 
96 } // namespace automotive
97 } // namespace drake
static const int kNumCoordinates
The total number of rows (coordinates).
Definition: trajectory_car_params.h:22
void set_max_speed(const T &max_speed)
Definition: trajectory_car_params.h:60
static const int kSpeedLimitKp
Definition: trajectory_car_params.h:26
bool isnan(const Eigen::AutoDiffScalar< DerType > &x)
Overloads isnan to mimic std::isnan from <cmath>.
Definition: autodiff_overloads.h:48
TrajectoryCarParams< T > * DoClone() const override
Returns a new BasicVector containing a copy of the entire vector.
Definition: trajectory_car_params.h:50
Definition: automotive_demo.cc:88
Specializes BasicVector with specific getters and setters.
Definition: trajectory_car_params.h:37
void set_speed_limit_kp(const T &speed_limit_kp)
Definition: trajectory_car_params.h:67
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorX
A column vector of any size, templated on scalar type.
Definition: eigen_types.h:46
TrajectoryCarParams()
Default constructor.
Definition: trajectory_car_params.h:45
static const std::vector< std::string > & GetCoordinateNames()
See TrajectoryCarParamsIndices::GetCoordinateNames().
Definition: trajectory_car_params.h:73
std::vector< Number > result
Definition: ipopt_solver.cc:151
int value
Definition: copyable_unique_ptr_test.cc:61
const T & speed_limit_kp() const
The smoothing constant for min/max speed limits.
Definition: trajectory_car_params.h:66
static const int kMaxSpeed
Definition: trajectory_car_params.h:25
BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.
Definition: basic_vector.h:25
TrajectoryCarParamsIndices K
An abbreviation for our row index constants.
Definition: trajectory_car_params.h:40
void CalcInequalityConstraint(VectorX< T > *value) const override
Populates a vector value suitable for a SystemConstraint inequality constraint.
Definition: trajectory_car_params.h:89
static const std::vector< std::string > & GetCoordinateNames()
Returns a vector containing the names of each coordinate within this class.
Definition: trajectory_car_params.cc:14
Describes the row indices of a TrajectoryCarParams.
Definition: trajectory_car_params.h:20