Problem with set_moving_speed

I connected two motors, in mode wheel. I assigns each motors, the same speed with the function set_moving_speed. But the speed of each motors is not the good speed. Why ?

import pypot.dynamixel
ports = pypot.dynamixel.get_available_ports()
if not ports:
    print ('no serial port found !')
else:
    xl_320 = pypot.dynamixel.Dxl320IO(ports[0])
ids = xl_320.scan(range(10))
xl_320.set_wheel_mode(ids)
xl_320.set_moving_speed({ids[0]: 90})
xl_320.set_moving_speed({ids[1]: -90})


Print present_speed during 10 secondes

for t in range(10):
    print "t = {0:1} s (v1,v2)= ({1:.2f},{2:.2f})".format(t, *xl_320.get_present_speed([ids[0],ids[1]]))
    time.sleep(1)

results:
t = 0 s (v1,v2)= (-53.28,103.90)
t = 1 s (v1,v2)= (-87.91,101.23)
t = 2 s (v1,v2)= (-93.24,106.56)
t = 3 s (v1,v2)= (-85.25,106.56)
t = 4 s (v1,v2)= (-87.91,69.26)
t = 5 s (v1,v2)= (-90.58,101.23)
t = 6 s (v1,v2)= (-93.24,114.55)
t = 7 s (v1,v2)= (-90.58,106.56)
t = 8 s (v1,v2)= (-87.91,101.23)
t = 9 s (v1,v2)= (-87.91,109.22)

I tested your code and I have similar results excepted that speed signs correspond on the sign of the targeted speed.

t = 0 s (v1,v2)= (111.89,-90.58)
t = 1 s (v1,v2)= (-3369.96,-103.90)
t = 2 s (v1,v2)= (111.89,-117.22)
t = 3 s (v1,v2)= (122.54,-103.90)
t = 4 s (v1,v2)= (111.89,-871.13)
t = 5 s (v1,v2)= (109.22,-111.89)
t = 6 s (v1,v2)= (119.88,-106.56)
t = 7 s (v1,v2)= (119.88,-101.23)
t = 8 s (v1,v2)= (111.89,-101.23)
t = 9 s (v1,v2)= (117.22,-114.55)
t = 10 s (v1,v2)= (114.55,-109.22)
t = 11 s (v1,v2)= (-1225.44,-322.34)
t = 12 s (v1,v2)= (111.89,-101.23)
t = 13 s (v1,v2)= (119.88,-111.89)
t = 14 s (v1,v2)= (111.89,-103.90)
t = 15 s (v1,v2)= (106.56,-101.23)

present_position seems to give the true speed as the speed between the two motors is visually a bit different.
I see no information of the control method on wheel mode in the XL-320 documention. I think that the rotary encoder does not work between 300 and 360 degree (cf the angle limitation in join mode), so in wheel mode there is no feedback, the control is only in open loop.
It explains also why present_speed give some very strange values (< 1000) in my results.
So, the true speed in wheel mode will depend on the temperature, the motor, … and it is not reliable…

ok, is there a trick to the two motors run approximately at the same speed. I attached two wheels Playmobil on two motors and I would like my car runs roughly right :slight_smile: For now this is not the case

I think you can try to implement yourself a PI controller if you remove inconsistent values of present_speed.

Good news, @jgrizou and I have worked on this and it’s ready to use. We didn’t implement the PID as it seems like an overkill but simply a controller with an infinite acceleration meaning that when moving, the speed will directly be at its maximum.

It’s also working in Snap!

To test it you can either:

  • re-install pypot from the repository: pip uninstall pypot && pip install git+https://github.com/poppy-project/pypot.git@toward-3.0
  • or wait for the next stable release :slight_smile:
2 Likes

Ok, I will test this week :grinning: