Robotics

ROS 2 Mobile Robot Hardware Architecture: Microcontroller Bridging, Motor Drivers, and Sensor Integration, explained simply.

Designing an Autonomous Mobile Robot (AMR) requires bridging two very different computing paradigms: the millisecond-deterministic, safety-critical domain of motor drivers, PID loops, and optical encoders, and the non-real-time, high-compute domain of ROS 2 Nav2, LiDAR SLAM, and costmap generation. Here is how to architect a reliable hardware and communication topology for industrial mobile platforms.

By YantriX Engineering Team · Robotics Hardware Studio5 min read
ROS 2 mobile robot hardware architecture combining NVIDIA Jetson, STM32 microcontroller, and LiDAR

Core idea

What this blog covers

A common architectural mistake in mobile robotics development is attempting to run closed-loop PID motor velocity control or wheel odometry interrupts directly on an operating system like Ubuntu on a Single Board Computer (SBC). Linux scheduling jitter, serial bus latency, and USB disconnects degrade odometry, cause Nav2 costmap distortion, and create safety risks in warehouse environments.

Main discussion

Separation of concerns: High-level autonomy vs Low-level real-time control

An industrial mobile robot architecture must be bifurcated into two distinct layers:

1. Real-Time Execution Layer (Microcontroller): Handled by a 32-bit MCU (such as an STM32F4/G4 or ESP32-S3). This layer runs deterministic hardware timers at 100 Hz to 1 kHz, capturing quadrature encoder pulses via hardware timer encoder modes, computing closed-loop PID/feedforward velocity control for brushless DC (BLDC) motor drivers, reading optical bumper switches, and managing emergency-stop (E-Stop) hardware cutoffs.

2. Autonomy & Compute Layer (Host SBC): Handled by an NVIDIA Jetson Orin Nano, Raspberry Pi CM4, or industrial x86 PC running Ubuntu 24.04 and ROS 2 Jazzy or Humble. This layer processes high-bandwidth sensor data: 2D/3D LiDAR point clouds, stereo depth camera streams, Cartographer / Slam Toolbox scan matching, global and local path planning (Nav2), and fleet management interfaces, as detailed in our Robotics Engineering & Autonomous Systems Services.

Micro-ROS vs Serial packet bridges on STM32 / ESP32

To connect the MCU to the ROS 2 host, engineers historically wrote custom serial string parsers or used legacy rosserial. In modern ROS 2 deployments, two robust approaches dominate:

• micro-ROS Client: Runs directly on bare-metal or FreeRTOS on STM32/ESP32. It natively publishes ROS 2 messages (e.g., nav_msgs/msg/Odometry, sensor_msgs/msg/Imu) and subscribes to geometry_msgs/msg/Twist (cmd_vel) over a micro-ROS Agent bridge running on the Linux host. It provides native DDS types and QoS reliability profiles.

• Binary Packet Protocol over CAN Bus or UART with DMA: For high-noise industrial chassis, running a dedicated CAN 2.0B or CAN-FD bus at 500 kbps / 1 Mbps between motor controllers and a central MCU provides superior noise immunity and multi-drop wiring. The MCU then aggregates telemetry and communicates with the Linux host via high-speed UART (921,600 baud) using DMA buffers and CRC16 checksum verification.

Odometry pipeline: Encoders, IMU fusion, and the robot_localization EKF

Accurate dead reckoning is the foundation of reliable autonomous navigation. In a differential drive or mecanum mobile base, relying solely on wheel optical encoders introduces cumulative drift: wheel slip during sudden deceleration, tire compliance under payload changes, and floor irregularities corrupt the robot's pose estimate.

The industry standard pipeline uses the ROS 2 robot_localization package running an Extended Kalman Filter (EKF): • Source 1: Wheel odometry from the MCU (linear velocity vx, angular velocity vtheta). • Source 2: 6-DOF IMU mounted rigidly along the robot's center of gravity (yaw velocity wz and linear accelerations ax, ay). The EKF fuses high-rate wheel encoders (accurate short-term translation) with the IMU gyro (immune to wheel slip during rapid turns), publishing a drift-reduced odom -> base_link transform that allows Nav2 costmaps to remain crisp and stable during high-speed transit, as deployed in our 80kg-Payload Heavy AMR Platform Development Case Study.

Power distribution and electrical noise isolation for mobile bases

High-current motor transients are the primary culprit behind unexplained SBC reboots and sensor data corruption on mobile robots. When an 80kg AMR accelerates from rest or encounters an obstacle, peak motor current can surge to 30A–50A within milliseconds, causing battery bus voltage sag (inductive kick and internal battery IR drop).

