Drake
driving_command.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 kSteeringAngle = 0;
26  static const int kAcceleration = 1;
27 
32  static const std::vector<std::string>& GetCoordinateNames();
33 };
34 
36 template <typename T>
38  public:
41 
46  this->set_steering_angle(0.0);
47  this->set_acceleration(0.0);
48  }
49 
50  DrivingCommand<T>* DoClone() const override { return new DrivingCommand; }
51 
53 
54  const T& steering_angle() const {
58  return this->GetAtIndex(K::kSteeringAngle);
59  }
60  void set_steering_angle(const T& steering_angle) {
61  this->SetAtIndex(K::kSteeringAngle, steering_angle);
62  }
66  const T& acceleration() const { return this->GetAtIndex(K::kAcceleration); }
67  void set_acceleration(const T& acceleration) {
68  this->SetAtIndex(K::kAcceleration, acceleration);
69  }
71 
73  static const std::vector<std::string>& GetCoordinateNames() {
75  }
76 
78  decltype(T() < T()) IsValid() const {
79  using std::isnan;
80  auto result = (T(0) == T(0));
81  result = result && !isnan(steering_angle());
83  return result;
84  }
85 };
86 
87 } // namespace automotive
88 } // namespace drake
static const std::vector< std::string > & GetCoordinateNames()
See DrivingCommandIndices::GetCoordinateNames().
Definition: driving_command.h:73
bool isnan(const Eigen::AutoDiffScalar< DerType > &x)
Overloads isnan to mimic std::isnan from <cmath>.
Definition: autodiff_overloads.h:48
static const std::vector< std::string > & GetCoordinateNames()
Returns a vector containing the names of each coordinate within this class.
Definition: driving_command.cc:13
Definition: automotive_demo.cc:88
static const int kSteeringAngle
Definition: driving_command.h:25
static const int kNumCoordinates
The total number of rows (coordinates).
Definition: driving_command.h:22
const T & acceleration() const
The signed acceleration, positive means speed up; negative means slow down, but should not move in re...
Definition: driving_command.h:66
double acceleration
Definition: system_identification_test.cc:205
std::vector< Number > result
Definition: ipopt_solver.cc:151
DrivingCommand()
Default constructor.
Definition: driving_command.h:45
DrivingCommand< T > * DoClone() const override
Returns a new BasicVector containing a copy of the entire vector.
Definition: driving_command.h:50
Specializes BasicVector with specific getters and setters.
Definition: driving_command.h:37
Describes the row indices of a DrivingCommand.
Definition: driving_command.h:20
DrivingCommandIndices K
An abbreviation for our row index constants.
Definition: driving_command.h:40
BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.
Definition: basic_vector.h:25
static const int kAcceleration
Definition: driving_command.h:26
void set_steering_angle(const T &steering_angle)
Definition: driving_command.h:60
void set_acceleration(const T &acceleration)
Definition: driving_command.h:67