How to tune velocity PI controller

Building a heavy (50 lbs) 3-wheeled robot (2 hoverboard BLDC motors/wheels, 1 swivel caster wheel). Robot will carry a load (up to 40lbs additional weight) downhill, dump load, and return uphill for next load. There are also flat portions of the travel path.

Am using an ESP32 as master controller of the robot, communication via CAN bus to the 2 hoverboard wheels. For testing am using RC controller with joysticks. Currently using velocity control mode to command speeds for the hoverboard motors to control speed and turning.

With velocity gain set to 2 and velocity integrator gain set to 0 for the two S1 motor controllers, robot works well on flat and uphill portions of drive path. But of course since the velocity integrator gain is set to 0, the robot freewheels and becomes uncontrollable on the downhill portion of the path (the sloped portion of the path is fairly steep, probably 20 degrees off level).

Problem is, if I adjust the velocity integrator gain anywhere between 0.3 - 4.0, the robot works well on the steep slope going downhill (ie it does a decent job of self-braking to control speed) but going uphill it develops a strong tendency to veer to one side or the other that gets worse over time and eventually becomes impossible to correct using the steering joystick. I believe the integrated error of one or the other motors over time when under heavy load (ie going uphill) becomes more than my steering adjustments can override.

  • Is this a common problem with heavy robots that must work on surfaces that are not mostly level (ie PID controller variables need to be altered depending on slope/operating conditions)?

  • I’m thinking about automatically changing the velocity integrator gain according to the readings from an integrated IMU (ie, set to 0 unless on a steep downhill slope). Can the velocity integrator gain be changed via the CAN bus? Is there a better way to solve this problem? Maybe zero out the accumulated error every 100ms when not on a downhill?

I have built a similar robot in the past using geared PowerWheel motors that worked pretty well (the gearing acted as a brake on the downhill slopes). I thought the BLDC motors paired with ODrive S1 motor controllers would be more efficient, more quiet and an elegant solution this 2nd iteration but maybe not?

Nate