= CPlane Protocol =

This is the structure of the compressed CPlane as transmitted from the robot to CPlaneDisplay. The CPlane data structure actually contains more than just the CPlane, and includes the OPlane (recognized objects), sensor data and sanity check data.

Version FIXME

N.B. Ints as recieved by the host are little-endian (least significant byte first) unless otherwise noted. See {{{robot/share/VisionDef.h}}} for definitions of most of the constants mentioned below.

The transmitted data structure is as follows:

== CPlane ==
The CPlane is of variable size and begins with an integer size specifiying the number of bytes in the CPlane data (excluding the sensor, sanity, OPlane data etc). This is followed by size bytes representing the pixels in the CPlane in a run-length encoding. Each pixel run is represented by a one byte run-length followed by a one byte colour identifier. The colours are currently identified as follows (but this is likely to change):

{{{
 static const QColor colorTable[] = {
     colorOrange,
     colorBlue,
     colorGreen,
     colorYellow,
     colorPink,
     colorBlue,
     colorRed,
     colorGreen,
     colorGrey,
     colorWhite,
     colorBlack,
     colorBlack
 };
}}}

In addition, the "maybe bit" may be (!) set on a colour. The maybe bit is 0x10 (dec 16).

== Sensor data ==
The sensor data is of a fixed size (SENSOR_SIZE bytes) and is transmitted as an array of longs. These seem to be ignored in both the Java and C++ CPlaneDisplay's.

== Sanity data ==
The sanity data is of a fixed size (SANITY_SIZE bytes) and transmitted as an array of ints. These seem to be ignored in both the Java and C++ CPlaneDisplay's.

== OPlane ==
The OPlane is actually an array of planes, where each plane is an array of NUM_INT_COORDS ints representing FIXME. The OPlane structure also contains robot data, an array of NUM_ROBOT_DATA ints.

The structure begins with an integer size specifying the number of objects (planes), then NUM_ROBOT_DATA (2) doubles for pan and tilt. This is followed by that number of objects, each of size ONE_OBJ_SIZE. Each object consists of the following integer properties: an object number (which object it is), an x position in the image, a y position in the image, a width in the image, a height in the image, and a distance from the local origin.

If delay testing is on, an int counter (big-endian) follows the OPlane data.

Currently, the object identifiers are as follows (from {{{RoboCommander/RoboConstant.java}}}):
{{{
    public static final int BALL                = 0;
    public static final int BLUE_GOAL           = 1;
    public static final int YELLOW_GOAL         = 2;
    public static final int BLUE_LEFT_BEACON    = 3;
    public static final int BLUE_RIGHT_BEACON   = 4;
    public static final int GREEN_LEFT_BEACON   = 5;
    public static final int GREEN_RIGHT_BEACON  = 6;
    public static final int YELLOW_LEFT_BEACON  = 7;
    public static final int YELLOW_RIGHT_BEACON = 8;
    public static final int RED_DOG             = 9;
    public static final int RED_DOG2            = 10;
    public static final int RED_DOG3            = 11;
    public static final int RED_DOG4            = 12;
    public static final int BLUE_DOG            = 13;
    public static final int BLUE_DOG2           = 14;
    public static final int BLUE_DOG3           = 15;
    public static final int BLUE_DOG4           = 16;
}}}
These are also likely to change.