Differences

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

Link to this comparison view

ref:script_measure [2020/01/07 17:06] (current)
Line 1: Line 1:
 +====== ScriptMeasure ======
 +[[measure|Measure]] defined through a Lua script. ​
 +
 +Runs the script defined in the file defined by ''​script_file'',​ which is relative to the folder of the scone scenario. See also [[lua_model|LuaModel]],​ [[lua_body|LuaBody]],​ [[lua_dof|LuaDof]],​ [[lua_actuator|LuaActuator]],​ [[lua_muscle|LuaMuscle]],​ [[lua_frame|LuaFrame]]. Example of a Lua measure script: <​code>​function init( model )
 +    -- This function is called at the start of the simulation
 +    -- '​model'​ can be used to initialize the measure parameters (see LuaModel)
 +end
 +
 +function update( model )
 +    -- This function is called at each simulation timestep
 +    -- Use it to update the internal variables of the measure (if needed)
 +    return false -- change to '​return true' to terminate the simulation early
 +end
 +
 +function result( model )
 +    -- This function is called at the end of the simulation
 +    -- It should return the result of the measure
 +    return 0.0
 +end
 +
 +function store_data( current_frame )
 +    -- This function is called at each simulation timestep
 +    -- '​current_frame'​ can be used to store values for analysis (see LuaFrame)
 +end
 +</​code>​ See Tutorial 6a and 6b for more information. ​
 +
 +**Inherits from** [[measure|Measure]].
 +
 +==== Public Attributes ====
 +^ Parameter ^ Type ^ Description ^
 +^ script_file | path | filename of the Lua script, path is relative to the .scone file |
 +^ name | String | Name of the [[measure|Measure]],​ to be used in reporting; defaults to measure type. |
 +^ weight | Real | Weighting factor applied to the result of the measure; default = 1. |
 +^ threshold | Real | Threshold above / below which the measure becomes zero; default = 0. |
 +^ result_offset | Real | Offset added to measure result; default = 0. |
 +^ minimize | bool | Indicate whether this measure should be minimized; default value depends on the measure type (usually true). |
 +^ start_time | TimeInSeconds | Time [s] at which [[controller|Controller]] becomes active; default = 0. |
 +^ stop_time | TimeInSeconds | Time [s] at which [[controller|Controller]] becomes inactive; default = until simulation ends. |
 +^ signature_prefix | String | Prefix signature with custom string. Special tags: DATE_TIME, DATE_TIME_EXACT,​ SCONE_VERSION. |
 +^ signature_postfix | String | Append custom string to signature. Special tags: DATE_TIME, DATE_TIME_EXACT,​ SCONE_VERSION. |
 +
 +<​sub>​Converted from doxygen using [[https://​github.com/​tgeijten/​dokugen|dokugen]]</​sub>​
  
  • (external edit)