MachineTrend

Real-Time Robotics Controller Firmware

Real-Time Robotics Controller Firmware

The Challenge

The objective was to develop highly reliable firmware for an autonomous mobile robot. The system, built on an ESP32 with a BNO055 IMU and wheel encoders, required a 100 Hz control loop and 50 Hz telemetry transmission over a 921 kbps UART link. A simple, single-threaded approach was insufficient for this application, as it would lead to missed commands, data packet loss, and unsafe operation due to processing delays.


The Solution

A sophisticated, multi-threaded firmware solution was engineered, leveraging the ESP32’s dual-core architecture with FreeRTOS. This architecture guaranteed real-time performance by dedicating the ESP32's Core 0 to high-priority control and command reception tasks, while Core 1 handled data transmission and user interface updates.

Modular C++ classes were developed to manage all hardware components, including the BTS7960B motor drivers, wheel encoders, and the BNO055 IMU. The firmware performed precise inverse kinematic calculations, converting high-level linear and angular velocity commands into PWM signals for each wheel, based on the robot's 0.20 m wheelbase. High-resolution odometry was implemented, with each encoder tick corresponding to approximately 0.142 mm of travel.

Safety was a core design component, ensured through the integration of a command timeout watchdog that halts the robot if communication is lost for over two seconds, an emergency stop handler, and a mutex to protect shared system states. This preemptive, task-based model eliminated blocking operations, resulting in a responsive, safe, and reliable control system ready for advanced autonomous navigation.