User Tools

Site Tools


tools:cplusplus

Differences

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

Link to this comparison view

Next revision
Previous revision
tools:cplusplus [2017/09/24 15:31] – created graftools:cplusplus [2021/07/08 19:31] (current) – [Lambda Functions] ursgraf
Line 49: Line 49:
 The square brackets - even if left empty - are necessary, because a ''Constant'' block requires a signal type for its output. The block is instantiated per default with a value of type ''double''. The second declaration chooses a different type. The third declaration uses a type different from an arithmetic type. The type ''Matrix'' is a built-in type which itself can be parametrized with its dimensions. \\ The square brackets - even if left empty - are necessary, because a ''Constant'' block requires a signal type for its output. The block is instantiated per default with a value of type ''double''. The second declaration chooses a different type. The third declaration uses a type different from an arithmetic type. The type ''Matrix'' is a built-in type which itself can be parametrized with its dimensions. \\
 Do not forget to call the method ''run''. Without this value of the block is not written to its output signal.  Do not forget to call the method ''run''. Without this value of the block is not written to its output signal. 
 +
 +===== Lambda Functions =====
 +A lambda is an anonymous function which can be passed as a parameter. While using EEROS lambda functions are useful for several cases. 
 +  * Safety system: see [[eeros_architecture:safety_system:properties#level_actions|Level Actions]].
 +  * Function used by periodic: see [[tools:logger_cs:start|]]
 +  * Generic block: see [[eeros_architecture:control_system:available_blocks:generic|]]
 +
 +A lambda function must be defined as follows
 +<code cpp>
 +[captures] (params) {body}
 +</code>
 +Captures are variables which are defined in the scope where the lambda function is defined and which can be made available to the lambda function either by value or by reference. Params are parameters which can be passed into the function like regular parameters. The body contains the code which is executed by the function.   
 + 
 +
tools/cplusplus.1506259875.txt.gz · Last modified: 2017/09/24 15:31 (external edit)