User Tools

Site Tools



Note: TWR-TDMA is now considered obsolete and replaced by the TDoA modes. TDoA will generally have better performance than TWR-TDMA, TWR might still be useful to you though but if you are setting up a single room system TDoA is most likely the way to go.


The Two Way Ranging Time Division Multiple Access (TWR-TDMA) mode allows to position multiple tag in Two Way Ranging mode (TWR).

The TWR mode is an active ranging mode where the tag is pinging the anchors in order to measure the distance between the tag and the anchor. By doing so on multiple anchor and by knowing the anchor position, the tag can calculate its own position.

The advantage of this technique is that the position estimation is quite stable in the Anchor convex hull, and deteriorate only slowly when leaving the convex hull (in contrast with the TDoA mode that deteriorate extremely fast outside the convex hull).

The disadvantage is that the tag has to actively send packets, it means that two tag cannot range at the same time and so some synchronization mechanism has to be put in place to allow multiple tag to use TWR measurement concurrently.

TWR-TDMA is implementing this concurrent mode using a Time Division Multiple Access algorithm. To do so, we define a time slot width and number of time slot per frame. Each tag is assigned a time slot and is only allowed to communicate in its assigned time slot. All the tags are synchronized on the Anchor 0 clock, they use it to calculate the position, in time, of the time slots.

Compiling Crazyflie for TWR-TDMA ranging

In order to activate TWR-TDMA, you need to recompile the Crazyflie firmware. Add the following to 'tools/make/':

# CFLAGS += -DTDMA_SLOT=0        # Optional, see bellow
  • LPS_TDMA_ENABLE=1 Enable the TDMA mode for TWR
  • TDMA_NSLOTS_BITS=1 Configures 2 time slot (good for 2 tags) per frame. The number of time slot per frame is 2^TDMA_NSLOTS_BITS
  • TDMA_SLOT Optionally hardcode the time slot. See bellow for time slot auto-configuration

Configuring time slots

If TDMA_SLOT is not set in, the time slot is going to be set from the Crazyflie radio address. The algorithm used to set the slot is TDMA_SLOT = radioAddress % (2^TDMA_NSLOTS_BITS). So if you set consecutive radio address for your Crazyflies, it will set a different time slot for each Crazyflie. For example, for 2 Crazyflies, you could set address 'E7E7E7E701' and 'E7E7E7E702'.

System performance

TWR-TDMA is currently implemented with time slots of 4ms. Each time slot is used by one tag to range with one anchor. This means that the ranging rate is of 1/(0.004 * 2^TDMA_NSLOTS_BITS) and the rate of update of the full system is 1/(0.004 * 2^TDMA_NSLOTS_BITS * nAnchors) where nAnchors is the number of anchors in the system.

The more timeslots per frame, the less often measurements can be used to estimate the tag position and so the performance of the position estimate will deteriorate. For a great number of tag the TDoA mode is better suited.

doc/lps/twr-tdma.txt · Last modified: 2018-10-19 07:24 by arnaud