Drake
simple_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 = 6;
23 
24  // The index of each individual coordinate.
25  static const int kWheelbase = 0;
26  static const int kTrack = 1;
27  static const int kMaxAbsSteeringAngle = 2;
28  static const int kMaxVelocity = 3;
29  static const int kMaxAcceleration = 4;
30  static const int kVelocityLimitKp = 5;
31 
36  static const std::vector<std::string>& GetCoordinateNames();
37 };
38 
40 template <typename T>
42  public:
45 
54  this->set_wheelbase(2.700);
55  this->set_track(1.521);
56  this->set_max_abs_steering_angle(0.471);
57  this->set_max_velocity(45.0);
58  this->set_max_acceleration(4.0);
59  this->set_velocity_limit_kp(10.0);
60  }
61 
62  SimpleCarParams<T>* DoClone() const override { return new SimpleCarParams; }
63 
65 
66  const T& wheelbase() const { return this->GetAtIndex(K::kWheelbase); }
70  void set_wheelbase(const T& wheelbase) {
71  this->SetAtIndex(K::kWheelbase, wheelbase);
72  }
76  const T& track() const { return this->GetAtIndex(K::kTrack); }
77  void set_track(const T& track) { this->SetAtIndex(K::kTrack, track); }
83  const T& max_abs_steering_angle() const {
84  return this->GetAtIndex(K::kMaxAbsSteeringAngle);
85  }
86  void set_max_abs_steering_angle(const T& max_abs_steering_angle) {
87  this->SetAtIndex(K::kMaxAbsSteeringAngle, max_abs_steering_angle);
88  }
92  const T& max_velocity() const { return this->GetAtIndex(K::kMaxVelocity); }
93  void set_max_velocity(const T& max_velocity) {
94  this->SetAtIndex(K::kMaxVelocity, max_velocity);
95  }
99  const T& max_acceleration() const {
100  return this->GetAtIndex(K::kMaxAcceleration);
101  }
102  void set_max_acceleration(const T& max_acceleration) {
103  this->SetAtIndex(K::kMaxAcceleration, max_acceleration);
104  }
108  const T& velocity_limit_kp() const {
109  return this->GetAtIndex(K::kVelocityLimitKp);
110  }
111  void set_velocity_limit_kp(const T& velocity_limit_kp) {
112  this->SetAtIndex(K::kVelocityLimitKp, velocity_limit_kp);
113  }
115 
117  static const std::vector<std::string>& GetCoordinateNames() {
119  }
120 
122  decltype(T() < T()) IsValid() const {
123  using std::isnan;
124  auto result = (T(0) == T(0));
125  result = result && !isnan(wheelbase());
126  result = result && (wheelbase() >= T(0.0));
127  result = result && !isnan(track());
128  result = result && (track() >= T(0.0));
129  result = result && !isnan(max_abs_steering_angle());
130  result = result && (max_abs_steering_angle() >= T(0.0));
131  result = result && !isnan(max_velocity());
132  result = result && (max_velocity() >= T(0.0));
133  result = result && !isnan(max_acceleration());
134  result = result && (max_acceleration() >= T(0.0));
135  result = result && !isnan(velocity_limit_kp());
136  result = result && (velocity_limit_kp() >= T(0.0));
137  return result;
138  }
139 
140  // VectorBase override.
141  void CalcInequalityConstraint(VectorX<T>* value) const override {
142  value->resize(6);
143  (*value)[0] = wheelbase() - T(0.0);
144  (*value)[1] = track() - T(0.0);
145  (*value)[2] = max_abs_steering_angle() - T(0.0);
146  (*value)[3] = max_velocity() - T(0.0);
147  (*value)[4] = max_acceleration() - T(0.0);
148  (*value)[5] = velocity_limit_kp() - T(0.0);
149  }
150 };
151 
152 } // namespace automotive
153 } // namespace drake
static const int kMaxAbsSteeringAngle
Definition: simple_car_params.h:27
static const int kVelocityLimitKp
Definition: simple_car_params.h:30
bool isnan(const Eigen::AutoDiffScalar< DerType > &x)
Overloads isnan to mimic std::isnan from <cmath>.
Definition: autodiff_overloads.h:48
SimpleCarParams()
Default constructor.
Definition: simple_car_params.h:53
void set_velocity_limit_kp(const T &velocity_limit_kp)
Definition: simple_car_params.h:111
void set_max_velocity(const T &max_velocity)
Definition: simple_car_params.h:93
void set_track(const T &track)
Definition: simple_car_params.h:77
Definition: automotive_demo.cc:88
const T & track() const
The distance between the center of two wheels on the same axle.
Definition: simple_car_params.h:76
void set_max_acceleration(const T &max_acceleration)
Definition: simple_car_params.h:102
static const int kNumCoordinates
The total number of rows (coordinates).
Definition: simple_car_params.h:22
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorX
A column vector of any size, templated on scalar type.
Definition: eigen_types.h:46
SimpleCarParamsIndices K
An abbreviation for our row index constants.
Definition: simple_car_params.h:44
static const int kTrack
Definition: simple_car_params.h:26
static const int kMaxAcceleration
Definition: simple_car_params.h:29
static const int kWheelbase
Definition: simple_car_params.h:25
void set_wheelbase(const T &wheelbase)
Definition: simple_car_params.h:70
std::vector< Number > result
Definition: ipopt_solver.cc:151
int value
Definition: copyable_unique_ptr_test.cc:61
const T & velocity_limit_kp() const
The smoothing constant for min/max velocity limits.
Definition: simple_car_params.h:108
const T & max_abs_steering_angle() const
The limit on the driving_command.steering angle input (the desired steering angle of a virtual center...
Definition: simple_car_params.h:83
BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.
Definition: basic_vector.h:25
Describes the row indices of a SimpleCarParams.
Definition: simple_car_params.h:20
void CalcInequalityConstraint(VectorX< T > *value) const override
Populates a vector value suitable for a SystemConstraint inequality constraint.
Definition: simple_car_params.h:141
static const std::vector< std::string > & GetCoordinateNames()
See SimpleCarParamsIndices::GetCoordinateNames().
Definition: simple_car_params.h:117
SimpleCarParams< T > * DoClone() const override
Returns a new BasicVector containing a copy of the entire vector.
Definition: simple_car_params.h:62
void set_max_abs_steering_angle(const T &max_abs_steering_angle)
Definition: simple_car_params.h:86
static const std::vector< std::string > & GetCoordinateNames()
Returns a vector containing the names of each coordinate within this class.
Definition: simple_car_params.cc:17
const T & max_acceleration() const
The limit on the car&#39;s acceleration and deceleration.
Definition: simple_car_params.h:99
const T & max_velocity() const
The limit on the car&#39;s forward speed.
Definition: simple_car_params.h:92
static const int kMaxVelocity
Definition: simple_car_params.h:28
Specializes BasicVector with specific getters and setters.
Definition: simple_car_params.h:41