Skip to content

Communications

superpingu edited this page Feb 2, 2017 · 5 revisions

Radio Communications

System components

The system is composed of :

  • a computer allowing the user to control the system
  • up to 15 robots able to move and perform dances.
  • a master beacon connected to the computer relaying orders to the robots and ranging.
  • 2 slave beacons ranging and sending back measurements to the master beacon.

General principles

  • Time is divided in frames of constant and pre-defined length (currently 100ms).
  • Each frame is divided into time slots (currently 2ms), containing either no-communication or one message from a beacon a one reply.
  • The master beacon defines timings by periodically sending a start-of-frame (SOF) message.
  • The robots and slave beacons synchronize by searching for SOF and enable receiver at specific time slots after that.

Here is the typical message sequence with sender (TX) and receiver (RX), robot N1 and N2 are already connected and a new robot has just been added :

Device SOF SB1 read SB2 read ranging ranging ranging ranging ranging ranging ... New Robot
Master beacon TX TX TX TX TX ... TX
Slave beacon 1 RX RX TX TX ...
Slave beacon 2 RX RX TX TX ...
Robot N1 RX RX RX RX ...
Robot N2 RX RX RX RX ...
New robot RX ... RX

Synchronisation mechanism

When a new robot is added, or when a robot lose synchronisation, it runs a synchronisation routine :

  1. turn on receiver for 50ms, sleep for 500ms (to avoid the module excessive heating) and loop until a SOF is received
  2. Send a response to the frame's new robot message (last time slot of each frame)
  3. a shorter ID (8 bits) is given to the robot that will be used for communications
  4. the robot listens to the next SOF and check its short ID has been added to the connected robots list. In case of failure, wait a random number of frames and go back to 2.

Ranging mechanism

To measure the distance from a beacon to a robot, a single-sided two way ranging is implemented (see DW1000 user manual, appendix 3) :

  • the beacon sends ranging message to a robot, and save the value of the ranging timer when the R marker is sent
  • the robot receives the message, and saves the value of the ranging timer when the R marker is received
  • the robot sends the response after a known time has elapsed
  • the beacon receives the response, save the value of the ranging timer when the R marker is received and computes the time of flight

Messages

General format

Message ID Destination address Payload ...

Each type of message has a different message ID. Destination address can be :

  • 0 for master beacon
  • 253 for slave beacon 1
  • 254 for slave beacon 2
  • a short ID from 1 to 20 for a robot
  • 255 for broadcast

Start-of-frame (SOF)

Sent by master beacon at the beginning of a frame, it sets the time origin for a frame. Precise moments to listen to are computed from this reference by robots and slave beacons. It also broadcasts some data about the system.

0x23 0xFF Session ID Date Connected beacons Connected robot ID 1 ... Connected robot ID N

Session ID : a number chosen randomly when master beacon starts
Date : shared time in 0.1s, allows robots to synchronise during the dance
Connected beacons : bit 0 : if SB1 is connected, bit 1 : if SB2 is connected
Connected robot 1..N : list of the short ID of the connected robots. The robot will receive ranging messages in the same order.

Slave beacon read

Allows the master beacon to retrieve measurements done in the last time frame.

0x32 SB ID

Response :

0x32 0 Robot 1 dist (2 bytes) ... Robot N dist (2 bytes)

The distances are sent in the order given by the previously sent ID list (in SOF), in cm and unsigned.

Ranging

Message sent to a robot to do a distance measurement. When sent from master beacon, it is also allows to exchange data.

Master beacon send :

0x42 RB ID last known X (2 bytes) last known Y (2 bytes) flags

RB ID : robot short ID
last known X, last known Y : coordinates of the robot measured in the last frame (in cm, 16 bits signed)
flags :

  • bit 0 : Dance enable : 1 if the robot should play the dance, 0 otherwise
  • bit 1 : Write flash : 1 if the robot should write dance data stored in its RAM into its flash
  • bit 2 : Store moves : 1 if the packet contains data about the moves that should be stored in RAM
  • bit 3 : Store colors : 1 if the packet contains data about the colors that should be stored in RAM
  • bit 4 : Clear : clear any data stored in RAM

Note : The packet may also contain extra data when download the dance to the robots, depending on the flags

Response :

0x42 0 RX timestamp (2 LSbytes) Status flags

RX timestamp : required for ranging as message are sent ignoring the 9LSbits of the target TX time (see Decawave user manual)
Status flags :

  • bits 0-1 : battery charge flag : 00: VERYLOW, 01: LOW, 10: OK, 11: HIGH
  • bit 2 : Write OK : 1 if the last write in flash has been successfully done

Slave beacon send :

0x42 RB ID

RB ID : robot short ID

Response :

| 0x42 | 0 | RX timestamp (2 LSbytes) | | ----- | ------ | ------ | --- |

RX timestamp : required for ranging as messages are sent ignoring the 9LSbits of the target TX time (see Decawave user manual)

New robot

Master beacon sends a message at the end of each time frame, for new robots to register and join the system. To join, a robot replies to the message with its STM32 UID, and check in the next SOF if it has actually been added to the connected robot list.

0x2A 0xFF available ID

available ID : the short ID that the robot will use if it replies successfully to this message, or 0 if no ID is available.

Response :

| 0x2A | 0 | Decawave part ID (3 bytes) | | ----- | ------ | ------ | --- |

Decawave part ID : Decawave module part ID register. This isn't used in the radio protocol but allows to retrieve ranging calibration data of the robot.

Clone this wiki locally