```{raw} latex \clearpage ``` (sec-item-sensorload)= # SensorLoad A sensor attached to a load, which measures the value of the load. ## Parameters The parameters of the item; in a dictionary, its type is 'Load': | name | type | size | default | description | |---|---|---|---|---| | **name** | String | | '' | sensor's unique name | | **loadNumber** | LoadIndex | | invalid (-1) | load number to which sensor is attached to | | **writeToFile** | Bool | | True | True: write sensor output to file; flag is ignored (interpreted as False), if fileName='' | | **fileName** | String | | '' | directory and file name for sensor file output; empty: no file is written; a relative name is placed in `exudyn.config.outputDirectory` if that is set; the directory is created if it does not exist | | **storeInternal** | Bool | | False | true: store sensor data in memory (faster, but may consume large amounts of memory); false: internal storage not available | | **visualization** | VSensorLoad | | | parameters for visualization of item | ## Visualization parameters The parameters of `VSensorLoad`, given as `visualization`: | name | type | size | default | description | |---|---|---|---|---| | **show** | Bool | | True | set true, if item is shown in visualization and false if it is not shown; the sensor is drawn at the position of the marker of its load, if the marker has a position | ## Drawing Drawn as [all sensors](#sec-drawing-sensors); at the position of the marker of its load, if the marker has a position; a load on a coordinate has none. (description-sensorload)= ## Detailed description ### Attached to The load `loadNumber`. ### Measures The value of the load at the current time: the vector or the scalar, as the load item computes it - from `loadVector` or `load`, or from its user function - and in the frame it is given in, which is the body frame for a load with `bodyFixed = True`. The load factor of a static computation is not included. There is no `outputVariableType`. (miniexample-sensorload)= ## Mini example ```python #the value of a load, here of a load with a user function, which the load vector does not show node = mbs.AddNode(Node1D(referenceCoordinates=[0])) mbs.AddObject(ObjectMass1D(nodeNumber=node, mass=1)) mCoord = mbs.AddMarker(MarkerNodeCoordinate(nodeNumber=node, coordinate=0)) def UFload(mbs, t, load): return load*np.cos(np.pi*t) lCoord = mbs.AddLoad(LoadCoordinate(markerNumber=mCoord, load=2, loadUserFunction=UFload)) sLoad = mbs.AddSensor(SensorLoad(loadNumber=lCoord, storeInternal=True, writeToFile=False)) mbs.Assemble() mbs.SolveDynamic() #the load at t=1: 2*cos(pi) exu.sys['testResult'] = mbs.GetSensorValues(sLoad) #-2 ``` Examples (Ex) and TestModels (TM) that show this item, with weblink to github: [`springDamperUserFunctionTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/springDamperUserFunctionTest.py) (TM), [`plotSensorTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/plotSensorTest.py) (TM)