ros-mobile-robots / diffbot

DiffBot is an autonomous 2wd differential drive robot using ROS Noetic on a Raspberry Pi 4 B. With its SLAMTEC Lidar and the ROS Control hardware interface it's capable of navigating in an environment using the ROS Navigation stack and making use of SLAM algorithms to create maps of unknown environments.
https://ros-mobile-robots.com
BSD 3-Clause "New" or "Revised" License
297 stars 86 forks source link

Question about Motors, minimum accomplishable RPM #80

Closed altineller closed 1 year ago

altineller commented 1 year ago

Hello,

I am using the same type of motors, and a custom made driver board for my robot. Everything is working well, but there is a minor problem: These motors have a high deadzone, and the PID algorithm is having a hard time - controlling them at low speeds, such as < 5RPM. The problem gets worse, as the robot weight increases. :(

I have tried many things, such as lowering the PWM frequency, (the lower the pwm frequency, the less deadzone we have, but at frequencies like 100hz, the system generates electrical noise. Another trick that I tried is to read encoders, and current feedback and change pid constants when the motor is not moving, which does work - but then leads to stability problems in the PID algorithm.

What was your experience on this problem? What was your lowest observed wheel RPM? I understand you are doing the PID in the teensy, and not doing something non-standard?

Best Regards, Can Altineller

fjp commented 1 year ago

Hi Can,

I've experienced the same issues with these motors. Here are some videos showing the tests I did when I started. The first one shows the deadzone issue you mention:

After switching from the high level PID (running on the SBC in the ROS hardware interface) to the low level PID (running on the Teensy mcu) and using the sturdy REMO 3D printed parts, I think the behavior got slightly better but I am still using only two PID controllers (both with the same gains) and no further tricks. What might also help is to use the gain trim model that's also used on the duckiebots. However, this all doesn't really improve the issue with low speeds and I didn't investigated the issue further yet.

Where did you lower the PWM frequency and which value do you use? As far as I know I left the default of 1600 Hz (when using the low level PID approach). I am not sure what value is set when I used the high level PID and the grove motor driver.

Best Regards Franz

altineller commented 1 year ago

Hi Franz,

I have read the relevant parts of the code. I understand you are extending the control_toolbox for PID. And I also understand you are using 1.0 for gain and motor constant as the default, and F=0.8 is an pid output multiplier, i.e. output transfer function.

I will give a try to the duckietown trim model, which seems practical.

These motors work best from 50-100hz, with fast decay model. Fast decay model means when the pwm is at 0, the driver allows the two terminals of motor be shorted, i.e. brake mode, giving it better precision, lower deadzone, but higher power consumption.

I am working on a custom made controller board that I made myself, that features an arm cortex mcu, which has very advanced pwm generation features. I believe your PWM frequency of 1600hz, is inefficient for these motors.

I have tried to make a digital 'vitesse' that changes the PWM frequency, when the motor is not moving it starts from 10hz, and as the duty cycle increases, it will increase the pwm frq to 25hz, 50hz and 100hz. However this idea failed, as the efficiency of motors are different for different pwm frequencies, it introduces an instability to PID algorithm. With my current setup, I can not use different frequencies for left and right motor, (i have to wire up the second motor, to a different pwm generator on my arm mcu, which i will try with another iteration) - so I will attempt again at another time.

Best Regards, C.