```{raw} latex \clearpage ``` (sec-item-sensornode)= # SensorNode A sensor attached to a node, which measures one of the output variables of the node. ## Parameters The parameters of the item; in a dictionary, its type is 'Node': | name | type | size | default | description | |---|---|---|---|---| | **name** | String | | '' | sensor's unique name | | **nodeNumber** | NodeIndex | | invalid (-1) | node 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 | | **outputVariableType** | OutputVariableType | | OutputVariableType::_None | OutputVariableType for sensor | | **storeInternal** | Bool | | False | true: store sensor data in memory (faster, but may consume large amounts of memory); false: internal storage not available | | **visualization** | VSensorNode | | | parameters for visualization of item | ## Visualization parameters The parameters of `VSensorNode`, 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 | ## Drawing Drawn as [all sensors](#sec-drawing-sensors). (description-sensornode)= ## Detailed description ### Attached to The node `nodeNumber`: every node, with {ref}`ODE2 `, {ref}`ODE1 ` or other coordinates. ### Measures `outputVariableType` is one of the output variables of the node, as its page lists them under **Output variables** - `Position`, `Velocity`, `Coordinates`, and for a rigid body node also `RotationMatrix`, `AngularVelocity` and the like. The frame is the one the node page gives for the variable. (miniexample-sensornode)= ## Mini example ```python #the position of a node, stored during the simulation node = mbs.AddNode(NodePoint(referenceCoordinates=[0,0,0], initialVelocities=[1,0,0])) mbs.AddObject(ObjectMassPoint(nodeNumber=node, mass=1)) sNode = mbs.AddSensor(SensorNode(nodeNumber=node, outputVariableType=exu.OutputVariableType.Position, storeInternal=True, writeToFile=False)) mbs.Assemble() mbs.SolveDynamic() #rows [t, x, y, z]; the last row at t=1 data = mbs.GetSensorStoredData(sNode) exu.sys['testResult'] = data[-1,0] + data[-1,1] #1+1 ``` Examples (Ex) and TestModels (TM) that show this item, with weblink to github: [`plotSensorExamples.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/plotSensorExamples.py) (Ex), [`sensorUserFunctionTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/sensorUserFunctionTest.py) (TM), [`springDamperUserFunctionTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/springDamperUserFunctionTest.py) (TM), [`rigidBodyCOMtest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/rigidBodyCOMtest.py) (TM), [`plotSensorTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/plotSensorTest.py) (TM)