```{raw} latex \clearpage ``` (sec-item-sensorkinematictree)= # SensorKinematicTree A sensor attached to a link $n_l$ of an ObjectKinematicTree at a local position $\pLocB$ in the frame of the link, which measures one of the output variables of the kinematic tree at that point. ## Parameters The parameters of the item; in a dictionary, its type is 'KinematicTree': | name | type | size | default | description | |---|---|---|---|---| | **name** | String | | '' | sensor's unique name | | **objectNumber** | ObjectIndex | | invalid (-1) | object number of KinematicTree to which sensor is attached to | | **linkNumber** | UInt | | invalid (-1) | (symbol: $n_l$) number of link in KinematicTree to measure quantities; **must be given**: the default is only a placeholder | | **localPosition** | Vector3D | 3 | [0.,0.,0.] | (symbol: $\LU{l}{\bv}$) local (link-fixed) position of sensor, defined in link ($n_l$) coordinate system | | **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** | VSensorKinematicTree | | | parameters for visualization of item | ## Visualization parameters The parameters of `VSensorKinematicTree`, 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-sensorkinematictree)= ## Detailed description ### Attached to The `ObjectKinematicTree` `objectNumber`, at its link `linkNumber` $n_l$ and the point `localPosition` $\LU{l}{\bv}$, given in the frame of that link. ### Measures `outputVariableType` is one of the output variables the kinematic tree provides for a link, as its page lists them under the output variables of `SensorKinematicTree` - e.g. the position, velocity or rotation of that point of the link. (miniexample-sensorkinematictree)= ## Mini example ```python #a point of a link of a kinematic tree: one prismatic link along x, pulled by a force nTree = mbs.AddNode(NodeGenericODE2(referenceCoordinates=[0.], initialCoordinates=[0.], initialCoordinates_t=[0.], numberOfODE2Coordinates=1)) oTree = mbs.AddObject(ObjectKinematicTree(nodeNumber=nTree, jointTypes=[exu.JointType.PrismaticX], linkParents=[-1], jointTransformations=exu.Matrix3DList([np.eye(3)]), jointOffsets=exu.Vector3DList([[0,0,0]]), linkInertiasCOM=exu.Matrix3DList([np.eye(3)]), linkCOMs=exu.Vector3DList([[0,0,0]]), linkMasses=[2.])) mLink = mbs.AddMarker(MarkerKinematicTreeRigid(objectNumber=oTree, linkNumber=0, localPosition=[0,0,0])) mbs.AddLoad(LoadForceVector(markerNumber=mLink, loadVector=[1,0,0])) sLink = mbs.AddSensor(SensorKinematicTree(objectNumber=oTree, linkNumber=0, localPosition=[0.5,0,0], outputVariableType=exu.OutputVariableType.Position, storeInternal=True, writeToFile=False)) mbs.Assemble() mbs.SolveDynamic() #local position 0.5 plus the joint coordinate F/(2m)*t^2 at t=1 exu.sys['testResult'] = mbs.GetSensorValues(sLink)[0] #0.75 ``` Examples (Ex) and TestModels (TM) that show this item, with weblink to github: [`kinematicTreeConstraintTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeConstraintTest.py) (TM)