Drake
system_interface.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include "drake/drakeSystemFramework_export.h"
9 
10 namespace drake {
11 namespace systems {
12 
18 class DRAKESYSTEMFRAMEWORK_EXPORT AbstractSystemInterface {
19  public:
21 
23  virtual std::string get_name() const = 0;
24 
25  protected:
27 
28  private:
29  // AbstractSystemInterface objects are neither copyable nor moveable.
30  AbstractSystemInterface(const AbstractSystemInterface& other) = delete;
31  AbstractSystemInterface& operator=(const AbstractSystemInterface& other) =
32  delete;
34  AbstractSystemInterface& operator=(AbstractSystemInterface&& other) = delete;
35 };
36 
45 template <typename T>
47  // TODO(david-german-tri): Add static_asserts on T.
48  public:
53  virtual std::unique_ptr<Context<T>> CreateDefaultContext() const = 0;
54 
57  virtual std::unique_ptr<SystemOutput<T>> AllocateOutput() const = 0;
58 
61  virtual void EvalOutput(const Context<T>& context,
62  SystemOutput<T>* output) const = 0;
63 
64  // TODO(sherm): these two energy methods should be present only for systems
65  // that represent some kind of physical system that can store energy in its
66  // configuration or motion. Consider introducing a PhysicalSystemInterface
67  // class so that a simple System (for example, an adder) doesn't have these
68  // methods. For now I'm breaking the no-code-in-interface rule to provide
69  // zero defaults so that these don't have to be implemented in non-physical
70  // systems.
71 
74  virtual T EvalPotentialEnergy(const Context<T>& context) const {
75  return T(0);
76  }
77 
80  virtual T EvalKineticEnergy(const Context<T>& context) const { return T(0); }
81 
82  protected:
84 
85  private:
86  // SystemInterface objects are neither copyable nor moveable.
87  SystemInterface(const SystemInterface<T>& other) = delete;
88  SystemInterface& operator=(const SystemInterface<T>& other) = delete;
89  SystemInterface(SystemInterface<T>&& other) = delete;
90  SystemInterface& operator=(SystemInterface<T>&& other) = delete;
91 };
92 
93 } // namespace systems
94 } // namespace drake
virtual ~AbstractSystemInterface()
Definition: system_interface.h:20
Definition: constants.h:3
A fully type-erased abstract superclass for dynamical systems.
Definition: system_interface.h:18
SystemInterface()
Definition: system_interface.h:83
The Context is a container for all of the data necessary to uniquely determine the computations perfo...
Definition: context.h:38
A superclass template for systems that receive input, maintain state, and produce numerical output us...
Definition: system_interface.h:46
AbstractSystemInterface()
Definition: system_interface.h:26
virtual T EvalKineticEnergy(const Context< T > &context) const
Return the kinetic energy currently present in the motion provided in the given Context.
Definition: system_interface.h:80
virtual T EvalPotentialEnergy(const Context< T > &context) const
Return the potential energy currently stored in the configuration provided in the given Context...
Definition: system_interface.h:74
A container for all the output ports of a System.
Definition: system_output.h:133