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:30] – ursgraf | eeros_architecture:control_system:available_blocks:generic [2025/08/08 15:37] (current) – ursgraf | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Basic Block ====== | ====== Basic Block ====== | ||
| - | This is the basic block from which all other blocks inherit. | + | Blockio | 
| + | However, | ||
| Define such a block with an example algorithm as follows: | Define such a block with an example algorithm as follows: | ||
| <code cpp> | <code cpp> | ||
| - | Blockio<2, | + | Blockio<1, | 
| - | auto val = (block.getIn(0).getSignal().getValue() + 0.5) * 2; | + | auto val = (block.getIn().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().setValue(val); | ||
| block.getOut().getSignal().setTimestamp(gen.getIn(0).getSignal().getTimestamp()); | block.getOut().getSignal().setTimestamp(gen.getIn(0).getSignal().getTimestamp()); | ||
| Line 14: | Line 13: | ||
| </ | </ | ||
| - | 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. | 
| - | - 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 | + | |
| - | gen.getOut(0).getSignal().setValue(gen.getIn(0).getSignal().getValue() + 0.1) * 1.1); | + | |
| - | gen.getOut(0).getSignal().setTimestamp(gen.getIn(0).getSignal().getTimestamp()); | + | |
| - | })</ | + | |
| - | Such a generic | + | How could this be solved with predefined block from [[eeros_architecture: | 
| + | Use a constant | ||
| + | |||
| + | Using a basic block with a lambda function as given in the example above saves valuable execution time in reducing the number of necessary blocks. It can also be useful when a given algorithm cannot be stitched together from predefined blocks. | ||
eeros_architecture/control_system/available_blocks/generic.1625765404.txt.gz · Last modified: 2021/07/08 19:30 by ursgraf
                
                