-
Notifications
You must be signed in to change notification settings - Fork 11
/
S-CodeParse.py
51 lines (44 loc) · 1.2 KB
/
S-CodeParse.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
"""
S-code Parser
"""
from smars_library.smars_library import SmarsRobot, Leg
import smars_library.smars_library as sl
import time
def readLine(line):
sm = SmarsRobot()
sm.setname("Quaddy")
sm.type = "Quad"
if line[0] == 's101': # Move Forward
sm.walkforward(100)
if line[0] == 's102': # Move Backward
sm.walkbackward(100)
if line[0] == 's103': # Turn left
sm.turnleft()
if line[0] == 's104': # Turn right
sm.turnright()
if line[0] == 's155': # Stand Up
sm.stand()
if line[0] == 's156': # Sit down
sm.sit()
if line[0] == 's157': # Clap
print("line count: ", len(line))
if len(line) <= 1:
clap_count = 3
else:
clap_count = int(line[1]) # convert str to int
sm.clap(clap_count)
if line[0] == 's158': # Wiggle
print("line count:", len(line))
if len(line) <= 1:
wiggle_count = 3
else:
wiggle_count = int(line[1]) # convert str to int
sm.wiggle(wiggle_count)
# Main
keywords = ""
while keywords != "quit":
key = input("# ")
keywords = key.split()
for items in keywords:
print(items)
readLine(keywords)