Drake
bicycle_car.h
Go to the documentation of this file.
1 #pragma once
2
3 #include <memory>
4
5 #include <Eigen/Geometry>
6
7 #include "drake/automotive/gen/bicycle_car_parameters.h"
8 #include "drake/automotive/gen/bicycle_car_state.h"
11
12 namespace drake {
13 namespace automotive {
14
15 /// BicycleCar implements a nonlinear rigid body bicycle model from Althoff &
16 /// Dolan (2014) [1]. The three-DOF model captures the rigid-body dynamics in
17 /// the lateral, longitudinal, and yaw directions but not in the roll and pitch
18 /// directions. The model assumes a vehicle that has two wheels: one at the
19 /// front and one at the rear. It has been demonstrated (e.g. [2]) that the
20 /// representation reasonably approximates the dynamics of a four-wheeled
21 /// vehicle; hence the model is useful as a simplified abstraction of car
22 /// dynamics.
23 ///
24 /// The states of the model are:
25 /// - yaw angle Ψ [rad]
26 /// - yaw rate Ψ_dot [rad/s]
27 /// - slip angle at the center of mass β [rad]
28 /// - velocity magnitude (vector magnitude at the slip angle) vel [m/s]
29 /// - x-position of the center of mass sx [m]
30 /// - y-position of the center of mass sy [m]
31 ///
32 /// N.B. "slip angle" (β) is the angle made between the body and the velocity
33 /// vector. Thus, the velocity vector can be resolved into the body-relative
34 /// componenets vx_body = cos(β) and vy_body = sin(β). β = 0 means the
35 /// velocity vector is pointing along the bicycle's longitudinal axis.
36 ///
37 /// Inputs:
38 /// - Angle of the front wheel of the bicycle δ [rad]
39 /// (InputPort getter: get_steering_input_port())
40 /// - Force acting on the rigid body F_in [N]
41 /// (InputPort getter: get_force_input_port())
42 ///
43 /// Output:
44 /// - A BicycleCarState containing the 6-dimensional state vector of the
45 /// bicycle.
46 /// (OutputPort getter: get_state_output_port())
47 ///
48 /// Instantiated templates for the following kinds of T's are provided:
49 /// - double
50 /// - drake::AutoDiffXd
51 /// - drake::symbolic::Expression
52 ///
54 ///
55 /// [1] M. Althoff and J.M. Dolan, Online verification of automated road
56 /// vehicles using reachability analysis, IEEE Transactions on Robotics,
57 /// 30(4), 2014, pp. 903-908. DOI: 10.1109/TRO.2014.2312453.
58 ///
59 /// [2] M. Althoff and J. M. Dolan, Reachability computation of low-order
60 /// models for the safety verification of high-order road vehicle models,
61 /// in Proc. of the American Control Conference, 2012, pp. 3559–3566.
62 ///
63 /// @ingroup automotive_plants
64 template <typename T>
65 class BicycleCar final : public systems::LeafSystem<T> {
66  public:
68
69  /// Default constructor.
70  BicycleCar();
71
72  /// Scalar-converting copy constructor. See @ref system_scalar_conversion.
73  template <typename U>
74  explicit BicycleCar(const BicycleCar<U>&);
75
76  ~BicycleCar() override;
77
78  /// Returns the input port that contains the steering angle.
80
81  /// Returns the input port that contains the applied powertrain force.
83
84  /// Returns the output port that contains the bicycle states.
86
87  private:
88  void CopyOutState(const systems::Context<T>& context,
89  BicycleCarState<T>* output) const;
90
91  void DoCalcTimeDerivatives(
92  const systems::Context<T>& context,
93  systems::ContinuousState<T>* derivatives) const override;
94
95  void ImplCalcTimeDerivatives(const BicycleCarParameters<T>& params,
96  const BicycleCarState<T>& state,
97  const systems::BasicVector<T>& steering,
99  BicycleCarState<T>* derivatives) const;
100
101  int steering_input_port_{};
102  int force_input_port_{};
103  int state_output_port_{};
104 };
105
106 } // namespace automotive
107 } // namespace drake
double force
Definition: system_identification_test.cc:205
~BicycleCar() override
Definition: bicycle_car.cc:48
Definition: bullet_model.cc:22
Context is an abstract class template that represents all the typed values that are used in a System&#39;...
Definition: context.h:40
const systems::OutputPort< T > & get_state_output_port() const
Returns the output port that contains the bicycle states.
Definition: bicycle_car.cc:63
An OutputPort belongs to a System and represents the properties of one of that System&#39;s output ports...
Definition: output_port.h:71
BicycleCar()
Default constructor.
Definition: bicycle_car.cc:16
A superclass template that extends System with some convenience utilities that are not applicable to ...
Definition: leaf_system.h:81
const systems::InputPort< T > & get_force_input_port() const
Returns the input port that contains the applied powertrain force.
Definition: bicycle_car.cc:57
BasicVector is a semantics-free wrapper around an Eigen vector that satisfies VectorBase.
Definition: basic_vector.h:25
BicycleCar implements a nonlinear rigid body bicycle model from Althoff & Dolan (2014) [1]...
Definition: bicycle_car.h:65
ContinuousState is a view of, and optionally a container for, all the continuous state variables xc o...
Definition: continuous_state.h:76
const systems::InputPort< T > & get_steering_input_port() const
Returns the input port that contains the steering angle.
Definition: bicycle_car.cc:51
#define DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:33
This extends InputPortBase with some scalar type-dependent methods.
Definition: input_port.h:22
Provides careful macros to selectively enable or disable the special member functions for copy-constr...