Here are the structs and ports we are using for device communication (the backend interface) for IGVC2007.

Find out more about the Backend_Interface

Notice that each struct has 3 common members, header, timestamp, and checksum.

  • Header is defined in the enum below
  • timestamp is seconds since 1/1/1970 with as much precision as possible (usually milliseconds). It is necessary to use a double (not a float) because floats only give 23 bits of precision and to have millisecond accuracy you need 24 bits. Doubles give 52.

NOTE: Don't reinvent the wheel! We have a function that does this (on win32 and linux) in svn (rastime.h and rastime.cpp)

  • checksum will be a one byte summation of each byte in the packet including the header but not the checksum bytes, zero-extended to two bytes. (We use a 2 byte checksum to maintain 32 bit alignment in the struct). C code for the checksum is in the file below

Command Packet

Used to pass messages from the frontend to the body.

C++ Struct

    typedef struct{
        unsigned short header;
        double timestamp;
        char command[16];
        float val;
        unsigned short checksum;
        } PKT_COMMAND_TYPE;

Python Class

class BaseCommand(Device):
    def __init__(self):
        Device.__init__(self, "CO", "16sf")
        self.command = ""
        self.val = 0.0

GPS Packet

Contains GPS latitude and longitude.

    typedef struct{
        unsigned short header;
        double timestamp;
        float lat;
        float lon;
        unsigned short checksum;
        } PKT_COMMAND_TYPE;
class BaseGps(Device):
    def __init__(self, gpsConfig, poseConfig):
        Device.__init__(self, "GP", "2f")
        self.x = poseConfig.x               # Initial x position [m]
        self.y = poseConfig.y               # Initial y position [m]

Motors: char[2] header = "MO" double timestamp float v float w }}}

Imu Packet:
char[2] header = "IM"
double timestamp
float heading
Pose2D:
char[2] header = "2D"
double timestamp
float x
float y
float theta
SonarArray:
char[2] header = "SO"
double timestamp
float[10] ranges