Drake
simple_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 = 4;
23 
24  // The index of each individual coordinate.
25  static const int kX = 0;
26  static const int kY = 1;
27  static const int kHeading = 2;
28  static const int kVelocity = 3;
29 
34  static const std::vector<std::string>& GetCoordinateNames();
35 };
36 
38 template <typename T>
40  public:
43 
46  this->SetFromVector(VectorX<T>::Zero(K::kNumCoordinates));
47  }
48 
49  SimpleCarState<T>* DoClone() const override { return new SimpleCarState; }
50 
52 
53  const T& x() const { return this->GetAtIndex(K::kX); }
55  void set_x(const T& x) { this->SetAtIndex(K::kX, x); }
57  const T& y() const { return this->GetAtIndex(K::kY); }
58  void set_y(const T& y) { this->SetAtIndex(K::kY, y); }
60  const T& heading() const { return this->GetAtIndex(K::kHeading); }
61  void set_heading(const T& heading) { this->SetAtIndex(K::kHeading, heading); }
63  const T& velocity() const { return this->GetAtIndex(K::kVelocity); }
64  void set_velocity(const T& velocity) {
65  this->SetAtIndex(K::kVelocity, velocity);
66  }
68 
70  static const std::vector<std::string>& GetCoordinateNames() {
72  }
73 
75  decltype(T() < T()) IsValid() const {
76  using std::isnan;
77  auto result = (T(0) == T(0));
78  result = result && !isnan(x());
79  result = result && !isnan(y());
80  result = result && !isnan(heading());
81  result = result && !isnan(velocity());
82  return result;
83  }
84 };
85 
86 } // namespace automotive
87 } // namespace drake
bool isnan(const Eigen::AutoDiffScalar< DerType > &x)
Overloads isnan to mimic std::isnan from <cmath>.
Definition: autodiff_overloads.h:48
SimpleCarState()
Default constructor. Sets all rows to zero.
Definition: simple_car_state.h:45
static const int kNumCoordinates
The total number of rows (coordinates).
Definition: simple_car_state.h:22
std::vector< Number > x
Definition: ipopt_solver.cc:153
Definition: automotive_demo.cc:88
static const int kY
Definition: simple_car_state.h:26
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 kHeading
Definition: simple_car_state.h:27
static const std::vector< std::string > & GetCoordinateNames()
See SimpleCarStateIndices::GetCoordinateNames().
Definition: simple_car_state.h:70
void set_y(const T &y)
Definition: simple_car_state.h:58
SimpleCarStateIndices K
An abbreviation for our row index constants.
Definition: simple_car_state.h:42
const T & heading() const
heading
Definition: simple_car_state.h:60
void set_heading(const T &heading)
Definition: simple_car_state.h:61
static const int kVelocity
Definition: simple_car_state.h:28
double y
Definition: vtk_util_test.cc:26
std::vector< Number > result
Definition: ipopt_solver.cc:154
void set_x(const T &x)
Definition: simple_car_state.h:55
const T & y() const
y
Definition: simple_car_state.h:57
BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.
Definition: basic_vector.h:25
static const int kX
Definition: simple_car_state.h:25
SimpleCarState< T > * DoClone() const override
Returns a new BasicVector containing a copy of the entire vector.
Definition: simple_car_state.h:49
const T & velocity() const
velocity
Definition: simple_car_state.h:63
Describes the row indices of a SimpleCarState.
Definition: simple_car_state.h:20
Specializes BasicVector with specific getters and setters.
Definition: simple_car_state.h:39
static const std::vector< std::string > & GetCoordinateNames()
Returns a vector containing the names of each coordinate within this class.
Definition: simple_car_state.cc:15
Vector6< double > velocity
Definition: pose_smoother.cc:29
void set_velocity(const T &velocity)
Definition: simple_car_state.h:64