Drake
trajectory_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 = 2;
23 
24  // The index of each individual coordinate.
25  static const int kPosition = 0;
26  static const int kSpeed = 1;
27 
32  static const std::vector<std::string>& GetCoordinateNames();
33 };
34 
36 template <typename T>
38  public:
41 
44  this->SetFromVector(VectorX<T>::Zero(K::kNumCoordinates));
45  }
46 
47  TrajectoryCarState<T>* DoClone() const override {
48  return new TrajectoryCarState;
49  }
50 
52 
53  const T& position() const { return this->GetAtIndex(K::kPosition); }
55  void set_position(const T& position) {
56  this->SetAtIndex(K::kPosition, position);
57  }
59  const T& speed() const { return this->GetAtIndex(K::kSpeed); }
60  void set_speed(const T& speed) { this->SetAtIndex(K::kSpeed, speed); }
62 
64  static const std::vector<std::string>& GetCoordinateNames() {
66  }
67 
69  decltype(T() < T()) IsValid() const {
70  using std::isnan;
71  auto result = (T(0) == T(0));
72  result = result && !isnan(position());
73  result = result && !isnan(speed());
74  return result;
75  }
76 };
77 
78 } // namespace automotive
79 } // namespace drake
bool isnan(const Eigen::AutoDiffScalar< DerType > &x)
Overloads isnan to mimic std::isnan from <cmath>.
Definition: autodiff_overloads.h:48
static const int kPosition
Definition: trajectory_car_state.h:25
double position
Definition: system_identification_test.cc:205
Definition: automotive_demo.cc:88
TrajectoryCarState()
Default constructor. Sets all rows to zero.
Definition: trajectory_car_state.h:43
const T & speed() const
The along-curve speed of the vehicle.
Definition: trajectory_car_state.h:59
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: trajectory_car_state.h:22
static const std::vector< std::string > & GetCoordinateNames()
Returns a vector containing the names of each coordinate within this class.
Definition: trajectory_car_state.cc:14
static const std::vector< std::string > & GetCoordinateNames()
See TrajectoryCarStateIndices::GetCoordinateNames().
Definition: trajectory_car_state.h:64
std::vector< Number > result
Definition: ipopt_solver.cc:151
static const int kSpeed
Definition: trajectory_car_state.h:26
TrajectoryCarState< T > * DoClone() const override
Returns a new BasicVector containing a copy of the entire vector.
Definition: trajectory_car_state.h:47
TrajectoryCarStateIndices K
An abbreviation for our row index constants.
Definition: trajectory_car_state.h:40
void set_position(const T &position)
Definition: trajectory_car_state.h:55
void set_speed(const T &speed)
Definition: trajectory_car_state.h:60
BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.
Definition: basic_vector.h:25
Specializes BasicVector with specific getters and setters.
Definition: trajectory_car_state.h:37
Describes the row indices of a TrajectoryCarState.
Definition: trajectory_car_state.h:20