Drake
mobil_planner_parameters.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 = 3;
23 
24  // The index of each individual coordinate.
25  static const int kP = 0;
26  static const int kThreshold = 1;
27  static const int kMaxDeceleration = 2;
28 
33  static const std::vector<std::string>& GetCoordinateNames();
34 };
35 
37 template <typename T>
39  public:
42 
48  this->set_p(0.5);
49  this->set_threshold(0.1);
50  this->set_max_deceleration(4.0);
51  }
52 
53  MobilPlannerParameters<T>* DoClone() const override {
54  return new MobilPlannerParameters;
55  }
56 
58 
59  const T& p() const { return this->GetAtIndex(K::kP); }
64  void set_p(const T& p) { this->SetAtIndex(K::kP, p); }
68  const T& threshold() const { return this->GetAtIndex(K::kThreshold); }
69  void set_threshold(const T& threshold) {
70  this->SetAtIndex(K::kThreshold, threshold);
71  }
75  const T& max_deceleration() const {
76  return this->GetAtIndex(K::kMaxDeceleration);
77  }
78  void set_max_deceleration(const T& max_deceleration) {
79  this->SetAtIndex(K::kMaxDeceleration, max_deceleration);
80  }
82 
84  static const std::vector<std::string>& GetCoordinateNames() {
86  }
87 
89  decltype(T() < T()) IsValid() const {
90  using std::isnan;
91  auto result = (T(0) == T(0));
92  result = result && !isnan(p());
93  result = result && (p() >= T(0.0));
94  result = result && (p() <= T(1.0));
95  result = result && !isnan(threshold());
96  result = result && (threshold() >= T(0.0));
97  result = result && !isnan(max_deceleration());
98  result = result && (max_deceleration() >= T(0.0));
99  return result;
100  }
101 
102  // VectorBase override.
103  void CalcInequalityConstraint(VectorX<T>* value) const override {
104  value->resize(4);
105  (*value)[0] = p() - T(0.0);
106  (*value)[1] = T(1.0) - p();
107  (*value)[2] = threshold() - T(0.0);
108  (*value)[3] = max_deceleration() - T(0.0);
109  }
110 };
111 
112 } // namespace automotive
113 } // namespace drake
static const std::vector< std::string > & GetCoordinateNames()
See MobilPlannerParametersIndices::GetCoordinateNames().
Definition: mobil_planner_parameters.h:84
void set_max_deceleration(const T &max_deceleration)
Definition: mobil_planner_parameters.h:78
bool isnan(const Eigen::AutoDiffScalar< DerType > &x)
Overloads isnan to mimic std::isnan from <cmath>.
Definition: autodiff_overloads.h:48
const T & threshold() const
acceleration threshold for changing lanes (Delta_a_th)
Definition: mobil_planner_parameters.h:68
Definition: automotive_demo.cc:88
static const int kP
Definition: mobil_planner_parameters.h:25
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: mobil_planner_parameters.h:22
MobilPlannerParameters()
Default constructor.
Definition: mobil_planner_parameters.h:47
static const std::vector< std::string > & GetCoordinateNames()
Returns a vector containing the names of each coordinate within this class.
Definition: mobil_planner_parameters.cc:15
MobilPlannerParameters< T > * DoClone() const override
Returns a new BasicVector containing a copy of the entire vector.
Definition: mobil_planner_parameters.h:53
static const int kMaxDeceleration
Definition: mobil_planner_parameters.h:27
std::vector< Number > result
Definition: ipopt_solver.cc:151
int value
Definition: copyable_unique_ptr_test.cc:61
void CalcInequalityConstraint(VectorX< T > *value) const override
Populates a vector value suitable for a SystemConstraint inequality constraint.
Definition: mobil_planner_parameters.h:103
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: mobil_planner_parameters.h:38
MobilPlannerParametersIndices K
An abbreviation for our row index constants.
Definition: mobil_planner_parameters.h:41
void set_threshold(const T &threshold)
Definition: mobil_planner_parameters.h:69
Describes the row indices of a MobilPlannerParameters.
Definition: mobil_planner_parameters.h:20
static const int kThreshold
Definition: mobil_planner_parameters.h:26
void set_p(const T &p)
Definition: mobil_planner_parameters.h:64
const T & max_deceleration() const
maximum safe deceleration (b_safe)
Definition: mobil_planner_parameters.h:75