Coverage for runmacs/geometry/mounttree.py : 82%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- mounttree =========
handling of mount tree files """
""" Parses a rotation string, given as multiplication of rotations about x,y or z axes.
:param x: String like ``Rx(5deg)*Ry(-7.2rad)``
Units (``deg`` or ``rad``) are optional, ``rad`` is default. """ unit = 'rad' elif unit == 'rad': f = 1 else: raise ValueError('unknown unit "%s"'%unit)
""" Parses a rotation, either as a list of euler angles or like :py:func:`parseRotationPrimitives`. """ return np.eye(3)
raise ValueError('too many arguments') kwargs[k] = v else:
else:
""" Dummy applicator for no time correction. """ """ Applies time correction (in this case, returns ``t`` as it is). """ return t
""" Applies time correction (in this case, returns ``t`` as it is) for datetime64 object. """ return t
""" Applicator for constant time correction.
:param dt: time offset (in seconds)
Performs a constant time correction. """ """ Applies time correction. """
""" Applies time correction for datetime64 object. """ return t + np.timedelta64(self.dt, 's')
""" Applicator for two point time correction.
:param t1: reference time 1 (as unix timestamp) :param t2: reference time 2 (as unix timestamp) :param dt1: time offset at ``t1`` (in seconds) :param dt2: time offset at ``t2`` (in seconds)
Performs a time correction by a linear interpolation (and extrapolation) of the time offsets ``dt1`` and ``dt2`` between the reference times ``t1`` and ``t2``. """ """ Applies time correction. """
""" Applies time correction for datetime64 object. """ return t + np.timedelta64(self.dt1, 's') + self.f * (t - self.t1_dt)
'null': NullTimeCorrection, 'constant': ConstantTimeCorrection, 'twopoint': TwopointTimeCorrection }
'name': sensor['name'], 'sensorId': sensor['sensorId'], 'coordinateframe': coordinateframe['framename'], 'tofs': timeCorrections[tofs['method']](**tofs['params']), 'provides': sensor.get('provides', []) }
""" mounttree representation
.. py:attribute:: name
The name of the mounttree.
.. py:attribute:: validFrom
Start of validity period.
.. py:attribute:: validUntil
End of validity period.
.. py:function:: update(**kwargs)
Updates the dynamic variables of the mounttree.
All named variables from the mount tree can be given as keyword arguments.
.. py:attribute:: universe
The coordinate universe defined by the mounttree
.. py:attribute:: sensors
:py:class:`list` of all sensors defined by the tree.
.. py:attribute:: sensorsById
:py:class:`dict` of all sensors defined by the tree with ``sensorId`` as keys. """ def fromDict(cls, mtDict): """ Constructs a MountTree from a dictionary.
:param mtDict: :py:class:`dict` describing the mounttree. """ def requiredSensors(self): """ Returns a :py:class:`set` of all sensorIds which provide data for the mounttree orientation. """ def availableSensors(self): """ Returns a :py:class:`set` of all sensorIds defined in the mounttree. """ def coordinateframes(self): """ Returns a :py:class:`dict` of coordinate frames defined in the mounttree. """ import pydot graph = pydot.Dot(graph_type='digraph', graph_name='_', rankdir='TD') for name, frame in self.coordinateframes.items(): node = pydot.Node(name, label=name) graph.add_node(node) for name, frame in self.coordinateframes.items(): if frame.referenceSystem is not None: edge = pydot.Edge(frame.referenceSystem.name, name) graph.add_edge(edge) return graph return self._repr_dot_().create_svg() |