2.2.4.2 Coordinate transformations

2.2.4.2.1 Vehicle and sensor coordinate systems

When running simulations, it is frequently necessary to transform coordinates from the global coordinate system for a specific vehicle and its sensors.

This section provides an overview of the messages and fields involved and their relationship for this task. It demonstrates how a global coordinate system, vehicle coordinate system, and sensor coordinate system are related on the basis of a specific (ego) vehicle.

Mathematical Definitions of Coordinate Transformations

All vectors and matrices are noted with reference frame as a superscript index and the direction of translation as a subscript index. [9] The translation direction is from the first index to the second index (src: source coordinate system, trg: target coordinate system). The vector \(\boldsymbol{v}^x\) denotes the 3D position of an object in the coordinate frame \(x\). Vector \(\boldsymbol{t}\) is the translation vector between two coordinate systems with the described indices for reference frame and direction. The angles yaw \(\psi\) around the z-axis, pitch \(\theta\) around the y-axis and roll \(\phi\) around the x-axis are defined in a right handed coordinate system according to DIN ISO 8855:2013 [6]. The sign of the angles corresponds to the direction of the transformation.

Transformation from source \(src\) to target \(trg\) coordinates:

\[\boldsymbol{v}^{trg} = \boldsymbol{R}_{src}^{trg} (\boldsymbol{v}^{src} - \boldsymbol{t}_{src,trg}^{src})\]

Transformation back from target \(trg\) to source \(src\) coordinates

\[\boldsymbol{v}^{src} = (\boldsymbol{R}_{src}^{trg})^{-1} \boldsymbol{v}^{trg} + \boldsymbol{t}_{src,trg}^{src}\]

With the rotation matrix (from rotating the coordinate system) [10]:

\[\boldsymbol{R}_{src}^{trg}=\boldsymbol{R}_{yaw,pitch,roll} = \boldsymbol{R}_{z,y,x} = \boldsymbol{R}_{x}(\phi) \boldsymbol{R}_{y}(\theta) \boldsymbol{R}_{z}(\psi) \\ \boldsymbol{R}_{z,y,x} = \begin{pmatrix} 1 & 0 & 0\\ 0 & \cos(\phi) & \sin(\phi)\\ 0 & -\sin(\phi) & \cos(\phi) \end{pmatrix} \begin{pmatrix} \cos(\theta) & 0 & -\sin(\theta)\\ 0 & 1 & 0\\ \sin(\theta) & 0 & \cos(\theta) \end{pmatrix} \begin{pmatrix} \cos(\psi) & \sin(\psi) & 0\\ -\sin(\psi) & \cos(\psi) & 0\\ 0 & 0 &1 \end{pmatrix} \\ \boldsymbol{R}_{z,y,x} = \begin{pmatrix} \cos(\theta)\cos(\psi) & \cos(\theta)\sin(\psi) & -\sin(\theta)\\ \sin(\phi)\sin(\theta)\cos(\psi)-\cos(\phi)\sin(\psi) & \sin(\phi)\sin(\theta)\sin(\psi)+\cos(\phi)\cos(\psi) & \sin(\phi)\cos(\theta)\\ \cos(\phi)\sin(\theta)\cos(\psi)+\sin(\phi)\sin(\psi) & \cos(\phi)\sin(\theta)\sin(\psi)-\sin(\phi)\cos(\psi) & \cos(\phi)\cos(\theta) \end{pmatrix}\]

Get Tait–Bryan angles from rotation matrix [11]:

\[\theta = -\arcsin(R_{13}) \\ \psi = \arctan2(R_{12}/\cos(\theta),R_{11}/\cos(\theta)) \\ \phi = \arctan2(R_{23}/\cos(\theta),R_{33}/\cos(\theta))\]

Relative orientation:

Object rotation Matrix: \(\boldsymbol{R}_{object}^{src}\)
Host vehicle rotation Matrix: \(\boldsymbol{R}_{ego}^{src}\)
Resulting rotation matrix between object and host: \(\boldsymbol{R}_{object}^{src}(\boldsymbol{R}_{ego}^{src})^{T}\)

To transform from world coordinates into host vehicle coordinates and back use the formulas from above with the world coordinates frame \(w\) as source system \(src\) and host vehicle coordinates frame \(v\) as target system \(trg\). To transform from host vehicle coordinates into sensor coordinates and back use the formulas from above with the host vehicle coordinates frame \(v\) as source system \(src\) and sensor coordinates frame \(s\) as target system \(trg\).

Corresponding messages

GroundTruth::moving_object::base::position

This field defines the position of the vehicle’s reference point in global coordinates. In Open Simulation Interface, an object’s position is defined by the coordinates of the center of the object’s 3D bounding box.

GroundTruth::moving_object::base::orientation

This field defines the orientation of the vehicle’s reference point in global coordinates.

GroundTruth::moving_object::vehicle_attributes::bbcenter_to_rear

This field specifies the vector pointing from the vehicle’s reference point to the middle of the rear axle under neutral load conditions.

SensorData::mounting_position

This field defines the sensor’s virtual mounting position and orientation and thereby the origin of the virtual sensor coordinate system. The mounting position is given in the host vehicle coordinate system.

Example

The following image shows the relationship between the coordinate systems. The reference point of the vehicle is given by a vector in the global coordinate system. A vector pointing from the reference position of the vehicle to the center of the rear axle then yields the origin of the host vehicle coordinate system. The mounting positions of the sensors and therefore the origins of the corresponding sensor coordinate systems are given with respect to the host vehicle coordinate system.

Static
Figure 11. Schematic example of OSI coordinate systems and their relationship