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 /// (InputPortDescriptor getter: get_steering_input_port())
40 /// - Force acting on the rigid body F_in [N]
41 /// (InputPortDescriptor 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 ///
53 /// They are already available to link against in libdrakeAutomotive.
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 a descriptor of the input port that contains the steering angle.
80 
81  /// Returns a descriptor of the input port that contains the applied
82  /// powertrain force.
84 
85  /// Returns the output port that contains the bicycle states.
87 
88  private:
89  void CopyOutState(const systems::Context<T>& context,
90  BicycleCarState<T>* output) const;
91 
92  void DoCalcTimeDerivatives(
93  const systems::Context<T>& context,
94  systems::ContinuousState<T>* derivatives) const override;
95 
96  void ImplCalcTimeDerivatives(const BicycleCarParameters<T>& params,
97  const BicycleCarState<T>& state,
98  const systems::BasicVector<T>& steering,
100  BicycleCarState<T>* derivatives) const;
101 
102  int steering_input_port_{};
103  int force_input_port_{};
104  int state_output_port_{};
105 };
106 
107 } // namespace automotive
108 } // namespace drake
double force
Definition: system_identification_test.cc:205
const systems::InputPortDescriptor< T > & get_force_input_port() const
Returns a descriptor of the input port that contains the applied powertrain force.
Definition: bicycle_car.cc:57
~BicycleCar() override
Definition: bicycle_car.cc:48
Definition: automotive_demo.cc:88
const systems::InputPortDescriptor< T > & get_steering_input_port() const
Returns a descriptor of the input port that contains the steering angle.
Definition: bicycle_car.cc:51
Context is an abstract base class template that represents all the inputs to a System: time...
Definition: query_handle.h:10
const systems::OutputPort< T > & get_state_output_port() const
Returns the output port that contains the bicycle states.
Definition: bicycle_car.cc:63
InputPortDescriptor is a notation for specifying the kind of input a System accepts, on a given port.
Definition: input_port_descriptor.h:21
An OutputPort belongs to a System and represents the properties of one of that System&#39;s output ports...
Definition: output_port.h:67
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:82
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 container for all the continuous state variables xc.
Definition: continuous_state.h:44
#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
Provides careful macros to selectively enable or disable the special member functions for copy-constr...