← All projects

TNTN Robotics · 2025

Optical Localization Sensor

I built a compact optical tracking sensor for TNTN Robotics, from its six-layer PCB and firmware to the link that sent position data to the robot.

STM32 · FreeRTOS · PCB design · RS-485

Render of the 25 mm optical localization board

Why we needed it

As a part of TNTN Robotics, we wanted a much more compact way to estimate how the robot was moving. Alternative solutions were either too bulky or too expensive. We designed and built OTOS, an optical tracking odometry sensor, which combined an optical flow sensor similar to that in a mouse and an IMU to calculate the robot’s pose. My focus was making that estimate accurate and reliable enough for a competition robot.

Design

In the end, the finished board was about one square inch. To enable this, we chose a six-layer PCB with a small STM32 microcontroller to handle the processing. We also used double-sided assembly, fitting the optical flow sensor and some supporting passives on the bottom side of the board, which I assembled manually.

One of the main priorities in the design was robustness and resilience. We had had issues with ESD damage in the past, so we used an ESD-resistant RS-485 transceiver and a TVS diode to protect the board from static discharge. We also decided to have only one port leaving the board to reduce the chance of damage.

Because of these choices, I also wrote a small custom bootloader to enable flashing the firmware over the single half-duplex RS-485 port. This let us update the firmware without disassembling the robot or using an external programmer.

Sensor fusion

I wrote the FreeRTOS firmware that used interrupt-based communication to get synchronized data from the optical flow sensor and IMU, then implemented a Kalman filter to fuse the data and estimate the final robot pose.

Communication

For communication, we wanted robustness and simplicity. We used a half-duplex RS-485 link with a custom communication protocol we developed. The protocol was simple, with a single command byte, COBS encoding for delimiting packets, and a CRC-16 checksum for error detection. This made sure that very few packets could be lost, and corrupt data could always be detected.

Results

The finished sensor provided millimetre-accurate localization for our robot. It contributed to our team’s VEX U World Championship, World Skills Championship, and World Excellence Award wins—the first time a team had won all three top awards at the VEX U World Championship. I later reused OTOS on our ENPH 253 robot, helping us win that competition as well.

TNTN Robotics at the 2025 VEX U World Championship
TNTN Robotics at the 2025 VEX U World Championship.

← Back to projects