Drake
bicycle_car_state.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 kPsi = 0;
26  static const int kPsiDot = 1;
27  static const int kBeta = 2;
28  static const int kVel = 3;
29  static const int kSx = 4;
30  static const int kSy = 5;
31 
36  static const std::vector<std::string>& GetCoordinateNames();
37 };
38 
40 template <typename T>
42  public:
45 
48  this->SetFromVector(VectorX<T>::Zero(K::kNumCoordinates));
49  }
50 
51  BicycleCarState<T>* DoClone() const override { return new BicycleCarState; }
52 
54 
55  const T& Psi() const { return this->GetAtIndex(K::kPsi); }
57  void set_Psi(const T& Psi) { this->SetAtIndex(K::kPsi, Psi); }
59  const T& Psi_dot() const { return this->GetAtIndex(K::kPsiDot); }
60  void set_Psi_dot(const T& Psi_dot) { this->SetAtIndex(K::kPsiDot, Psi_dot); }
62  const T& beta() const { return this->GetAtIndex(K::kBeta); }
63  void set_beta(const T& beta) { this->SetAtIndex(K::kBeta, beta); }
65  const T& vel() const { return this->GetAtIndex(K::kVel); }
66  void set_vel(const T& vel) { this->SetAtIndex(K::kVel, vel); }
68  const T& sx() const { return this->GetAtIndex(K::kSx); }
69  void set_sx(const T& sx) { this->SetAtIndex(K::kSx, sx); }
71  const T& sy() const { return this->GetAtIndex(K::kSy); }
72  void set_sy(const T& sy) { this->SetAtIndex(K::kSy, sy); }
74 
76  static const std::vector<std::string>& GetCoordinateNames() {
78  }
79 
81  decltype(T() < T()) IsValid() const {
82  using std::isnan;
83  auto result = (T(0) == T(0));
84  result = result && !isnan(Psi());
85  result = result && !isnan(Psi_dot());
86  result = result && !isnan(beta());
87  result = result && !isnan(vel());
88  result = result && !isnan(sx());
89  result = result && !isnan(sy());
90  return result;
91  }
92 };
93 
94 } // namespace automotive
95 } // namespace drake
bool isnan(const Eigen::AutoDiffScalar< DerType > &x)
Overloads isnan to mimic std::isnan from <cmath>.
Definition: autodiff_overloads.h:48
void set_Psi_dot(const T &Psi_dot)
Definition: bicycle_car_state.h:60
BicycleCarStateIndices K
An abbreviation for our row index constants.
Definition: bicycle_car_state.h:44
static const int kSx
Definition: bicycle_car_state.h:29
Definition: automotive_demo.cc:88
const T & sx() const
x-position at the center of mass
Definition: bicycle_car_state.h:68
static const std::vector< std::string > & GetCoordinateNames()
See BicycleCarStateIndices::GetCoordinateNames().
Definition: bicycle_car_state.h:76
const T & sy() const
y-position at the center of mass
Definition: bicycle_car_state.h:71
void set_sx(const T &sx)
Definition: bicycle_car_state.h:69
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorX
A column vector of any size, templated on scalar type.
Definition: eigen_types.h:46
void set_vel(const T &vel)
Definition: bicycle_car_state.h:66
void set_sy(const T &sy)
Definition: bicycle_car_state.h:72
static const int kSy
Definition: bicycle_car_state.h:30
static const int kNumCoordinates
The total number of rows (coordinates).
Definition: bicycle_car_state.h:22
std::vector< Number > result
Definition: ipopt_solver.cc:151
const T & beta() const
slip angle at the center of mass
Definition: bicycle_car_state.h:62
void set_beta(const T &beta)
Definition: bicycle_car_state.h:63
Describes the row indices of a BicycleCarState.
Definition: bicycle_car_state.h:20
static const int kVel
Definition: bicycle_car_state.h:28
void set_Psi(const T &Psi)
Definition: bicycle_car_state.h:57
static const int kPsiDot
Definition: bicycle_car_state.h:26
BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.
Definition: basic_vector.h:25
BicycleCarState()
Default constructor. Sets all rows to zero.
Definition: bicycle_car_state.h:47
const T & Psi_dot() const
yaw angular rate
Definition: bicycle_car_state.h:59
const T & vel() const
velocity magnitude
Definition: bicycle_car_state.h:65
BicycleCarState< T > * DoClone() const override
Returns a new BasicVector containing a copy of the entire vector.
Definition: bicycle_car_state.h:51
static const std::vector< std::string > & GetCoordinateNames()
Returns a vector containing the names of each coordinate within this class.
Definition: bicycle_car_state.cc:17
static const int kPsi
Definition: bicycle_car_state.h:25
static const int kBeta
Definition: bicycle_car_state.h:27
Specializes BasicVector with specific getters and setters.
Definition: bicycle_car_state.h:41