Skip to main content
Version: FILS English

COLOR PARKING CAR

An autonomous four-wheel-drive robot programmed in Rust that parks based on color cues.

info

Author: Elena-Daniela NEGOIȚĂ
GitHub Project Link: https://github.com/UPB-PMRust-Students/fils-project-2026-daniela-negoita

Description

This project consists of an autonomous 4WD robot based on the STM32U545RE-Q microcontroller. The robot's objective is to traverse a path, identify a specific parking bay from three available options based on a color-coded floor marker, and execute a pre-programmed parking maneuver.

Motivation

I chose this project to learn how to build an autonomous robot using Rust and the STM32 microcontroller. It is a great way to practice writing software that interacts directly with the real world. Since the robot doesn't have distance sensors, I have to rely entirely on precise timing and live color detection to make it park correctly. This makes it a fun and challenging way to learn about state machines, motor control, and reading sensor data.

Architecture

The system architecture is built around a central State Machine that coordinates the robot's behavior without relying on an operating system. The main software components are:

  • Main Controller (State Machine): The core logic unit that dictates the current mode of the robot. It shifts between four specific modes: Driving, Checking, Parking, and Finished.
  • Sensor Processing Module: This component manages the I2C protocol communication with the physical RGB sensor. It continuously reads incoming color values, compares them against set limits, and filters out false positives (like shadows).
  • Motor Control Module: This component translates the high-level movement commands from the Main Controller into specific timing and power signals (PWM).

How they connect: The Sensor Processing Module acts as the "eyes," constantly feeding processed environmental data to the Main Controller. The Main Controller evaluates this data based on its current state. When the Sensor Module confirms a target color is found, the Main Controller transitions to the "Parking" state and sends a "script" of timed movement instructions down to the Motor Control Module. The Motor Control Module then executes these specific durations and speeds to physically move the robot.

System Architecture Diagram

Log

Week 5 - 11 May

  • Set up the Rust embedded development environment (probe-rs, embassy) for the STM32 architecture.
  • Initialized the project repository and configured the required build scripts.
  • Designed and programmed the core State Machine architecture in software.
  • Implemented and tested mock transitions for the Driving, Checking, Parking, and Finished modes.

Week 12 - 18 May

  • Assembled the 4WD physical chassis, mounting the motors and wheels.
  • Wired the TB6612FNG motor drivers to the STM32 microcontroller.
  • Configured the basic PWM outputs using the embassy-stm32 HAL to control motor speeds.

Week 19 - 25 May

  • Wired the TCS34725 RGB sensor via I2C and successfully read raw color data.
  • Integrated the live sensor data with the State Machine to successfully trigger the Parking mode.
  • Conducted floor tests to calibrate motor timing and validate the complete parking sequence.

Hardware

The system uses a 4WD chassis driven by independent DC motors, powered by a 3.7V Li-ion battery setup, and utilizes a dedicated RGB sensor for environmental awareness.

Schematics

Bill of Materials

DeviceUsagePrice
STM32 Nucleo-U545RE-QThe Microprocessor~120 RON
DC Gear Motors (Yellow "TT" style, 3V-6V)Propulsion~7.50 RON / pc
Rubber-tired wheelsWheels for TT motor shafts~5 RON / pc
TB6612FNG Dual H-Bridge ModulesMotor Drivers~14 RON / pc
TCS34725 RGB Color SensorColor Sensing~20 RON
Acrylic or Aluminum Base PlatesStructure (Chassis plates)~50 RON
Metal or Plastic "L" bracketsMotor Mounting~10 RON / set
M3 Screws, Nuts, and StandoffsAssembly~20 RON / set
18650 Li-ion Cells (3.7V)Battery~30 RON / pc
Dual 18650 Cell HolderBattery Holder~10 RON
LM2596 DC-DC Buck ConverterPower Control~8 RON
SPST Toggle SwitchSwitching~5 RON
400-Point Solderless BreadboardPrototyping~12 RON
Jumper Wires (M-M, M-F)Wiring~15 RON / set
Double-sided tape / Zip TiesAdhesive~10 RON

Software

LibraryDescriptionUsage
embassy-stm32Core FrameworkSTM32 Hardware Abstraction
embassy-executorAsync FrameworkTask management
embassy-timeTiming LibraryUsed for the precise time-based motor control
tcs34725Sensor DriverUsed to interface with the RGB sensor
embedded-hal / asyncHAL TraitsStandardizing I2C and PWM communication
cortex-m / rtCore ArchitectureLow-level ARM Cortex-M support
defmt / rttLogging FrameworkFormatting and sending logs/telemetry
panic-probePanic HandlerSystem debugging
  1. Embassy Framework Documentation - Official docs for the async Rust framework powering the robot.
  2. TCS34725 Sensor Datasheet - Essential for understanding the I2C registers and color integration timing.
  3. STM32 Nucleo-U545RE-Q Product Page - Crucial for downloading the board's user manual, schematics, and pinout diagrams.
  4. The Embedded Rust Book - The definitive guide for understanding embedded Rust concepts, memory safety, and tooling.
  5. Embassy STM32 GitHub Examples - Reference code showing exactly how to configure PWM, I2C, and timers on the STM32U5 series using Embassy.
  6. TB6612FNG Motor Driver Hookup Guide - A great visual guide explaining the logic pins (AIN1, AIN2, PWMA) needed to make the motors go forward, reverse, and stop.
  7. defmt Logging Framework Book - Documentation for setting up extremely fast, low-resource logging over the debugger (since you are using defmt-rtt).