eeros_architecture:control_system:subsystem
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
eeros_architecture:control_system:subsystem [2017/12/19 07:48] – [Define a Subsystem] graf | eeros_architecture:control_system:subsystem [2023/06/28 13:18] (current) – [Using Subio Block] ursgraf | ||
---|---|---|---|
Line 4: | Line 4: | ||
===== Define a Subsystem ===== | ===== Define a Subsystem ===== | ||
- | In order to create a subsystem you have to create a custom made block (see [[eeros_architecture: | + | In order to create a subsystem |
+ | |||
+ | ==== Using Subio Block ==== | ||
+ | |||
+ | Define | ||
<code cpp> | <code cpp> | ||
- | class Observer : public eeros:: | + | class Observer : public eeros:: |
- | public: | + | |
- | Observer() : gain1(5.0) ... { | + | Observer() : gain1({5.0, 2.2}) ... { |
- | sum1.negateInout(1); | + | sum1.getIn(1).connect(sum2.getOut()); |
- | sum1.getIn(0).connect(sum2.getOut()); | + | sum1.negateInput(1); |
+ | setOut(sum1.getOut()); | ||
... | ... | ||
} | } | ||
- | virtual ~Observer() { } | + | |
virtual void run() { | virtual void run() { | ||
sum2.run(); | sum2.run(); | ||
Line 21: | Line 26: | ||
} | } | ||
| | ||
- | | + | |
- | virtual eeros:: | + | eeros:: |
- | virtual eeros:: | + | eeros:: |
+ | ... | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | The whole subsystem is now a block for itself. It can be added to a control system (or an outer subsystem). Its run-method will be called automatically as soon as it is added to a time domain which itself must be started by the executor. | ||
+ | |||
+ | For an example study the tutorial at [[getting_started: | ||
+ | |||
+ | ==== Using Custom Block ==== | ||
+ | Define the necessary inner blocks in your custom class. In the constructor you create the inner blocks and connect them among each other. The run-method must call all the run-methods of the inner blocks. Write getter methods for all the inputs into and outputs out of the new subsystem | ||
+ | <code cpp> | ||
+ | class Observer : public eeros:: | ||
+ | | ||
+ | Observer() : gain1({5.0, 2.2}) ... { | ||
+ | sum1.getIn(1).connect(sum2.getOut()); | ||
+ | sum1.negateInput(1); | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | virtual void run() { | ||
+ | sum2.run(); | ||
+ | sum1.run(); | ||
+ | ... | ||
+ | gain1.run(); | ||
+ | } | ||
+ | |||
+ | | ||
+ | virtual eeros:: | ||
+ | virtual eeros:: | ||
- | private: | + | private: |
- | eeros:: | + | eeros:: |
- | eeros:: | + | eeros:: |
... | ... | ||
}; | }; | ||
Line 33: | Line 67: | ||
The whole subsystem is now a block for itself. It can be added to a control system (or an outer subsystem). Its run-method will be called automatically as soon as it is added to a time domain which itself must be started by the executor. | The whole subsystem is now a block for itself. It can be added to a control system (or an outer subsystem). Its run-method will be called automatically as soon as it is added to a time domain which itself must be started by the executor. | ||
+ | |||
+ | |||
+ | ===== Using Input Signals ===== | ||
+ | Consider the following example | ||
+ | [{{ : | ||
+ | |||
+ | This subsystem has an input which is used by several blocks within the subsystem. In order to be able to connect these blocks to the input, you have to define the input as being of type '' | ||
+ | <code cpp> | ||
+ | InputSub<> | ||
+ | </ | ||
+ | The getter function for this input will be | ||
+ | <code cpp> | ||
+ | virtual Input<>& | ||
+ | </ | ||
+ | |||
+ | See Tutorial for a example of using a subsystem. | ||
+ |
eeros_architecture/control_system/subsystem.1513666106.txt.gz · Last modified: 2017/12/19 07:48 by graf