After hundreds of turn_degrees() to spin 360 degrees, and of drive_inches() to travel 21 inches forward and backwards, I think I am seeing a consistent variance for movement commands with my GoPiGo3.
To consistently spin 360 degrees [with set_speed(120)], I need to issue turn_degrees(373.5). This amounts to an under-turn of 3.75%. I was even able to repeatably issue ten sequential turns of 373.5 degrees (with 2 second stop delays), and the total directional error after the final turn was the intended direction +/- 2 degrees.
To consistently drive 21 inches, I need to issue a drive_inches(21.8). This amounts to an under-drive of 3.8%
I understand nothing is simple here. Every wheel has a slightly different WHEEL_DIAMETER, and a different contact angle with the floor, Every robot has a slightly different WHEEL_BASE_WIDTH, and toe-in-out. Every motor has a slightly different load response curve. Then there is gear backlash, and start/stop differences between motors that affect consistency.
I also have not measured the error across full to drained battery, other than set_speed(120), and wood floor (with small joints) versus tile floor (with half inch wide, 1/8 inch deep mortared joints - obvious the joints are going to reek havoc).
(My bot is not allowed out of the office onto the tiled and carpeted areas until it is house-broken, but that is for the next post.)
To be seeing a nearly non-variant error of less than 4% is actually quite remarkable, and perhaps is favorable to tuning.
My question: Is it possible to play around with decreasing the WHEEL_DIAMETER by 3.8% (63.98mm) , or will I need to apply my correction factor when issuing commands and when interpreting read_encoder() values (during non-blocking operation or separate threads)?
Will this work?
egpg = easygopigo3.EasyGoPiGo3(use_mutex=True)
# adjust instance "constants" to my particular bot
egpg.WHEEL_DIAMETER = 63.98
egpg.WHEEL_CIRCUMFERENCE = egpg.WHEEL_DIAMETER * math.pi
Example test turns and drives:
===== Spin 373.5 Degrees ========
Encoder Values: 0 0
Turn Processor Time:15.6ms Wall Time:5.5s
Encoder Value: 654 -654
Delta Value: 654 654
Delta Degrees: 371.7 371.7
Accuracy: 99.5% 99.5%
Spin Rate:67.3 dps Wheel Rate:117.9 dps (includes start/stop effect)
=============
^^^^ Turn 1 ^^^^
===== Spin 373.5 Degrees ========
Encoder Values: 654 -654
Turn Processor Time:16.2ms Wall Time:5.5s
Encoder Value: 1308 -1309
Delta Value: 654 655
Delta Degrees: 371.7 372.3
Accuracy: 99.5% 99.7%
Spin Rate:67.3 dps Wheel Rate:117.9 dps (includes start/stop effect)
=============
^^^^ Turn 2 ^^^^
Drive (21.8 inches)? (0=reset, +/- change default_dist by 0.1)
x4
===== Drive 21.8 Inches ========
Encoder Values: 1892 1890
Drive 21.8 inches: Processor Time:20.5ms, Wall Time:8.1s
Encoder Value: 2845 2842
Delta Value: 953 952
Delta Distance: 21.8 21.8
Accuracy: 99.9% 99.8%
Wheel Rate:118.0 dps (includes start/stop effect)
=============
^^^^ Drive 1 ^^^^
===== Drive -21.8 Inches ========
Encoder Values: 2845 2842
Drive -21.8 inches: Processor Time:20.6ms, Wall Time:8.1s
Encoder Value: 1891 1889
Delta Value: 954 953
Delta Distance: 21.8 21.8
Accuracy: -100.0% -99.9%
Wheel Rate:118.2 dps (includes start/stop effect)
=============
^^^^ Drive 2 ^^^^