Close

Adding Dynamic Course Correction - Update 1

A project log for Indoor Autonomous Mobile Platform

Building a prototype Autonomous Mobile Robot (AMR) to apply ROS 2 and SLAM concepts in a real-world environment.

peter-wallheadPeter Wallhead 07/25/2025 at 02:540 Comments

The first step to get the robot driving forward in a straight line was to finally get it driving wirelessly under its own power.

The Pi 4 is super power hungry, especially at boot with the RPLidar connected, and requires a power bank with a decent 3A output. The motors are currently running on only 6V, supplied by a pack of AA cells, but have been tested up to 12V in short bursts.

The cheap gearboxes I'm using have a 48:1 gear ratio and don't provide enough torque at lower voltages on carpet, but run well enough on hard surfaces.

The initial method I tested for course correction as the robot drives forward was to compare the difference between the raw encoder ticks from each motor and then to slow down or speed up the corresponding motor to correct for the difference.

In this first test the robot's wheels were off the ground and allowed to spin freely. Initially, this method looked promising until it began oscillating left and right as it overshot the target point and then over corrected.

The RVIZ2 plot below shows the pose estimate for this test.


I ran some additional tests using this same method with the robot driving on a hard surface, and the results were similar; a hard twist to the right and then a series of wild oscillations.

Further testing revealed that my encoder ticks publisher was running too slowly, at only 5 Hz, and this was contributing to the wild oscillation I was seeing. I have since increased this publisher speed to 50Hz.

I then updated the method I was using to recalculate the motor speed error to a partial PID loop, only setting the Proportional gain.

In the RVIZ2 plot over 100m with the wheels freewheeling, it’s clear that this new method was going to be a lot more successful. While there was still a slight twist to the right as the motors came up to speed, the robot’s path remained relatively straight.

In the final test performed for this update, I ran the robot on the ground with the proportional gain set 3.1 (which was the gain that gave the best performance in the freewheeling tests). The RVIZ2 plot below shows the now familiar twist to the right, and then a straightening as the error slowly decreased over the 4 to 5m long run.


Discussions