import pypot.dynamixel
import pypot.robot
ports = pypot.dynamixel.get_available_ports()
print 'Found ports', ports
port = ports[0]
print 'Using', port
Found ports ['/dev/ttyUSB0'] Using /dev/ttyUSB0
io = pypot.dynamixel.DxlIO(port)
ids = io.scan(range(40))
print 'Found ids', ids
Found ids [11, 36, 37]
motors = [pypot.dynamixel.motor.DxlMXMotor(id) for id in ids]
motors
[<DxlMotor name=motor_11 id=11 pos=0.0>, <DxlMotor name=motor_36 id=36 pos=0.0>, <DxlMotor name=motor_37 id=37 pos=0.0>]
c = pypot.dynamixel.controller.BaseDxlController(io, motors)
robot = pypot.robot.Robot([c])
robot.start_sync()
for m in robot.motors:
m.compliant = False
m.goal_position = 0
from pypot.primitive.utils import Sinus
s1 = Sinus(robot, 50, robot.motors, amp=30)
s2 = Sinus(robot, 50, robot.motors, amp=5, freq=2)
s1.start()
%pylab inline
import time
pos = []
start = time.time()
while time.time() - start < 5:
pos.append(robot.motors[0].present_position)
time.sleep(0.02)
plot(linspace(0, 5, len(pos)), pos)
Populating the interactive namespace from numpy and matplotlib
[<matplotlib.lines.Line2D at 0xa39fa0c>]
s2.start()
import time
pos = []
start = time.time()
while time.time() - start < 5:
pos.append(robot.motors[0].present_position)
time.sleep(0.02)
plot(linspace(0, 5, len(pos)), pos)
[<matplotlib.lines.Line2D at 0xa4fe50c>]
s1.stop()
import time
pos = []
start = time.time()
while time.time() - start < 5:
pos.append(robot.motors[0].present_position)
time.sleep(0.02)
plot(linspace(0, 5, len(pos)), pos)
[<matplotlib.lines.Line2D at 0xa54d9ac>]
s2.stop()
import time
pos = []
s1.start()
s2.start()
start = time.time()
while time.time() - start < 10:
pos.append(robot.motors[0].present_position)
time.sleep(0.02)
if (3 < time.time() - start < 9):
s2.pause()
else:
s2.resume()
plot(linspace(0, 10, len(pos)), pos)
s1.stop()
s2.stop()