-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExecuteCommands.py
38 lines (30 loc) · 1.14 KB
/
ExecuteCommands.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
from InterpolationMethods import InterpolationMethods
from JsonDeserialize import JsonDeserialize
from JsonParser import JsonParser
class ExecuteCommands:
def __init__(self, jsonCommand):
self.parsingFile(jsonCommand)
def parsingFile(self, jsonCommand):
data = JsonParser.ReadExamplesCommand(jsonCommand)
servos = JsonDeserialize.commands(data)
self.recognizeServos(servos)
def recognizeServos(self, servos):
position = []
for servo in servos:
idServo = self.servoNameToId(servo.name)
goalPosition = servo.goalPosition
position.append(self.calculateGoalPosition(idServo, goalPosition))
print(position)
@staticmethod
def servoNameToId(name):
return ({
name == 'Head': 1,
name == 'Neck': 2
})[False]
@staticmethod
def calculateGoalPosition(idServo, goalPosition):
calculate = InterpolationMethods()
return ({
idServo == 1: calculate.CalcHead(goalPosition),
idServo == 2: calculate.CalcNeck(goalPosition)
})[False]