Drake
maliput_railcar_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 kS = 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  MaliputRailcarState<T>* DoClone() const override {
48  return new MaliputRailcarState;
49  }
50 
52 
53  const T& s() const { return this->GetAtIndex(K::kS); }
55  void set_s(const T& s) { this->SetAtIndex(K::kS, s); }
57  const T& speed() const { return this->GetAtIndex(K::kSpeed); }
58  void set_speed(const T& speed) { this->SetAtIndex(K::kSpeed, speed); }
60 
62  static const std::vector<std::string>& GetCoordinateNames() {
64  }
65 
67  decltype(T() < T()) IsValid() const {
68  using std::isnan;
69  auto result = (T(0) == T(0));
70  result = result && !isnan(s());
71  result = result && !isnan(speed());
72  return result;
73  }
74 };
75 
76 } // namespace automotive
77 } // namespace drake
void set_speed(const T &speed)
Definition: maliput_railcar_state.h:58
bool isnan(const Eigen::AutoDiffScalar< DerType > &x)
Overloads isnan to mimic std::isnan from <cmath>.
Definition: autodiff_overloads.h:48
MaliputRailcarStateIndices K
An abbreviation for our row index constants.
Definition: maliput_railcar_state.h:40
static const std::vector< std::string > & GetCoordinateNames()
Returns a vector containing the names of each coordinate within this class.
Definition: maliput_railcar_state.cc:14
Definition: automotive_demo.cc:88
static const int kSpeed
Definition: maliput_railcar_state.h:26
const T & speed() const
The speed of the vehicle in physical space.
Definition: maliput_railcar_state.h:57
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorX
A column vector of any size, templated on scalar type.
Definition: eigen_types.h:46
std::vector< Number > result
Definition: ipopt_solver.cc:151
static const std::vector< std::string > & GetCoordinateNames()
See MaliputRailcarStateIndices::GetCoordinateNames().
Definition: maliput_railcar_state.h:62
static const int kS
Definition: maliput_railcar_state.h:25
static const int kNumCoordinates
The total number of rows (coordinates).
Definition: maliput_railcar_state.h:22
MaliputRailcarState()
Default constructor. Sets all rows to zero.
Definition: maliput_railcar_state.h:43
Specializes BasicVector with specific getters and setters.
Definition: maliput_railcar_state.h:37
BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.
Definition: basic_vector.h:25
Describes the row indices of a MaliputRailcarState.
Definition: maliput_railcar_state.h:20
MaliputRailcarState< T > * DoClone() const override
Returns a new BasicVector containing a copy of the entire vector.
Definition: maliput_railcar_state.h:47
void set_s(const T &s)
Definition: maliput_railcar_state.h:55