Download ERRATIC Mobile Robot User Manual
Transcript
ERA ROBOT USER’S MANUAL
2009 VIDERE DESIGN
When integers are sent as arguments, they are always inserted into the byte
stream as 2 bytes. The first byte is the low byte, the second byte is the high
byte of the integer.
Appendix E
Erratic controller packet
communications
This Appendix documents the format of the Erratic controller
communication protocol. Further details can be found in the source code
for the Erratic driver, in player/server/drivers/mixed/erratic.
E.3 Packet protocol
The protocol is based on command packets that are sent to the controller,
and information packets that are received by the host PC. All packets have
the following format.
E.1 Communication channel
SYNC0
SYNC1
count
count-2 bytes of data
checksum (2 bytes)
Communication is through a USB 1.1 connection. Host PC drivers convert
the USB connection into a serial connection. The name of the connection
on Linux systems is
/dev/erratic
This device name is a symlink to /dev/ttyUSBn. The symlink is
performed automatically at boot-up by rules in /etc/udev/rules.d/60symlinks.rules.
E.4 Checksum calculation
The checksum is calculated on the full packet, starting after the SYNC
bytes, and includes the byte count. The checksum algorithm is given here
in C code. The argument “n” is the number of bytes, and “b” is the vector
of bytes in the packet.
On MS Windows systems, the connection is
comX
where X is the next highest serial port number.
int calc_chksum(int16_t n, unsigned char *b) {
uint16_t c = 0;
while (n > 1) {
c += (*(b)<<8) | *(b+1);
n -= 2;
b += 2;
}
if (n > 0) c = c ^ (uint16_t)*b;
return c;
}
The device communicates at a native speed of 38.4 Kbaud, 8 bits per byte,
no parity, 1 stop bit.
E.2 Special byte definitions
Some bytes have a special meaning at certain points within a packet (see
subsequent sections). These are given symbolic names as follows.
SYNC0
SYNC1
END
ARG
NARG
SARG
0xFA
0xFB
0xFE
0x3B
0x1B
0x2B
E.5 Command packets
A command packet consists of a command byte, followed by an argument.
The command argument can be either NULL, a 16-bit positive integer, a
34