There are three main components for which software was written for on the BB8: a Raspberry Pi Zero W, an Arduino Uno, and a Node MCU 0.9 wireless module. Each device is responsible for very different tasks. The Arduino Uno is responsible for driving the motors while keeping BB8 stable, using input from the Node MCU. The Node MCU is responsible for gathering input from the Raspberry Pi, converting that information into a type that can be read by the Arduino, and sending the Arduino the converted data. Finally, the Raspberry Pi is responsible for substantially higher level control tasks. Depending on what mode BB8 is configured in, the head can decide to turn and watch people as they move by the BB8, follow people who look at the BB8's camera, or receive remote commands from a remote host.
Information between the Arduino and Node MCU is sent over a wire, using Arduino's built in functionality to receive information from another device through an input pin. As a single byte of information is sent at a time, characters are concatenated until a full message is formed. Messages assume the format "LeftMotorSpeed, RightMotorSpeed", and are separated by new line characters. After storing this message to a temporary variable, the Arduino parses the message to store each motor speed to their respective integer variables. Using the Adafruit motorshield library, these motor speeds are directly sent to the motors. The software on the Arduino does not update the motor speeds until the stop command of "0,0" is sent from the Node MCU to the Arduino, or the Arduino is turned off. For safety, any message not in the format expected by the Arduino will be converted to the stop command.
Here is the link to our GitHub Repo: https://github.com/gracemontagnino/BBGreat