-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstairs.py
70 lines (56 loc) · 1.73 KB
/
stairs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python
"""
Climbing stairs (demo for Tour-the-Stairs 2015)
usage:
./stairs.py <task> [<metalog> [<F>]]
"""
import sys
import math
from jumpingsumo import JumpingSumo
from commands import moveCmd, jumpCmd, loadCmd, postureCmd, addCapOffsetCmd, setVolumeCmd
# this will be in new separate repository as common library fo robotika Python-powered robots
from apyros.metalog import MetaLog, disableAsserts
from apyros.manual import myKbhit, ManualControlException
def move( robot, speed, steps ):
for i in xrange(steps):
robot.update( cmd=moveCmd(speed, 0) )
robot.update( cmd=moveCmd(0,0) )
def step1( robot ):
# move( robot, 20, 30 )
move( robot, -20, 20 )
robot.wait(1.0)
robot.update( cmd=jumpCmd(1), ackRequest=True )
robot.wait(5.0)
move( robot, 20, 10 )
move( robot, 0, 10 )
move( robot, -20, 5 )
robot.wait(1.0)
def step2( robot ):
robot.update( cmd=jumpCmd(1), ackRequest=True )
robot.wait(5.0)
move( robot, 20, 20 )
move( robot, -20, 5 )
robot.update( cmd=addCapOffsetCmd(math.radians(10)) )
def backup( robot ):
"fall back in order to save the sequence"
move( robot, -20, 10 )
move( robot, 20, 20 )
move( robot, -20, 5 )
def tourTheStairs2015( robot ):
step1(robot)
for i in xrange(30):
step2(robot)
backup( robot )
if __name__ == "__main__":
if len(sys.argv) < 2:
print __doc__
sys.exit(2)
metalog=None
if len(sys.argv) > 2:
metalog = MetaLog( filename=sys.argv[2] )
if len(sys.argv) > 3 and sys.argv[3] == 'F':
disableAsserts()
robot = JumpingSumo( metalog=metalog )
tourTheStairs2015( robot )
print "Battery:", robot.battery
# vim: expandtab sw=4 ts=4