@@ -15,7 +15,9 @@ Launch the RTDE publisher node using the provided launch file:
1515 ros2 launch ur_rtde_publisher rtde_publisher.launch.xml \
1616 robot_ip:=192.168.56.101 \
1717 output_recipe:=' ["payload", "robot_mode"]' \
18- rtde_frequency:=125
18+ rtde_frequency:=125 \
19+ use_robot_timestamp:=true \
20+ t_delay:=0.004
1921
2022 After launching, verify the node is running:
2123
@@ -81,6 +83,26 @@ The following parameters control the node behavior:
8183 *Example: * setting ``tf_prefix:=robot1 `` and the default ``frame_id `` of ``base ``
8284 results in ``robot1/base ``.
8385
86+ - ``use_robot_timestamp `` (bool, optional, default: ``false ``)
87+
88+ When enabled, the node uses the robot controller's internal hardware clock to stamp
89+ ROS 2 messages instead of the host PC's local processing time.
90+
91+ For a detailed explanation of the timeline reconstruction, see the
92+ `Timestamp Synchronization `_ section.
93+
94+ *Example: * ``use_robot_timestamp:=true ``
95+
96+ - ``t_delay `` (double, optional, default: ``0.0 ``)
97+
98+ Constant time offset in seconds (s) to compensate for network latency between the robot and the ROS PC.
99+
100+ This parameter is only effective when ``use_robot_timestamp `` is enabled. It shifts the reconstructed
101+ timeline backward, allowing the ROS timestamps to better approximate the exact moment the physical
102+ measurement occurred on the robot hardware. See `Timestamp Synchronization `_ for the mathematical implementation.
103+
104+ *Example: * ``t_delay:=0.004 `` to compensate for an estimated 4 ms communication delay.
105+
84106
85107
86108Configuration
@@ -103,6 +125,76 @@ systematically prepend a prefix to the default ``frame_id`` values defined in
103125Apart from frame-related metadata, modifying RTDE variables, message types, or mappings
104126is not recommended and may lead to inconsistent behavior.
105127
128+ Timestamp Synchronization
129+ -----------------------------------
130+
131+ When the ``use_robot_timestamp `` parameter is enabled, the node switches from host-side
132+ timestamping to a reconstructed timeline anchored directly to the robot controller's
133+ internal hardware clock.
134+
135+ .. note ::
136+ The timestamp received over RTDE represents the time in seconds since the controller
137+ startup (boot time).
138+
139+ Timeline Reconstruction Mechanism
140+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
141+
142+ **1. Anchor Setup (First Packet) **
143+
144+ Upon receiving the first RTDE packet, the node captures the current host ROS time (:math: `t_{\text {host}}`)
145+ and the initial robot hardware timestamp (:math: `T_0 `). It applies the network latency compensation factor
146+ ``t_delay `` to calculate an adjusted host base time (:math: `t_0 `):
147+
148+ .. math ::
149+ t_0 = t_{\text {host}} - t_{\text {delay}}
150+
151+ **2. Linear Tracking (Subsequent Packets) **
152+
153+ For all consecutive packets, the node tracks the elapsed hardware time using the incoming robot timestamp (:math: `T`).
154+ The final ROS 2 message timestamp (:math: `t_{\text {msg}}`) is linearly extrapolated as:
155+
156+ .. math ::
157+ t_{\text {msg}} = t_0 + (T - T_0 )
158+
159+ **Walkthrough Example: ** Consider a configuration using ``use_robot_timestamp:=true `` and ``t_delay:=0.004 `` (values in seconds):
160+
161+ .. list-table ::
162+ :align: center
163+ :widths: 20 15 25 40
164+ :header-rows: 1
165+
166+ * - Scope / Step
167+ - Variable
168+ - Value
169+ - Mathematical Context / Equation
170+ * - **Packet 1 ** (Initialization)
171+ - :math: `t_{\text {host}}`
172+ - ``1779781131.140454 ``
173+ - Host PC reception time
174+ * -
175+ - :math: `T_0 `
176+ - ``9010.081000 ``
177+ - Initial robot hardware timestamp
178+ * -
179+ - :math: `t_{\text {delay}}`
180+ - ``0.004 ``
181+ - Configured latency compensation
182+ * -
183+ - :math: `t_0 `
184+ - ``1779781131.136454 ``
185+ - Adjusted base ROS time: :math: `t_{\text {host}} - t_{\text {delay}}`
186+ * - **Packet 2 ** (Next Cycle)
187+ - :math: `T`
188+ - ``9010.087000 ``
189+ - Current robot hardware timestamp
190+ * -
191+ - :math: `dt`
192+ - ``0.006 ``
193+ - Elapsed hardware time: :math: `T - T_0 `
194+ * -
195+ - :math: `t_{\text {msg}}`
196+ - ``1779781131.142454 ``
197+ - Final ROS message timestamp: :math: `t_0 + dt`
106198
107199Typical Workflow
108200----------------
@@ -136,6 +228,5 @@ There are several aspects users should be aware of when using the RTDE ROS2 Publ
136228 the node, at the time RTDE data is received and published. These timestamps
137229 therefore reflect host‑side reception time rather than the exact time at which
138230 the data was produced by the robot controller.
139- If precise controller‑side timing is required, users may include the RTDE
140- ``timestamp `` variable in the ``output_recipe `` and use it as a reference for
141- time synchronization or post‑processing.
231+ If precise controller‑side timing is required, users can enable hardware timeline
232+ reconstruction. See the `Timestamp Synchronization `_ section for details.
0 commit comments