Recent Changes - Search:




Mega Plan



The flockbot revision brings with it two new systems for software development. For our new revision, we opted to use currently popular hobbyist technology, namely the Raspberry Pi and Arduino Uno, for these robots. With these controllers, we have a world of beautiful, simple, and efficient languages in which the software may be developed. So, naturally, we stuck with C and C++.

C and C++/Processing The Raspberry Pi controller was written almost exclusively in C, using a native gcc compiler on the custom Raspbian linux operating system. The advantage of this operating system being a derivation of a very common linux distribution (Debian/Ubuntu) is that native support is bountiful. All of the code for the flockbot, to include the code for the Arduino Uno microcontroller and the optional WSN motes are compiled directly on each robot and is immediately available for operation. Likewise, the Raspberry Pi brings with it a standard platform with thread, sockets, and serial communications support.

The Arduino Uno is typically built using a provided IDE and the Processing language. Instead of using this approach, which would have resulted in having to connect the Uno to an external laptop for every build, we opted to switch to C++ for out programming and do the compiling and flashing of the Uno directly from the Raspberry Pi. This increased driver writing productivity dramatically when it was initially implemented. While the code is written and compiled in C++, the style is still very heavily C, with some of the Arduino libraries making use of the nicer C++ constructs.

Code Overview

Raspberry Pi

On the Raspberry Pi, we have the Arduino Daemon, which is the main controller process used to access the robot's functions. This process uses serial communications to send instructions to the Arduino, and to receive sensor values and updates from the Arduino.

Serial Listener Within the Arduino Daemon, a dedicated serial listener thread is created to handle all incoming traffic from the Uno. At 30ms intervals from this point forth, sensor data arrives from the Uno, carrying with it information from the five IR sensors, two bump sensors, and information about the state of the wheels. This data is buffered into a configurable-sized array, enabling behavior programmers to access both the latest sensor information, as well as aggregating older sensor information.

TCP/IP Socket Listener The Arduino Daemon also opens a TCP/IP socket, on its listener thread, for remote client connections. This socket is able to accept any reasonable number of clients (where reasonable is defined in the settings) and allow them to perform all of the interactions with the robot remotely. As the daemon will begin automatically on bootup, this is the primary venue for command and control of the Flockbots.

Flockbot API C Library Local programs may use the provided flockbot_api.o library for linking into their own executable, to allow a convenient means of interfacing with the daemon. The API provides the primitives necessary to communicate with the daemon as well as the necessary functions to provide high level control of the robots. These functions allow access to the Integrator, the Drive system, all Sensors, and allow for both blocking and non-blocking calls.

OpenCV Local programs may also use the OpenCV libraries to link into their executables. An additional step that is necessary is to link with the raspicam_cv library as well. While OpenCV is usable in full, the direct camera interface is all handled through the raspicam library. This library allows the camera to open and release mid-execution, as well as supporting settable OpenCV standard parameters on the device, such as CV_CAP_PROP_FRAME_WIDTH.

Barcodes Local programs may also use the Barcode library for detecting and decoding barcodes found in the environment. Unlike other vision based programs, this uses custom code that will preclude the use of OpenCV. This library takes direct control of the camera internally. Explore the sample barcode project for more information.

Behaviors Sample programs demonstrating the C API calls, OpenCV calls, and Barcode Library calls are present in the flockbot/behaviors directory.

Edit - History - Print - Recent Changes - Search
Page last modified on August 27, 2015, at 07:53 PM