Drake
simple_powertrain.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace drake {
6 namespace automotive {
7 
8 /// SimplePowertrain models a powertrain with first-order lag. It accepts
9 /// throttle as the input and outputs the applied lumped force from the vehicle
10 /// to the road.
11 ///
12 /// Input:
13 /// - A unitless scalar value representing the throttle input to the power
14 /// system.
15 ///
16 /// Output:
17 /// - The force transmitted from the vehicle to the road [N].
18 ///
19 /// @tparam T The vector element type, which must be a valid Eigen scalar.
20 ///
21 /// Instantiated templates for the following kinds of T's are provided:
22 /// - double
23 /// - AutoDiffXd
24 /// - symbolic::Expression
25 ///
26 /// They are already available to link against in the containing library.
27 ///
28 /// @ingroup automotive_plants
29 template <typename T>
30 class SimplePowertrain final : public systems::LinearSystem<T> {
31  public:
33 
34  /// Constructs a simple powertrain model, specified via a fixed time-constant
35  /// and scalar gain. The inputs are as follows:
36  /// @param time_constant is the rise time of the first-order lag [s].
37  /// @param gain is the gain converting throttle input to force output [N].
38  SimplePowertrain(double time_constant, double gain)
39  : systems::LinearSystem<T>(
40  systems::SystemTypeTag<automotive::SimplePowertrain>{},
41  Vector1d(-1. / time_constant),
42  Vector1d(gain),
43  Vector1d(1. / time_constant),
44  Vector1d(0.),
45  0.0 /* time_period */),
46  time_constant_(time_constant),
47  gain_(gain) {}
48 
49  /// Scalar-converting copy constructor. See @ref system_scalar_conversion.
50  template <typename U>
51  explicit SimplePowertrain(const SimplePowertrain<U>& other)
52  : SimplePowertrain<T>(other.get_time_constant(), other.get_gain()) {}
53 
54  ~SimplePowertrain() override = default;
55 
58  }
59 
62  }
63 
64  /// Accessors for the system constants.
65  /// @{
66  double get_time_constant() const { return time_constant_; }
67  double get_gain() const { return gain_; }
68  /// @}
69 
70  private:
71  const double time_constant_{};
72  const double gain_{};
73 };
74 
75 } // namespace automotive
76 } // namespace drake
const systems::InputPortDescriptor< T > & get_throttle_input_port() const
Definition: simple_powertrain.h:56
~SimplePowertrain() override=default
Definition: automotive_demo.cc:88
double get_time_constant() const
Accessors for the system constants.
Definition: simple_powertrain.h:66
double get_gain() const
Definition: simple_powertrain.h:67
const InputPortDescriptor< T > & get_input_port(int port_index) const
Returns the descriptor of the input port at index port_index.
Definition: system.h:972
InputPortDescriptor is a notation for specifying the kind of input a System accepts, on a given port.
Definition: input_port_descriptor.h:21
A discrete OR continuous linear system.
Definition: linear_system.h:43
An OutputPort belongs to a System and represents the properties of one of that System&#39;s output ports...
Definition: output_port.h:67
const systems::OutputPort< T > & get_force_output_port() const
Definition: simple_powertrain.h:60
SimplePowertrain(double time_constant, double gain)
Constructs a simple powertrain model, specified via a fixed time-constant and scalar gain...
Definition: simple_powertrain.h:38
SimplePowertrain(const SimplePowertrain< U > &other)
Scalar-converting copy constructor. See System Scalar Conversion.
Definition: simple_powertrain.h:51
Eigen::Matrix< double, 1, 1 > Vector1d
A column vector of size 1 of doubles.
Definition: eigen_types.h:26
SimplePowertrain models a powertrain with first-order lag.
Definition: simple_powertrain.h:30
const OutputPort< T > & get_output_port(int port_index) const
Returns the output port at index port_index.
Definition: system.h:983
#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
LinearSystem(const LinearSystem &)=delete