← All projects

Independent project · In progress

Autonomous Robotic Fleet

A small autonomous car built from scratch (electronics, PCB, chassis, and firmware), the first unit of a fleet I'm building toward leader–follower behavior learned with multi-agent reinforcement learning.

Reactive obstacle avoidance: the car turns away as a hand approaches its ultrasonic sensors.
Assembled car: white 3D-printed chassis holding the custom black PCB, Arduino Nano, IMU, three ultrasonic sensors, servo wheels and a 9 V battery
The assembled car: custom PCB, Arduino Nano, MPU-6050 IMU, three HC-SR04 sensors, and a 9 V battery bay.

From breadboard to robot

Breadboard prototype with an Arduino Uno, a MAX78000 board, an ESP32, three ultrasonic sensors and two servo wheels
Breadboard prototype. Wiring the sensors, servos, Arduino, and MAX78000 together and testing each piece with a voltmeter and mock code.
Fusion 360 assembly of the chassis with the PCB, three ultrasonic sensors and a 9 V battery placed inside
CAD assembly. Designing the chassis in Fusion 360 around the exact board, sensor, and battery dimensions.
KiCad layout of the two-layer PCB with Arduino Nano footprint, GY-521 IMU, sensor and servo headers
PCB layout. A two-layer KiCad board that replaces the breadboard wiring: Nano, IMU, three sensor headers, two servo headers, and a ground pour.

The result is the car at the top of the page: printed, populated, and driving, after several rounds of 3D prints until everything fit.

How it works

Renders of the 3D-printed caster, camera mount, and wheel
Other 3D-printed parts (rendered from the STL files).

Code

Obstacle avoidance with three ultrasonic sensors gyro_practice.ino
// Three HC-SR04 sonars: front (N), left (W), right (E); max range 50 cm
static NewPing sonar[SONAR_NUM] = {
  NewPing(TRIGGER_PIN_N, ECHO_PIN_N, MAX_DISTANCE),
  NewPing(TRIGGER_PIN_W, ECHO_PIN_W, MAX_DISTANCE),
  NewPing(TRIGGER_PIN_E, ECHO_PIN_E, MAX_DISTANCE)
};

int sonar_N = sonar[0].ping_cm();
int sonar_W = sonar[1].ping_cm();
int sonar_E = sonar[2].ping_cm();

// React to anything closer than 20 cm (0 means no echo)
if (sonar_N < 20 && sonar_N > 0) {
  rightWheel.write(0);
  leftWheel.write(180);
}
else if (sonar_W < 20 && sonar_W > 0) {
  leftWheel.write(180);
  rightWheel.write(90);
}
else if (sonar_E < 20 && sonar_E > 0) {
  leftWheel.write(90);
  rightWheel.write(0);
}
else {
  rightWheel.write(90);  // 90 = stop for continuous-rotation servos
  leftWheel.write(90);
}
Heading from the MPU-6050 gyro gyro_practice.ino
// Read the three gyro axes over I2C (6 bytes starting at GYRO_XOUT_H)
Wire.beginTransmission(MPU);
Wire.write(0x43);
Wire.endTransmission(false);
Wire.requestFrom(MPU, 6, true);
GyroX = (Wire.read() << 8 | Wire.read()) / 131.0;  // ±250 °/s range → °/s
GyroY = (Wire.read() << 8 | Wire.read()) / 131.0;
GyroZ = (Wire.read() << 8 | Wire.read()) / 131.0;

// Correct with calibrated bias, then integrate the z-rate into yaw
GyroZ = GyroZ + 1.51;
yaw = yaw + GyroZ * elapsedTime;
MAX78000 → Arduino commands over UART MAX_practice/src/main.c
MXC_UART_Init(MXC_UART2, 115200, MXC_UART_APB_CLK);
MXC_UART_SetDataSize(MXC_UART2, 8);
MXC_UART_SetParity(MXC_UART2, MXC_UART_PARITY_DISABLE);
MXC_UART_SetStopBits(MXC_UART2, MXC_UART_STOP_1);

while (1) {
    if (val) {
        LED_On(LED);
        const char* msg = "1\n";               // newline-terminated command
        len = strlen(msg);
        MXC_UART_Write(MXC_UART2, (uint8_t*)msg, &len);
    }
    else {
        LED_Off(LED);
        const char* msg = "0\n";
        len = strlen(msg);
        MXC_UART_Write(MXC_UART2, (uint8_t*)msg, &len);
    }
    val = !val;
    MXC_Delay(1000000);                        // ~1 second delay
}

← Back to all projects