Software: Interfacing with Sensors
As described in the design overview, the sensor component objects each handle their own I/O.
- DVL: The DVL component's initialization routine reads settings such as the DVL's offset in the robot, angular offset from forward, heading bias, and input device name from the user configuration. It opens the input device (which may be a regular file or a serial device) and, if the device is a serial port, establishes communication and sends the "start pinging" command. It then begins its own thread of execution, which repeatedly reads a binary sample from the input source, processes the data according to the configuration settings, and updates the robot's shared configuration state. The DVL component uses the Depth component to read the Z coordinate of position and velocity instead of relying on the data coming from the DVL itself. If the configuration specifies an output file, all binary data is also written to this file. This allows runs to be recorded to a file, which can later be specified as the input source to allow the robot to exactly replay movements. The system receives approximately 8 samples a second from the DVL.
- Altimeter: The altimeter behaves much like the DVL, first reading settings such as device name and sample-averaging window size, then beginning its own thread. The altimeter thread simply reads altimeter output continuously, and updates the altitude and altitude velocity of the shared robot state.
- Cameras: Each of the two cameras has its own component object. The component first checks the configuration for any custom picture settings (size, brightness, saturation, etc.). Once the specified camera device is opened and initialized throug the Video4Linux interface, the component starts a separate thread of execution. Each of the camera threads sleeps by default. When a behavior requests that the camera be started, the thread wakes up and begins reading frames from the device. When each frame is read, the camera component passes it to a listener object for processing. Because the listener object is called from the camera's thread, vision processing does not interfere with more frequent but less computationally intensive processing. When a behavior is done with camera data, the camera thread goes back to sleep.
- Acoustics: The acoustics component thread polls a digital input pin on the DAC for a HI signal which notifies the computer that the acoustics card has processed a ping. When this signal appears, the component reads the 14 bit counter value through the DAC's digital I/O interface and generates a notification event for the active behavior informing it of the direction of the detected ping.