While messing with the robot speed control routines in my project, I have made an interesting discovery:
Viz.:
If set_motor_dps
speed is set less than about 20, the wheels move in a series of jerks timed about once a second, with the motion per jerk being proportional to the speed value. After 20 dps, the wheel motion is more-or-less smooth.[1]
Viz.: (executed from the python 3.n shell in Thonny)
Python 3.7.3 (/usr/bin/python3)
>>> import gopigo3
>>> from easygopigo3 import EasyGoPiGo3
>>> gopigo = EasyGoPiGo3()
>>> gopigo.set_motor_dps(gopigo.MOTOR_RIGHT, 3)
>>> gopigo.set_motor_dps(gopigo.MOTOR_RIGHT, 10)
>>> gopigo.set_motor_dps(gopigo.MOTOR_LEFT, 10)
>>> gopigo.set_motor_dps(gopigo.MOTOR_RIGHT, 20)
>>> gopigo.set_motor_dps(gopigo.MOTOR_LEFT, 20)
>>> gopigo.set_motor_dps(gopigo.MOTOR_LEFT, 15)
>>> gopigo.set_motor_dps(gopigo.MOTOR_RIGHT, 15)
>>> gopigo.stop()
>>> gopigo.set_motor_dps(gopigo.MOTOR_RIGHT, 20)
>>> gopigo.set_motor_dps(gopigo.MOTOR_LEFT, 20)
>>> gopigo.stop()
>>>
Additional important findings concerning robot speed control:
Use of the set_speed()
category of commands, (as well as the functions that depend on it; i.e. forward()
, backward()
, left()
, right()
, (etc)), simultaneously with the set_motor_dps()
category of commands, (set_motor_dps()
, etc.), results in unpredictable behavior as it appears that these two categories of commands are, (or should be), mutually exclusive.
Apparently the robot tries to satisfy both the set_speed()
and the set_motor_dps()
commands simultaneously, instead of allowing the last command entered to supersede any previous robot motion command.[2]
Example:
Originally I used set_speed()
along with forward()
or backward()
for motion directly forward or backward; whereas for turns I used set_motor_dps()
with each wheel receiving a calculated speed value. The result of this was that the transition from turning to straight travel was “buggy” at best with sudden speed changes, or the robot not responding to changes in speed at all. (i.e. The transition from turning to straight motion was accompanied by a sudden burst of speed - or a slow-speed turn continued as slow speed motion regardless of the joystick position.)
When I started using set_motor_dps()
for all motion, (with directly ahead/behind using the same speed value for both motors), the control action became much smoother.
Has anyone else experienced this?
@cleoqc
Is this expected behavior?
===============
One detail I am still researching is what appears to be “command caching” or “command queuing”.
If I do something for longer than about 30 seconds, the instructions get “stored up” somewhere and after I release the joystick, things keep playing for a non-trivial amount of time afterwards.
I don’t know if this is happening within the Python server on the 'bot or within the browser.
Any ideas?
-----------------------
Footnotes:
[1] Speeds up to 15 dps experienced jerkiness. Speeds of 20 dps or greater did not jerk. I did not experiment to determine the exact value that jerking stopped at.
[2] IMHO, this is a bug.
These two categories of commands should automatically supersede each other. Either that or there should be a documented way, (aside from physically stopping the robot or restarting the code), for one set of commands to relinquish command authority to the other set.