In [1]:
import pypot.dynamixel
import time
Find the available usb port. The port where USB2AX or USBDynamixel is plug.
In [2]:
print(pypot.dynamixel.get_available_ports())
Open a low level connexion to the motors, don't forget to replace 'COM3' if your port is different.
In [3]:
dxl_io = pypot.dynamixel.Dxl320IO('COM3', use_sync_read=True)
Find the different motors which must have differents id. Id have been set up before with the herborist tool.
In [5]:
print(dxl_io.scan(range(30)))
A test to check the speed of the communication with your motor. On windows it is possible that you have to change the latency time of the driver of the usbdynamixel (see forum : https://forum.poppy-project.org/t/birth-of-poppy-ergo-jr-and-support-for-low-cost-xl-320-motors/1052/22)
In [4]:
%timeit dxl_io.get_present_position((1, 2, 3, 4))
Setting the robot to 0 position :
In [5]:
dxl_io.set_goal_position({1: 0})
dxl_io.set_goal_position({2: 0})
dxl_io.set_goal_position({3: 0})
dxl_io.set_goal_position({4: 0})
If you want to close the connexion :
In [27]:
dxl_io.close()
Now, if you want to have a robot acces and not only motors access, you have to configure your robot.
In [1]:
from pypot.dynamixel import autodetect_robot
my_robot = autodetect_robot()
for m in my_robot.motors:
m.goal_position = 0.0
In [20]:
my_robot.motors
Out[20]:
In [5]:
my_robot.motor_1.goal_position = 0
You can save the configuration in a file :
In [9]:
import json
config = my_robot.to_config()
with open('mini_dof.json', 'wb') as f:
json.dump(config, f)
And close the robot :
In [14]:
my_robot.close()
You can use your previous json file to instanciate your robot :
In [9]:
from pypot.robot import from_json
mini_4dof = from_json('test.json')
In [10]:
mini_4dof.motors
Out[10]:
And make move your robot :
In [12]:
mini_4dof.m4.goto_position(90,0.5)
In [13]:
mini_4dof.m4.goto_position(-90,0.5)
In [228]:
mini_4dof.m3.goto_position(-10,0.5)
In [229]:
mini_4dof.m3.goto_position(90,0.5)
In [211]:
mini_4dof.m4.goto_position(90,0.5)
mini_4dof.m4.goto_position(-90,0.5)
In [216]:
mini_4dof.m3.goal_position = 20
In [8]:
mini_4dof.close()
If you have correctly set your robot as a poppy creature you just have to import the class and instanciate your robot :
In [2]:
from poppy.creatures import Poppy4dofArmMini
To know what poppy creature are installed on your computer :
In [3]:
installed_poppy_creatures_packages()
Out[3]:
In [29]:
poppy = Poppy4dofArmMini()
In [30]:
poppy.motors
Out[30]:
In [35]:
poppy.close()
To check what is installed on your computer. You have to find the name of your creature.
In [1]:
import pip
pip.get_installed_distributions()
Out[1]:
In [ ]: