Skip to content

Commit 5c44f27

Browse files
authored
Merge pull request #607 from OpenSimulationInterface/604_coordinate_transformation
Added coordinate transformation to documentation
2 parents ce35bc3 + 77cf2a9 commit 5c44f27

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed

doc/architecture/reference_points_coordinate_systems.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Coordinate systems and reference points
1+
= Coordinate systems, reference points and coordinate transformation
22

33
OSI uses DIN ISO 8855:2013-11 cite:[iso8855] for coordinate systems and transformations between coordinate systems.
44
OSI uses three coordinate systems:

doc/usecases/transforming_coordinate_systems.adoc

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,75 @@ When running simulations, it is frequently necessary to transform coordinates fr
77
This section provides an overview of the messages and fields involved and their relationship for this task.
88
It demonstrates how a global coordinate system, vehicle coordinate system, and sensor coordinate system are related on the basis of a specific (ego) vehicle.
99

10-
//TODO: Should we add one or more sentences about the mathematical operations involved?
10+
**Mathematical Definitions of Coordinate Transformations**
11+
12+
All vectors and matrices are noted with reference frame as a superscript index and the direction of translation as a supscript index. cite:[reuper2020]
13+
The translation direction is from the first index to the second index (src: source coordinate system, trg: target coordinate system).
14+
The vector latexmath:[\boldsymbol{v}^x] denotes the 3D position of an object in the coordinate frame latexmath:[x].
15+
Vector latexmath:[\boldsymbol{t}] is the translation vector between two coordinate systems with the described indices for reference frame and direction.
16+
The angles yaw latexmath:[\psi] around the z-axis, pitch latexmath:[\theta] around the y-axis and roll latexmath:[\phi] around the x-axis are defined in a right handed coordinate system according to DIN ISO 8855:2013 cite:[iso8855].
17+
The sign of the angles corresponds to the direction of the transformation.
18+
19+
Transformation from source latexmath:[src] to target latexmath:[trg] coordinates:
20+
[latexmath]
21+
++++
22+
\boldsymbol{v}^{trg} = \boldsymbol{R}_{src}^{trg} (\boldsymbol{v}^{src} - \boldsymbol{t}_{src,trg}^{src})
23+
++++
24+
25+
Transformation back from target latexmath:[trg] to source latexmath:[src] coordinates
26+
[latexmath]
27+
++++
28+
\boldsymbol{v}^{src} = (\boldsymbol{R}_{src}^{trg})^{-1} \boldsymbol{v}^{trg} + \boldsymbol{t}_{src,trg}^{src}
29+
++++
30+
31+
32+
With the rotation matrix (from rotating the coordinate system) cite:[wiki_rotation_matrix]:
33+
[latexmath]
34+
++++
35+
\boldsymbol{R}_{srv}^{trg}=\boldsymbol{R}_{yaw,pitch,roll} = \boldsymbol{R}_{z,y,x} = \boldsymbol{R}_{x}(\phi) \boldsymbol{R}_{y}(\theta) \boldsymbol{R}_{z}(\psi) \\
36+
37+
\boldsymbol{R}_{z,y,x} =
38+
\begin{pmatrix}
39+
1 & 0 & 0\\
40+
0 & \cos(\phi) & \sin(\phi)\\
41+
0 & -\sin(\phi) & \cos(\phi)
42+
\end{pmatrix}
43+
\begin{pmatrix}
44+
\cos(\theta) & 0 & -\sin(\theta)\\
45+
0 & 1 & 0\\
46+
\sin(\theta) & 0 & \cos(\theta)
47+
\end{pmatrix}
48+
\begin{pmatrix}
49+
\cos(\psi) & \sin(\psi) & 0\\
50+
-\sin(\psi) & \cos(\psi) & 0\\
51+
0 & 0 &1
52+
\end{pmatrix} \\
53+
54+
\boldsymbol{R}_{z,y,x} =
55+
\begin{pmatrix}
56+
\cos(\theta)\cos(\psi) & \cos(\theta)\sin(\psi) & -\sin(\theta)\\
57+
\sin(\phi)\sin(\theta)\cos(\psi)-\cos(\phi)\sin(\psi) & \sin(\phi)\sin(\theta)\sin(\psi)+\cos(\phi)\cos(\psi) & \sin(\phi)\cos(\theta)\\
58+
\cos(\phi)\sin(\theta)\cos(\psi)+\sin(\phi)\sin(\psi) & \cos(\phi)\sin(\theta)\sin(\psi)-\sin(\phi)\cos(\psi) & \cos(\phi)\cos(\theta)
59+
\end{pmatrix}
60+
++++
61+
62+
Get Tait–Bryan angles from rotation matrix cite:[wiki_euler_angles]:
63+
[latexmath]
64+
++++
65+
\theta = -\arcsin(R_{13}) \\
66+
\psi = \arctan2(R_{12}/\cos(\theta),R_{11}/\cos(\theta)) \\
67+
\phi = \arctan2(R_{23}/\cos(\theta),R_{33}/\cos(\theta))
68+
++++
69+
70+
**Relative orientation**:
71+
72+
Object rotation Matrix: latexmath:[\boldsymbol{R}_{object}^{src}] +
73+
Host vehicle rotation Matrix: latexmath:[\boldsymbol{R}_{ego}^{src}] +
74+
Resulting rotation matrix between object and host: latexmath:[\boldsymbol{R}_{object}^{src}(\boldsymbol{R}_{ego}^{src})^{T}] +
75+
76+
To transform from world coordinates into vehicle coordinates and back use the formulas from above with the world coordinates frame latexmath:[w] as source system latexmath:[src] and vehicle coordinates frame latexmath:[v] as target system latexmath:[trg].
77+
To transform from world coordinates into vehicle coordinates and back use the formulas from above with the vehicle coordinates frame latexmath:[v] as source system latexmath:[src] and sensor coordinates frame latexmath:[s] as target system latexmath:[trg].
78+
1179

1280
**Corresponding messages**
1381

0 commit comments

Comments
 (0)