Library Overview
Understand the architecture and core concepts behind the UNI library.
Architecture
The UNI ecosystem is designed for the UniBase robotic platform. It consists of two main components:
1. UniBase (ESP32)
The core library runs on the ESP32 microcontroller onboard the robot. It handles:
- Motor PID Control: Ensures precise speed and distance using encoders.
- Odometry: Calculates position (X, Y) relative to the start point.
- Hardware Abstraction: Manages the OLED display, the status LED and the battery voltage sensor.
2. UniBaseControl (Arduino Nano / Remote)
An optional library for controlling the robot from a secondary processor via UART.
- Sends high-level commands (e.g., "move 100mm") to the ESP32.
- Receives sensor data (odometry, battery) from the ESP32.
- Ideal for educational kits where students program an Arduino Nano plugged into the robot.
Core Concepts
Blocking and async commands
The ordinary movement commands — moveDist(), rotate(), moveTo() —
are blocking: the program waits until the robot has finished. Each has a twin ending in
Async that only starts the movement and returns at once.
Only one movement command runs at a time: a new one cancels the current one. A full walkthrough is in Lesson 4.
Background work
The library looks after odometry, the motor controllers and the screen by itself — in background
tasks on the other core of the ESP32: the motor controllers run 200 times a second (1000 on the last
millimetres before a target), the screen 10 times a second. That is why the coordinates
keep updating even while your program sits in delay().
Coordinate System
The robot uses a standard 2D cartesian coordinate system:
- X Axis: Forward direction from the starting point.
- Y Axis: To the right of the starting direction.
- Angle (Theta): 0 degrees is facing forward. Positive angles turn clockwise (right), negative angles turn counter-clockwise (left).
Robot Name
You can assign a custom name to your robot during initialization. This name is displayed on the OLED screen startup.
robot.begin("WALL-E");