```{raw} latex \clearpage ``` (sec-item-sensorobject)= # SensorObject A sensor attached to an object other than a body - a connector, a constraint, a joint - which measures one of the output variables of the object; a body is measured at a point, with SensorBody. ## Parameters The parameters of the item; in a dictionary, its type is 'Object': | name | type | size | default | description | |---|---|---|---|---| | **name** | String | | '' | sensor's unique name | | **objectNumber** | ObjectIndex | | invalid (-1) | object (e.g. connector) 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** | VSensorObject | | | parameters for visualization of item | ## Visualization parameters The parameters of `VSensorObject`, 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; sensors can be shown at the position assiciated with the object - note that in some cases, there might be no such position (e.g. data object)! | ## Drawing Drawn as [all sensors](#sec-drawing-sensors). (description-sensorobject)= ## Detailed description ### Attached to The object `objectNumber`, usually a connector, constraint or joint, which is measured as a whole and not at a point. ### Measures `outputVariableType` is one of the output variables of the object, as its page lists them under **Output variables** - for a spring-damper e.g. `Force` and `Distance`, for a joint the reaction forces and torques in the frame its page gives. (miniexample-sensorobject)= ## Mini example ```python #the force in a spring-damper, measured at the object node = mbs.AddNode(NodePoint(referenceCoordinates=[1,0,0])) mbs.AddObject(ObjectMassPoint(nodeNumber=node, mass=1)) mNode = mbs.AddMarker(MarkerNodePosition(nodeNumber=node)) mFixed = mbs.AddMarker(MarkerNodePosition(nodeNumber=nGround)) oSpring = mbs.AddObject(ObjectConnectorSpringDamper(markerNumbers=[mFixed, mNode], stiffness=100, referenceLength=1)) mbs.AddObject(ObjectConnectorCartesianSpringDamper(markerNumbers=[mFixed, mNode], stiffness=[0,100,100], offset=[1,0,0])) #holds y and z mbs.AddLoad(LoadForceVector(markerNumber=mNode, loadVector=[10,0,0])) sForce = mbs.AddSensor(SensorObject(objectNumber=oSpring, outputVariableType=exu.OutputVariableType.Force, storeInternal=True, writeToFile=False)) mbs.Assemble() mbs.SolveStatic() #the spring force equals the load exu.sys['testResult'] = mbs.GetSensorValues(sForce)[0] #10 ``` Examples (Ex) and TestModels (TM) that show this item, with weblink to github: [`tutorialSpringDamper.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/notebooks/tutorialSpringDamper.py) (Ex), [`tutorialSpringDamperCreate.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/notebooks/tutorialSpringDamperCreate.py) (Ex), [`pendulum2Dconstraint.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/pendulum2Dconstraint.py) (Ex), [`plotSensorExamples.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/plotSensorExamples.py) (Ex)