Setting control mode for XL320

I have been experimenting with pypot and XL320, only low-level IO so far. My motor is in wheel mode, I did not succeed to set it in joint mode.

Here is my test case:

import itertools

import pypot.dynamixel

ports = pypot.dynamixel.get_available_ports()

dxl_io = pypot.dynamixel.Dxl320IO(ports[0], baudrate=1000000)

ids = dxl_io.scan(range(10))

print(ids)  # [2]

###
print(dxl_io.get_control_mode(ids))  # ('wheel',)

speed = dict(zip(ids, itertools.repeat(100)))
dxl_io.set_moving_speed(speed)  # works

speed = dict(zip(ids, itertools.repeat(0)))
dxl_io.set_moving_speed(speed)  # works

###
dxl_io.set_joint_mode(ids)
print(dxl_io.get_control_mode(ids))  # ('wheel',)  -> fail

mode = dict(zip(ids, itertools.repeat('joint')))
dxl_io.set_control_mode(mode)
print(dxl_io.get_control_mode(ids))  # ('wheel',)  -> fail

pos = dict(zip(ids, itertools.repeat(100)))
dxl_io.set_goal_position(pos)  # fail (logique)

### dummy to check connection
dxl_io.set_LED_color({2: 'red'})  # works
dxl_io.set_LED_color({2: 'off'})  # works

###
dxl_io.close()   # works

@pierre any ideas?

One possible explanation is that you can only change EEPROM when your motor have torque disabled. This is a new security (I guess?) introduced by robotis in the XL-320.

So try something like:


print(dxl_io.get_control_mode(ids)) 
>>> ('wheel',)


dxl_io.disable_torque(ids)

dxl_io.set_joint_mode(ids)

print(dxl_io.get_control_mode(ids)) 
>>> 'hopefully joint :-)'

Let me know if this was your problem.

I’m still searching for a way to raise an Error or a Warning when this happened but I haven’t found the time to integrate this smoothly without breaking anything else.

1 Like

Works fine! Thks

Post must be at least 20 characters