bjoerngiesler / BBDroids

Code for the Bavarian R2 Builders' Droid Control System, consisting of dual miniature multi-axis remote controls and a droid control board, currently for BB-8. Please refer to the Wiki for reference.
Apache License 2.0
6 stars 3 forks source link
arduino bb8 bb8-robot droid starwars wifi xbee

BBDroids

Code for BBDroids, the Bavarian Droid Builders' Droid Control System, currently for BB-8 and D-O. You can call this an "operating system" if you like. Please refer to the Wiki for reference and documentation.

Hardware concept, layout and realization by Felix Beyer, software concept and realization by Björn Giesler.

Please note that this is work in progress.

Recent work in Q1/2024 has been prioritizing D-O, and the results look very promising, as the videos in this playlist show. https://www.youtube.com/playlist?list=PLQXuN0SWfVLk_Lird5GfVPj6_yB7YLnPW

Work on BB-8 is on hold until D-O software is finished, at which point the improvements will be ported over. This is expected to happen still in April 2024.

If you want to base your own build off of BBDroids, I would suggest to hold off until mid May 2024 or so, when work on D-O and BB-8 are (mostly) finished and some cleanup work has been done.

Watch this space for official releases!

About

The project started with the plan to build a RC BB-8 replica, and has since evolved to a general-purpose remote control, a slightly less general-purpose droid control board, and a very much general-purpose software system and architecture. It can be used to realize and control almost arbitrary droids, e.g. BB-8, R2-D2, B2EMO, and many others, although this repository currently contains complete applications for only D-O and BB-8.

From an end-user perspective, the most important aspect are the two remotes used to control the droid, one for the right and one for the left hand. Both have a 2-axis clickable joystick, a 6-axis gyroscope and accelerometer (of which currently only the gyroscope is used), four chordable buttons for index finger, ring finger and pinky, and three additional buttons. The left remote contains a display displaying parameters, droid status, and other telemetry information, and has an encoder to navigate the display. The right remote has two potentiometers that can be operated with the thumb.

Electronically, the system is built on the basis of Arduinos. Currently, it is using Arduino RP2040 nano connect boards in the remotes and a MKR Wifi 1010 in the droid body. Communication between remotes and droid is done via XBee or alternatively via UDP (although this is not recommended for conventions or similar due to the limited range of the small integrated antennas).

All three components (two remotes and mainboard) offer command line consoles for deep introspection into system health, setting parameters, stopping and restarting subsystems, etc. The consoles can be accessed via serial port (directly accessible on the remotes) or alternatively via a TCP connection. For this purpose all three components can join infrastructure networks or (default) open their own individual access points, which are identifiable via MAC addresses so they will not clash even in crowded convention situations.

Hardware

Remotes

Both left and right remote use an Arduino RP2040 nano connect as their computing platforms, and require the Arduino-pico core to compile. We are in the process of converting to ESP32 to remove this requirement. Connected peripherals common to both remotes are:

Left

The left remote additionally sports a small graphic display and a digital encoder.

Right

The right remote additionally sports two analog potentiometers.

Droid Control Board

The droid control bord uses an Arduino MKR Wifi 1010 plus a Dynamixel shield for servo control. Connected peripherals are:

The BB8 Arduino sketch expects the following external hardware:

The D-O Arduino sketch expects the following external hardware:

Software

LibBB

This library (LibBB - Bavarian Builders Lib, not LibBB8) encapsulates some aspects of a middleware supporting very different droids. It forms the base of the BB8 and D-O code included in the repository, and can be used for your droid project as well. It provides the following concepts:

Example

Here is a simple example on how to construct a droid sketch in Arduino using LibBB:

#include <LibBB.h>
using namespace bb;

static const String WIFI_SSID = "MySSID";
static const String WIFI_WPA_KEY = "MyWifiKey";
static const bool WIFI_AP_MODE = true;

class MyDroidClass: public Subsystem, public PacketReceiver {
public:
    static MyDroidClass droid;

    virtual Result initialize() { 
        // Add your initialization code here
        return RES_OK;
    }
    virtual Result step() {
        // Add your droid control code here
        return RES_OK;
    }
};

void initializeSubsystems() {
  Runloop::runloop.initialize();
  Console::console.initialize();
  WifiServer::server.initialize(WIFI_SSID, WIFI_WPA_KEY, WIFI_AP_MODE);
  MyDroid::droid.initialize();
}

void startSubsystems() {
  WifiServer::server.start();
  Console::console.start();
  MyDroid::droid.start();
  Runloop::runloop.start(); // never returns; start last!
}

void setup() {
  Serial.begin(2000000);
  Serial.println();
  Serial.println("My Droid starting up");

  initializeSubsystems();
  startSubsystems();
}

void loop() {}