In [1]:
import pypot.dynamixel
import pypot.robot

In [2]:
ports = pypot.dynamixel.get_available_ports()
print 'Found ports', ports
port = ports[0]
print 'Using', port


Found ports ['/dev/ttyUSB0']
Using /dev/ttyUSB0

In [3]:
io = pypot.dynamixel.DxlIO(port)

In [4]:
ids = io.scan(range(40))
print 'Found ids', ids


Found ids [11, 36, 37]

In [5]:
motors = [pypot.dynamixel.motor.DxlMXMotor(id) for id in ids]
motors


Out[5]:
[<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>]

In [6]:
c = pypot.dynamixel.controller.BaseDxlController(io, motors)

In [7]:
robot = pypot.robot.Robot([c])

In [8]:
robot.start_sync()

In [9]:
for m in robot.motors:
    m.compliant = False
    m.goal_position = 0

In [10]:
from pypot.primitive.utils import Sinus

In [11]:
s1 = Sinus(robot, 50, robot.motors, amp=30)
s2 = Sinus(robot, 50, robot.motors, amp=5, freq=2)

In [12]:
s1.start()

In [13]:
%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
Out[13]:
[<matplotlib.lines.Line2D at 0xa39fa0c>]

In [14]:
s2.start()

In [15]:
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)


Out[15]:
[<matplotlib.lines.Line2D at 0xa4fe50c>]

In [16]:
s1.stop()

In [17]:
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)


Out[17]:
[<matplotlib.lines.Line2D at 0xa54d9ac>]

In [18]:
s2.stop()

In [19]:
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()



In [19]:


In [ ]: