Skip to content

Commit 432c14c

Browse files
mergify[bot]ahcordetfoote
authored
Add draft of velocity transform specification (#4235) (#5648)
(cherry picked from commit 0e034c7) Signed-off-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: Tully Foote <[email protected]>
1 parent 95dbbf3 commit 432c14c

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

source/Concepts/Intermediate/About-Tf2.rst

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,101 @@ tf2 can operate in a distributed system.
3030
This means all the information about the coordinate frames of a robot is available to all ROS 2 components on any computer in the system.
3131
tf2 can have every component in your distributed system build its own transform information database or have a central node that gathers and stores all transform information.
3232

33+
.. mermaid::
34+
35+
flowchart LR
36+
E((Earth))
37+
E --> A[[Car A]]
38+
E --> B[[Car B]]
39+
E --> C{{Satellite C}}
40+
E --> D((Moon D))
41+
42+
Publishing transforms
43+
^^^^^^^^^^^^^^^^^^^^^
44+
45+
When publishing transforms we typically think of the transforms as the transform from one frame to the other.
46+
The semantic difference is whether you are transforming data represented in a frame or transforming the frame itself.
47+
These values are directly inverse.
48+
Transforms published in the ``geometry_msgs/msg/Transform`` message represent the frame formulation.
49+
Keep this in mind when debugging published transforms they are the inverse of what you will lookup depending on what direction you're traversing the transform tree.
50+
51+
.. math::
52+
53+
54+
_{B}T^{data}_{A} = (_{B}T^{frame}_{A})^{-1}
55+
56+
The TF library handles inverting these elements for you depending on which way you're traversing the transform tree.
57+
For the rest of this document we will just use :math:`T^{data}` but the ``data`` is unwritten.
58+
59+
Position
60+
^^^^^^^^
61+
62+
If the driver in car :math:`A` observes something and a person on the ground wants to know where it is relative to it's position, you transform the observation from the source frame to the target frame.
63+
64+
.. math::
65+
66+
_{E}T_{A} * P_{A}^{Obs} = P_{E}^{Obs}
67+
68+
69+
Now if a person in car B wants to know where it is too you can compute the net transform.
70+
71+
72+
.. math::
73+
74+
_{B}T_{E} * _{E}T_{A} * P_{A}^{Obs} = _{B}T_{A} * P_{A}^{Obs} = P_{B}^{Obs}
75+
76+
77+
This is exactly what ``lookupTransform`` provides where ``A`` is the *source* ``frame_id`` and ``B`` is the *target* ``frame_id``.
78+
79+
It is recommended to use the ``transform<T>(target_frame, ...)`` methods when possible because they will read the *source* ``frame_id`` from the datatype and write out the *target* ``frame_id`` in the resulting datatype and the math will be taken care of internally.
80+
81+
If :math:`P` is a ``Stamped`` datatype then :math:`_A` is it's ``frame_id``.
82+
83+
As an example, if a root frame ``A`` is one meter below frame ``B`` the transform from ``A`` to ``B`` is positive.
84+
85+
However when converting data from coordinate frame ``B`` to coordinate frame ``A`` you have to use the inverse of this value.
86+
This can be seen as you'll be adding value to the height when you change to the lower reference frame.
87+
However if you are transforming data from coordinate frame ``A`` into coordinate frame ``B`` the height is reduced because the new reference is higher.
88+
89+
.. math::
90+
91+
92+
_{B}T_{A} = (_{B}{Tf}_{A})^{-1}
93+
94+
95+
Velocity
96+
^^^^^^^^
97+
98+
For representing ``Velocity`` we have three pieces of information.
99+
:math:`V^{moving\_frame - reference\_frame}_{observing\_frame}`
100+
This velocity represents the velocity between the moving frame and the reference frame.
101+
And it is represented in the observing frame.
102+
103+
For example a driver in Car A can report that they're driving forward (observed in A) at 1m/s (relative to earth) so that would be :math:`V_{A}^{A - E} = (1,0,0)`
104+
Whereas that same velocity could be observed from the view point of the earth (lets assume the car is driving east and Earth is NED), it would be :math:`V_{E}^{A - E} = (0, 1, 0)`
105+
106+
However transforms can show that these are actually the same with:
107+
108+
.. math::
109+
110+
_{E}T_{A} * V_{A}^{A - E} = V_{E}^{A - E}
111+
112+
113+
Velocities can be added or subtracted if they're represented in the same frame, in this case ``Obs``.
114+
115+
.. math::
116+
117+
V_{Obs}^{A - C} = V_{Obs}^{A - B} + V_{Obs}^{D - C}
118+
119+
Velocities can be "reversed" by inverting.
120+
121+
.. math::
122+
123+
V_{Obs}^{A - C} = -(V_{Obs}^{C - A})
124+
125+
If you want to compare two velocities you must first transform them into the same observational frame first.
126+
127+
33128
Tutorials
34129
---------
35130

0 commit comments

Comments
 (0)