Drake
gain3.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <memory>
5 
11 
12 namespace drake {
13 namespace systems {
14 
19 template <typename T>
20 class Gain3 : public System3<T> {
21  public:
24  // TODO(sherm1) Shouldn't specify the length; any size is OK.
25  // TODO(sherm1) Gain should be a parameter.
26  DRAKESYSTEMFRAMEWORK_EXPORT Gain3(const std::string& name, const T& gain,
27  int length);
28 
30  T get_gain() const { return gain_; }
31 
33  void set_gain(const T& gain) { gain_ = gain; }
34 
35  private:
36  // Implement System<T> interface.
37 
38  std::unique_ptr<AbstractContext3> DoCreateEmptyContext() const override {
39  return std::make_unique<Context3<T>>();
40  }
41 
42  // Set output to the product of the gain and the input port.
43  DRAKESYSTEMFRAMEWORK_EXPORT void DoCalcOutputPort(
44  const AbstractContext3& context, int port_num,
45  AbstractValue* value) const override;
46 
47  T gain_;
48  const int length_;
49 };
50 
51 } // namespace systems
52 } // namespace drake
An abstract superclass for the Context3 objects for dynamical systems, encapsulating functionality th...
Definition: context3.h:87
A superclass template for systems that use a specified scalar type T for numerical values...
Definition: system3.h:481
Definition: constants.h:3
T get_gain() const
Report the gain that was supplied in the constructor.
Definition: gain3.h:30
A fully type-erased container class.
Definition: value.h:22
void set_gain(const T &gain)
Change the gain from its current value.
Definition: gain3.h:33
DRAKESYSTEMFRAMEWORK_EXPORT Gain3(const std::string &name, const T &gain, int length)
Create Gain System with one input and one output port of the given length.
Definition: gain3.cc:14
Multiply the single vector input by a scalar and present the result as the single output port...
Definition: gain3.h:20