Drake
bicycle_car_parameters.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 = 6;
23 
24  // The index of each individual coordinate.
25  static const int kMass = 0;
26  static const int kLf = 1;
27  static const int kLr = 2;
28  static const int kIz = 3;
29  static const int kCf = 4;
30  static const int kCr = 5;
31 
36  static const std::vector<std::string>& GetCoordinateNames();
37 };
38 
40 template <typename T>
42  public:
45 
54  this->set_mass(2278.0);
55  this->set_lf(1.292);
56  this->set_lr(1.515);
57  this->set_Iz(3210.0);
58  this->set_Cf(10.8e4);
59  this->set_Cr(10.8e4);
60  }
61 
62  BicycleCarParameters<T>* DoClone() const override {
63  return new BicycleCarParameters;
64  }
65 
67 
68  const T& mass() const { return this->GetAtIndex(K::kMass); }
72  void set_mass(const T& mass) { this->SetAtIndex(K::kMass, mass); }
76  const T& lf() const { return this->GetAtIndex(K::kLf); }
77  void set_lf(const T& lf) { this->SetAtIndex(K::kLf, lf); }
81  const T& lr() const { return this->GetAtIndex(K::kLr); }
82  void set_lr(const T& lr) { this->SetAtIndex(K::kLr, lr); }
86  const T& Iz() const { return this->GetAtIndex(K::kIz); }
87  void set_Iz(const T& Iz) { this->SetAtIndex(K::kIz, Iz); }
91  const T& Cf() const { return this->GetAtIndex(K::kCf); }
92  void set_Cf(const T& Cf) { this->SetAtIndex(K::kCf, Cf); }
96  const T& Cr() const { return this->GetAtIndex(K::kCr); }
97  void set_Cr(const T& Cr) { this->SetAtIndex(K::kCr, Cr); }
99 
101  static const std::vector<std::string>& GetCoordinateNames() {
103  }
104 
106  decltype(T() < T()) IsValid() const {
107  using std::isnan;
108  auto result = (T(0) == T(0));
109  result = result && !isnan(mass());
110  result = result && (mass() >= T(0.0));
111  result = result && !isnan(lf());
112  result = result && (lf() >= T(0.0));
113  result = result && !isnan(lr());
114  result = result && (lr() >= T(0.0));
115  result = result && !isnan(Iz());
116  result = result && (Iz() >= T(0.0));
117  result = result && !isnan(Cf());
118  result = result && (Cf() >= T(0.0));
119  result = result && !isnan(Cr());
120  result = result && (Cr() >= T(0.0));
121  return result;
122  }
123 
124  // VectorBase override.
125  void CalcInequalityConstraint(VectorX<T>* value) const override {
126  value->resize(6);
127  (*value)[0] = mass() - T(0.0);
128  (*value)[1] = lf() - T(0.0);
129  (*value)[2] = lr() - T(0.0);
130  (*value)[3] = Iz() - T(0.0);
131  (*value)[4] = Cf() - T(0.0);
132  (*value)[5] = Cr() - T(0.0);
133  }
134 };
135 
136 } // namespace automotive
137 } // namespace drake
const T & Cf() const
cornering stiffness (front)
Definition: bicycle_car_parameters.h:91
bool isnan(const Eigen::AutoDiffScalar< DerType > &x)
Overloads isnan to mimic std::isnan from <cmath>.
Definition: autodiff_overloads.h:48
static const int kIz
Definition: bicycle_car_parameters.h:28
void set_Cr(const T &Cr)
Definition: bicycle_car_parameters.h:97
BicycleCarParameters< T > * DoClone() const override
Returns a new BasicVector containing a copy of the entire vector.
Definition: bicycle_car_parameters.h:62
const T & lf() const
distance from the center of mass to the front axle
Definition: bicycle_car_parameters.h:76
Definition: automotive_demo.cc:88
void set_lf(const T &lf)
Definition: bicycle_car_parameters.h:77
static const int kLr
Definition: bicycle_car_parameters.h:27
BicycleCarParameters()
Default constructor.
Definition: bicycle_car_parameters.h:53
BicycleCarParametersIndices K
An abbreviation for our row index constants.
Definition: bicycle_car_parameters.h:44
Describes the row indices of a BicycleCarParameters.
Definition: bicycle_car_parameters.h:20
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorX
A column vector of any size, templated on scalar type.
Definition: eigen_types.h:46
static const int kNumCoordinates
The total number of rows (coordinates).
Definition: bicycle_car_parameters.h:22
static const int kCf
Definition: bicycle_car_parameters.h:29
std::vector< Number > result
Definition: ipopt_solver.cc:151
Specializes BasicVector with specific getters and setters.
Definition: bicycle_car_parameters.h:41
int value
Definition: copyable_unique_ptr_test.cc:61
void set_lr(const T &lr)
Definition: bicycle_car_parameters.h:82
const T & Iz() const
moment of inertia about the yaw-axis
Definition: bicycle_car_parameters.h:86
static const int kLf
Definition: bicycle_car_parameters.h:26
void set_mass(const T &mass)
Definition: bicycle_car_parameters.h:72
BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.
Definition: basic_vector.h:25
const T & Cr() const
cornering stiffness (rear)
Definition: bicycle_car_parameters.h:96
void set_Cf(const T &Cf)
Definition: bicycle_car_parameters.h:92
const T & lr() const
distance from the center of mass to the rear axle
Definition: bicycle_car_parameters.h:81
static const int kCr
Definition: bicycle_car_parameters.h:30
void set_Iz(const T &Iz)
Definition: bicycle_car_parameters.h:87
static const std::vector< std::string > & GetCoordinateNames()
See BicycleCarParametersIndices::GetCoordinateNames().
Definition: bicycle_car_parameters.h:101
static const int kMass
Definition: bicycle_car_parameters.h:25
static const std::vector< std::string > & GetCoordinateNames()
Returns a vector containing the names of each coordinate within this class.
Definition: bicycle_car_parameters.cc:18
void CalcInequalityConstraint(VectorX< T > *value) const override
Populates a vector value suitable for a SystemConstraint inequality constraint.
Definition: bicycle_car_parameters.h:125