Meaning of timestamp

Hi, everyone.

Recently,I use the DWM1001-examples(https://github.com/Decawave/dwm1001-examples/tree/master/examples 3) as the software for DWM1001 hardware

/* Retrieve poll transmission and response reception timestamps. See NOTE 5 below. /
poll_tx_ts = dwt_readtxtimestamplo32();
resp_rx_ts = dwt_readrxtimestamplo32();
/
Get timestamps embedded in response message. /
resp_msg_get_ts(&rx_buffer[RESP_MSG_POLL_RX_TS_IDX], &poll_rx_ts);
resp_msg_get_ts(&rx_buffer[RESP_MSG_RESP_TX_TS_IDX], &resp_tx_ts);
/
Compute time of flight and distance, using clock offset ratio to correct for differing local and remote clock rates */
rtd_init = resp_rx_ts - poll_tx_ts;
rtd_resp = resp_tx_ts - poll_rx_ts;

  tof = ((rtd_init - rtd_resp * (1.0f - clockOffsetRatio)) / 2.0f) * DWT_TIME_UNITS; // Specifying 1.0f and 2.0f are floats to clear warning 
  distance = tof * SPEED_OF_LIGHT;

I have a little confuse of the meaning of poll_tx_ts, resp_rx_ts, poll_rx_ts, resp_tx_ts
Could you please help me answer which of t1, t2, t3,t4 in this picture is represented by poll_tx_ts, resp_rx_ts, poll_rx_ts, resp_tx_ts respectively
时间戳
It’s confused me. I need some help. Thanks!

Best regards!

Device A will be measuring the time it transmits and receives messages (t1 and t4). These are the poll transmit times and response reception times, poll_tx_ts and resp_rx_ts.
t2 and t3 are the poll reception time and response transmit times (poll_rx_ts and resp_tx_ts).

But the clock on devices A and B aren’t synchronized so you can’t simply do t2-t1 to get the time of flight. Instead you do:
tRoundA = t4 - t1 = resp_rx_ts - poll_tx_ts
tReplyB = t3 - t2 = resp_tx_ts - poll_rx_ts
and then
Time of flight = (tRoundA - tReplyB) / 2

Things get a little bit more complex because you have to allow for the clocks on devices A and B running at different speeds, that’s what the (1.0f - clockOffsetRatio) is adjusting for.
tRoundA - tReplyB

got it
thanks a lot!