Hardware | Software | Mathematics | Contributors
OBB is control science for everyone.
- A low-cost, open-source hardware and software platform.
- For research, teaching, and self-guided instruction in data-driven control.
- An open-loop neutrally stable dynamical system that is nontrivial to control.
Existing educational control systems are often
- Prohibitively expensive (cost thousands of USD)
- Use proprietary hardware and software
- Development knowledge is not transferrable to other systems.
OBB offers a viable alternative
- OBB is cheap enough for most individuals and labs.
- OBB uses open-source and widely available hardware and software.
OBB encourages users to get their hands dirty!
- Redesign custom 3D parts
- Create new & improved controllers
- Try out reinforcement learning algorithms
See parts_list.xlsx for a list of parts to purchase and to kit out a single OBB unit.
CAD models for 3D printing are provided in the cad directory.
- STEP files (portable format), suitable for 3D printing.
- PTC Creo files (native format), suitable for viewing and redesign in PTC Creo.
- The full assembly
ballbeam.asmmay be opened in Creo. Working kinematic joints are provided so the movement can be interacted with via dragging.
- The full assembly
See the Assembly and Setup Guide for instructions on how to assemble an OBB unit.
OBB was developed and tested on 64-bit Windows 10 using Anaconda environments, but should work on other platforms as well e.g. macOS & Linux.
OBB ships with the following software features.
- Proportional-integral-derivative (PID)
- Linear quadratic regulator (LQR) with integral control
- Model predictive control (MPC) with integral control
- Anti-windup for integral control
- Exponential smoothing
- Linear quadratic state estimation (Kalman filter)
- Ball removal detection
OBB ships with environments compatible with OpenAI Gym (requires Gym installation)
- Continuous action-space environment
BallBeamContinuousEnv - Discrete action-space environment
BallBeamDiscreteEnv - Option to use simulator (with fast visualizer) or the actual physical hardware
Try out reinforcement learning algorithms e.g. those from OpenAI Spinning Up in simulation or on a real-world physical system!
- Install the Arduino IDE
- Install the following libraries from the
Manage Libraries...dialog in the Arduino IDE- Servo (may be installed already with the Arduino IDE)
- Polulu VL53L0X
- Search for
VL53L0X - Be sure to use the Polulu library and NOT the Adafruit Library (regardless of whether the Polulu or the Adafruit physical hardware is used)
- Search for
- Adafruit_LSM6DS
- Search for
Adafruit LSM6DS - Select
Install Allif prompted
- Search for
- BasicLinearAlgebra
- Search for
BasicLinearAlgebra
- Search for
It is recommended to use virtualenv to create a separate environment to install OBB and its dependencies.
- Open a terminal / command prompt
- Create a new environment
- Activate the desired environment
- Install the dependency packages
pip install -r requirements.txt
- Navigate to the root level directory of this package.
- Run the command
pip install -e .- NOTE: The
-eoption is very important! This is what tells pip to install in "editable mode", so that changes you make to scripts actually take effect when you run them! Read the official pip docs for more details.
- NOTE: The
Run
pre-commit run --all-filesto run all pre-commit hooks, including style formatting and unit tests.
Update requirements.in with new direct dependencies.
Then run
pip-compile requirements.into update the requirements.txt file with all indirect and transitive dependencies.
Then run
pip install -r requirements.txtto update your virtual environment with the packages.
If necessary, also add the type hints package to the additional_dependencies for mypy in .pre-commit-config.yaml so that mypy knows about the type hints (often required for less popular packages).
-
Baud rate
- A baud rate of 115200 is used throughout the project.
- When using
Tools->Serial MonitororSerial Plottermake sure to use 115200 baud rate.
-
COM port
- Determine the COM port that your Arduino is attached to
- e.g. use Device Manager in Windows
- In
hardware_configurator.pychangePORTtoCOM#as appropriate.
- Determine the COM port that your Arduino is attached to
-
Servo and sensor calibration coefficients
- Run
servo_calibrator.pyandsensor_calibrator.py - Copy the printed coefficients into
constants.cpp
- Run
There are two APIs that offer comparable functionality:
In the Arduino API, all processing (e.g. control and state estimation) occurs locally on the Arduino board. No serial connection to a host computer is strictly required during system operation; a serial connection is required only for uploading programs and for monitoring system operation through the Serial Monitor and Serial Plotter.
The benefit of the Arduino API is that no host computer is required to run the system. In this configuration, only power to the Arduino (e.g. over the USB cable) is necessary, so the system is more portable and be run from any location with power outlets. MPC control is currently not available in the Arduino API.
- Upload
interface.inoto the Arduino. - Start the
Tools->Serial Plotterto monitor the various signals in the system.
In the Python API, the majority of processing occurs on the host computer and the Arduino acts as a simple client, sending raw measurement information and receiving actuator commands. A stable serial connection is required throughout system operation to maintain stability.
The benefit of the Python API is that the full computing power of the host computer can be used to control the system. In particular, the more computationally intensive MPC strategy can be used.
In order to use the MPC controller, the solver code must be generated with
python configurators/controller/mpc/design.py- Upload
client.inoto the Arduino.
- Adjust all the configurable parameters in the
*_configurator.pyfiles as needed.- Set the
system_typevariable to'Simulator'ininterface_configurator.pyfirst to ensure proper functioning in the simulator before attempting to run on the physical hardware.
- Set the
- Run
python configurators.pyto run all configurators. - Run
python main.pyto start the interface (without running configurators).- Alternatively, run
python main.py --configureto run the configurators as well as start the interface.
- Alternatively, run
An technical write-up describing the mathematics behind the software is available. Note that this document is still in development.
- Original author: Benjamin Gravell
- Testing and improvements: Sleiman Safaoui and Karthik Ganapathy