Key electrical design practices: 1. Separate battery rails: Step down 24V or 48V LiFePO4 battery voltage through an isolated, wide-input DC-DC converter (e.g., 18V–75V input to regulated 12V / 5V) specifically dedicated to compute and sensors, with large bulk electrolytic reservoir capacitors. 2. Galvanic ground isolation: Route motor return currents directly back to the battery BMS terminal via star grounding to avoid sharing high-current motor ground paths with sensitive analog IMU or micro-ROS UART return paths. 3. Hardware E-Stop safety loop: The emergency stop button must physically de-energize the motor driver gate power or drop the main DC contactor coil through dual-channel safety relays, rather than relying solely on software stop commands.

Sensor topology: 2D/3D LiDAR, depth cameras, and wheel base placement

Mounting sensors correctly on the mechanical CAD frame is critical before running SLAM:

• 2D Safety / Navigation LiDAR: Positioned at 150mm–250mm above floor level to detect low obstacles, pallet feet, and walls. If positioned too high, low obstacles fall into the blind spot below the scan plane; if too low, floor tilt during acceleration causes ground plane false positives. For 360-degree coverage, either mount on opposing diagonal corners (front-left and rear-right dual LiDARs merged via laser_filters) or use an elevated mast.

• RGB-D Depth Cameras: Mounted forward-facing at a slight downward angle (15°–20°) to detect drop-offs (negative obstacles like stairwells or loading docks) and overhangs (tabletops, warehouse pallet rack beams) that pass over the 2D LiDAR plane.

• Kinematic Center Alignment: Ensure the robot's physical wheel axle center coincides accurately with the base_link frame origin in the URDF CAD description to avoid kinematic calculation errors.

Common hardware integration failures in mobile robotics prototyping

1. Using non-real-time USB-to-UART dongles: Cheap FTDI or CH340 USB serial adapters have kernel buffer latency timers (typically defaulting to 16ms in Linux). Set latency_timer to 1ms in udev rules or use native hardware serial (/dev/ttyTHS* or /dev/ttyAMA*) to avoid sluggish control loop feedback.

2. Lack of hardware quadrature decoding: Decoding high-resolution 1024-PPR encoders using software GPIO pin-change interrupts can overload the MCU at high motor RPM. Using dedicated microcontroller hardware timer peripheral encoder modes prevents missed counts.

3. Back-EMF energy return during braking: When decelerating a heavy robot carrying its payload, motors act as generators, dumping current back into the power bus. Without regenerative braking management or TVS clamp diodes, the bus voltage spikes, destroying motor driver MOSFETs.

4. Loose mechanical sensor fixtures: A 3D printed LiDAR mount that flexes by even 0.5 degrees under chassis vibration causes point cloud oscillation, manifesting as false 'phantom obstacles' in Nav2 local costmaps.

Tagged

  • ROS 2
  • Mobile Robotics
  • Nav2
  • micro-ROS
  • AMR
  • Hardware Architecture
  • LiDAR

Key takeaways

What readers should remember

  • Hard real-time motor commutation and low-level encoder counting is best handled on dedicated microcontrollers (such as STM32 or ESP32), separating it from the non-real-time Linux host.
  • Use micro-ROS over CAN bus or reliable hardware UART with DMA to stream differential drive odometry and receive cmd_vel targets.
  • Isolate motor power buses from compute electronics using DC-DC isolated converters, flyback diodes, and separate ground star topologies to prevent brownouts under acceleration.
  • Wheel slip during acceleration invalidates pure encoder odometry; fuse wheel ticks with a 6-DOF or 9-DOF IMU using an Extended Kalman Filter (robot_localization).

Frequently asked questions

Answers from the work itself.

Why can't I control robot motors directly from a Raspberry Pi or Jetson without a microcontroller?

Linux is a non-real-time operating system. OS scheduling jitter and background processes interrupt motor control loops and encoder counting, causing uneven motor speeds, lost wheel position counts, and distorted odometry that degrades navigation.

What communication protocol is best between ROS 2 and the motor controller?

In industrial mobile robots, CAN bus (with CANopen or a compact binary packet protocol) is preferred for chassis-level reliability and electrical noise immunity. For direct SBC-to-MCU connections, high-speed hardware UART (460,800 or 921,600 baud) running micro-ROS or structured binary frames with CRC checksums is the most reliable choice.

How do I prevent motor electrical noise from crashing my Jetson or LiDAR?

Use a star ground topology where motor high-current return loops directly to the battery, power the Jetson and sensors from an isolated wide-input DC-DC converter with LC filtering, use twisted-pair shielded cabling for CAN/UART, and install flyback diodes across inductive loads.

Related reading

Keep going on robotics.

Continue exploring

Related services and proof points

Explore our core engineering capabilities and verified hardware case studies related to this technical domain.

Engineering Consultation

Working on a similar engineering problem?

Share your technical specifications, prototype requirements, or CAD models with our engineering team. NDA support is available where required before confidential CAD exchange.