Obtaining Bat Events and Data

Introduction

The Bat system has been modified from its original AT&T form to output detailed raw data over sockets. SPIRIT provides access to the basic data, so why would you ever want to just get the raw data?

Raw Data

The sockets interface provides access not only to the basic position result (x,y,z,error estimates) but to the raw lateration data - the pulse distance measurements and measured intensities.

Build Environment

You may not want to learn or use the SPIRIT build environment

Latency

You may want to reduce any latency in event delivery imposed by the layers of SPIRIT which any position event must traverse.

Where is the Data Then?

The data used to be unicast, but this is now deprecated. If you want to use this, the old protocol is below and should work for the moment (but I'm getting rid of it asap).

The new protocol uses multicast:

Multicast Group: 225.0.1.0
Port: 10256

Connect to this group and you will receive variable-sized messages. There are two events: Bat positions and Bat button presses. They can be distinguished using the 16 byte header of the message you receive:

Bytes   C++ Type        Description
1       unsigned char   Message Version (1 at present)
2	short	        Event id
1       unsigned char   Sequence Number for Bat messages
4	long            UNIX time (seconds)
4       long            UNIX time (microseconds)
4       n/a             Reserved

A bat position has the event ID set to 1 and has the following message structure:

Bytes   C++ Type        Description
16      n/a             Header (see above)
6	unsigned char	The Bat ID as six unsigned chars
1       unsigned char   The GCG id
5	unsigned char	The GCG timestamp as 5 unsigned chars
4       float32         x value of result
4       float32         y value of result
4       float32         z value of result
4	float32         Horizontal plane angle (degrees)
4	float32         Vertical plane angle (degrees)
4	float32         Standard deviation of measurement
4	float32         GDOP value
4	float32	        Temperature of room (C)
1	unsigned char	Number of accepted pulses (na)
1	unsigned char	Number of rejected pulses (nr)
1	unsigned char	Number of secondary pulses (ns)
na*20   See below       Data for accepted pulse measurements
nr*20   See below       Data for rejected pulse measurements
ns*20   See below       Data for secondary pulse measurements
Varies  char array      Textual descriptor of the relevant MM ('\0' terminated)

The 20-byte data structure for each pulse is as follows:

Bytes	C++ Type    Description
4	float32	    The x co-ordinate of the receiver
4	float32	    The y co-ordinate of the receiver
4	float32	    The z co-ordinate of the receiver
4	float32	    The pulse ToF as a distance (m)
4	float32	    Intensity of received pulse (arbitrary)

A bat button press has the event ID set to 2 and has the following message structure:

Bytes   C++ Type        Description
16      n/a             Header (see above)
6	unsigned char	The Bat ID as six unsigned chars
1       unsigned char   The GCG id
5	unsigned char	The GCG timestamp as 5 unsigned chars
1       unsigned char   The button pressed (0=Top, 1=Bottom)

Example

See the BatFeed program. The code for this program can be found in /project/gsp/bat/versions/v3.1/core/src/clients/BatListen/OMMulticastListener.cc