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:
from pypot.creatures import PoppyErgo
ergo = PoppyErgo()
For a PoppyErgoJr:
from pypot.creatures import PoppyErgoJr
ergo = PoppyErgoJr()
ergo
<Robot motors=[<DxlMotor name=m1 id=11 pos=-1.69>, <DxlMotor name=m2 id=12 pos=-97.13>, <DxlMotor name=m3 id=13 pos=89.96>, <DxlMotor name=m4 id=14 pos=0.65>, <DxlMotor name=m5 id=15 pos=41.5>, <DxlMotor name=m6 id=16 pos=22.14>]>
ergo.m2
<DxlMotor name=m2 id=12 pos=-97.43>
ergo.m2.present_position
-97.13
ergo.m2.present_temperature
32.0
for m in ergo.motors:
print 'Motor "{}" current position = {}'.format(m.name, m.present_position)
Motor "m1" current position = -1.69 Motor "m2" current position = -97.13 Motor "m3" current position = 89.96 Motor "m4" current position = 0.65 Motor "m5" current position = 41.5 Motor "m6" current position = 22.14
ergo.m3.compliant
True
ergo.m6.compliant = False
ergo.m6.goal_position = 0.
for m in ergo.motors:
m.compliant = False
# Goes to the position 0 in 2s
m.goto_position(0, 2)
# 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:
import time
ergo.m4.goal_position = 30
time.sleep(1.)
ergo.m4.goal_position = -30
On multiple motors:
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:
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.)
dance()
for _ in range(4):
dance()
Using goto position instead:
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)
for _ in range(4):
dance2()