This notebook is still work in progress! Feedbacks are welcomed!
In this tutorial we will show how to get started with your PoppyErgo creature. You can use a PoppyErgoJr instead.
To run the code in this notebook, you will need:
You can install those libraries with the pip tool (see here if you don't know how to run this):
pip install pypot poppy-ergo
For a PoppyErgo:
In [1]:
from poppy.creatures import PoppyErgo
In [2]:
ergo = PoppyErgo()
For a PoppyErgoJr:
In [ ]:
from poppy.creatures import PoppyErgoJr
ergo = PoppyErgoJr()
In [3]:
ergo
Out[3]:
In [4]:
ergo.m2
Out[4]:
In [5]:
ergo.m2.present_position
Out[5]:
In [6]:
ergo.m2.present_temperature
Out[6]:
In [7]:
for m in ergo.motors:
print 'Motor "{}" current position = {}'.format(m.name, m.present_position)
In [8]:
ergo.m3.compliant
Out[8]:
In [9]:
ergo.m6.compliant = False
In [10]:
ergo.m6.goal_position = 0.
In [11]:
for m in ergo.motors:
m.compliant = False
# Goes to the position 0 in 2s
m.goto_position(0, 2)
In [ ]:
# You can also change the maximum speed of the motors
# Warning! Goto position also change the maximum speed.
for m in ergo.motors:
m.moving_speed = 50
On a single motor:
In [13]:
import time
ergo.m4.goal_position = 30
time.sleep(1.)
ergo.m4.goal_position = -30
On multiple motors:
In [14]:
ergo.m4.goal_position = 30
ergo.m5.goal_position = 20
ergo.m6.goal_position = -20
time.sleep(1.)
ergo.m4.goal_position = -30
ergo.m5.goal_position = -20
ergo.m6.goal_position = 20
Wrap it inside a function for convenience:
In [15]:
def dance():
ergo.m4.goal_position = 30
ergo.m5.goal_position = 20
ergo.m6.goal_position = -20
time.sleep(1.)
ergo.m4.goal_position = -30
ergo.m5.goal_position = -20
ergo.m6.goal_position = 20
time.sleep(1.)
In [16]:
dance()
In [17]:
for _ in range(4):
dance()
Using goto position instead:
In [18]:
def dance2():
ergo.goto_position({'m4': 30, 'm5': 20, 'm6': -20}, 1., wait=True)
ergo.goto_position({'m4': -30, 'm5': -20, 'm6': 20}, 1., wait=True)
In [19]:
for _ in range(4):
dance2()