User Tools

Site Tools


eeros_architecture:control_system:available_blocks:generic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
eeros_architecture:control_system:available_blocks:generic [2021/07/08 19:14] ursgrafeeros_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 is the basic block from which all other blocks inherit. See [[eeros_architecture:control_system:custom_blocks|]] to learn how to use this basic blocks for your custom made blocks. \\ 
 +However, you can use this block directly and set its specific algorithm that will run whenever the block runs within a timedomain. Use the template parameters to choose any number of input and output signals together with their associated types. The algorithm can be passed to the constructor of the block with a lambda function. 
 +  
 +Define such a block with an example algorithm as follows: 
 +<code cpp> 
 +  Blockio<1,1,Vector2,Vector2> block([&]() { 
 +    auto val = (block.getIn().getSignal().getValue() + 0.5) * 2; 
 +    block.getOut().getSignal().setValue(val); 
 +    block.getOut().getSignal().setTimestamp(gen.getIn(0).getSignal().getTimestamp()); 
 +  }); 
 +</code>
  
-A generic block simply runs a predefined algorithm which can be passed to the constructor of the block. Such an algorithm could theoretically calculate any output from a given set of inputs. It can be especially valuable for cases like the followingA signal value must be applied with an offset and scale. How to achieve this? +Such an algorithm could theoretically calculate any output from a given set of inputs. Choose this method when the algorithm is simple and one wants to avoid using several other blocks doing a simple algorithm, e.g. adding a offset and scale to a signal as given in the example above
-  - Use 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>GenericBlock<> gen([&]() { +
-  gen.getOut(0).getSignal().setValue(gen.getIn(0).getSignal().getValue() + 0.1) * 1.1); +
-  gen.getOut(0).getSignal().setTimestamp(gen.getIn(0).getSignal().getTimestamp()); +
-})</code>+
  
-Such generic block can save 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.+How could this be solved with predefined block from [[eeros_architecture:control_system:available_blocks|]]? 
 +Use 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. 
 + 
 +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.1625764496.txt.gz · Last modified: 2021/07/08 19:14 by ursgraf