API Reference
Complete reference for all public functions in the Autobot Library.
Arduino API
AutOBot.begin()
Initializes the robot with a specific drive type and motor configuration.
#include "AutOBot.h"
AutOBot myBot;
myBot.begin(type, deviation);
Parameters
| Parameter | Type | Description |
|---|---|---|
type | DriveType | The drive configuration. One of: DRIVE_DIFFERENTIAL, DRIVE_OMNI_3W, DRIVE_MECANUM |
deviation | int | Correction for straight-line drift. Range: -100 to 100 |
Motor Pin Arrays by Drive Type
| Drive Type | Pin Array Format |
|---|---|
| Differential (2W) | motor1(a = 18, b = 19), motor2(a = 22, b = 23) |
| Differential (4W) / Mecanum | motor1(a = 18, b = 19), motor2(a = 22, b = 23), motor3(a = 25, b = 26), motor4(a = 27, b = 14) |
| Omni (3W) | motor1(a = 18, b = 19), motor2(a = 22, b = 23), motor3(a = 25, b = 26) |
Deviation Guide
| Value | Effect |
|---|---|
-100 to -1 | Reduces right motor speed — use if the robot drifts left |
0 | No correction |
1 to 100 | Reduces left motor speed — use if the robot drifts right |
robot.drive()
Commands the robot to move in a given direction at a given speed, with optional rotation.
robot.drive(speed, direction, angular);
Parameters
| Parameter | Type | Range | Description |
|---|---|---|---|
speed | int | 0 – 100 | Movement speed (0 = stopped) |
direction | int | 0 – 360 | Heading in degrees. 0 = forward, 180 = backward |
angular | int | -100 – 100 | Rotational speed. -100 = full left, 100 = full right |
Pi Communication Setup
Initialize the UART connection between the ESP32 and Raspberry Pi.
// In setup()
AutOBot myBot;
AutOBotAI myAI;
myBot.begin(type, deviation);
myAI.begin(Serial, myBot);
Serial2.begin(baudRate, SERIAL_8N1, myAI.rx, myAI.tx);
| Parameter | Type | Default | Description |
|---|---|---|---|
baudRate | int | 115200 | Serial baud rate (must match the Pi-side configuration) |
PI_RX_PIN | int | 16 | ESP32 GPIO pin connected to the Pi's TX |
PI_TX_PIN | int | 17 | ESP32 GPIO pin connected to the Pi's RX |
// In loop() — required to process incoming drive commands
AutOBotAI.handle();
AutOBotAI.requestHuman()
Requests the Raspberry Pi to start Human Tracking mode.
AutOBotAI.requestHuman(baseSpeed, turnGain, boxSize, deadzone);
| Parameter | Type | Default | Description |
|---|---|---|---|
baseSpeed | int | 0 | Forward speed while tracking. 0 = rotate only, 100 = always move forward |
turnGain | float | 0.5 | Turning sensitivity. Higher values increase responsiveness (risk of overshoot) |
boxSize | int | 30000 | Target bounding box area. Larger values make the robot approach closer |
deadzone | int | 5000 | Angular deadzone — the robot will not turn if the target is within this threshold |
AutOBotAI.requestLine()
Requests the Raspberry Pi to start Line Tracking mode.
AutOBotAI.requestLine(baseSpeed, turnGain, thresh, color, defS, defD, defA);
| Parameter | Type | Default | Description |
|---|---|---|---|
baseSpeed | int | 0 | Forward speed while tracking. 0 = rotate only |
turnGain | float | 0.5 | Turning sensitivity |
thresh | int | 100 | Threshold for the image mask used in line detection |
color | String | "black" | Color of the line to follow |
defS | int | 0 | Fallback speed when no line is detected |
defD | int | 0 | Fallback direction (degrees) when no line is detected |
defA | int | 0 | Fallback angular speed when no line is detected |
AutOBotAI.requestStop()
Stops all active AI processing on the Raspberry Pi.
AutOBotAI.requestStop();
Raspberry Pi Serial Protocol
The ESP32 communicates with the Raspberry Pi using a simple text-based serial protocol.
Message Format
:M|parameter=value|parameter=value|...
Example:
:M|spd=50|sen=0.8|LN=1
This sets the speed to 50, sensitivity to 0.8, and starts Line Tracking mode.
Parameter Reference
| Parameter | Type | Description |
|---|---|---|
LN | int | Line Tracking mode: 0 = stop, 1 = start |
HM | int | Human Tracking mode: 0 = stop, 1 = start |
spd | int | Movement speed (0–100). Applies to both modes |
sen | float | Turning sensitivity. Applies to both modes |
thr | int | Image threshold (0–100). Line Tracking only |
type | String | Drive type: "diff", "omni", or "mac" |
box | int | Target bounding box size. Human Tracking only |
dzone | int | Angular deadzone. Applies to both modes |
col | String | Line color (e.g., "black"). Line Tracking only |
def | String | Fallback values as speed,direction,angular (e.g., "50,180,0"). Line Tracking only |
Related Links
- AutOBot Library (GitHub)
- AutOBot-Web (GitHub)
- Autobot Raspberry Pi Image (Archive.org)
- 🎬 AutOBot YouTube Channel