eeros_architecture:control_system:available_blocks:generic
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
eeros_architecture:control_system:available_blocks:generic [2021/07/08 19:09] – ursgraf | eeros_architecture:control_system:available_blocks:generic [2021/07/08 19:30] (current) – ursgraf | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | A generic | + | This is the basic block from which all other blocks inherit. But you can use the block directly and set its specific algorithm that will run whenever the block runs within |
+ | |||
+ | Define such a block with an example algorithm as follows: | ||
+ | <code cpp> | ||
+ | Blockio< | ||
+ | auto val = (block.getIn(0).getSignal().getValue() + 0.5) * 2; | ||
+ | val[0] *= -1.0; | ||
+ | val += block.getIn(1).getSignal().getValue() + 1.0; | ||
+ | block.getOut().getSignal().setValue(val); | ||
+ | block.getOut().getSignal().setTimestamp(gen.getIn(0).getSignal().getTimestamp()); | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | The algorithm can be passed to the constructor of the block with a lambda function. Such an algorithm could theoretically calculate any output from a given set of inputs. It can be especially valuable for cases like the following. A signal value must be applied with an offset and a scale. How to achieve this? | ||
- Use a constant block delivering the offset together with a sum block which adds the offset to the signal. Finally, a gain block applies the desired scale. All in all, you will use three different blocks. | - Use a constant block delivering the offset together with a sum block which adds the offset to the signal. Finally, a gain block applies the desired scale. All in all, you will use three different blocks. | ||
- Use a generic block and define the necessary algorithm as follows <code cpp> | - Use a generic block and define the necessary algorithm as follows <code cpp> |
eeros_architecture/control_system/available_blocks/generic.1625764197.txt.gz · Last modified: 2021/07/08 19:09 by ursgraf