tr2023-robot/Robot.py
2023-03-25 11:55:37 +01:00

55 lines
1.8 KiB
Python

import RobotCompletCode
Controls = RobotCompletCode.MotorizedPlatform()
class Robot:
def init(self):
Controls.init()
def set_range(self, name:str, mini:int, maxi:int):
Controls.set_range(name,mini,maxi)
def translation(self, direction, vitesse):
if direction == 'N':
Controls.northTranslation(vitesse)
elif direction == 'E':
Controls.eastTranslation(vitesse)
elif direction == 'W':
Controls.westTranslation(vitesse)
elif direction == 'S':
Controls.southTranslation(vitesse)
elif direction =='SE':
Controls.southEastTranslation(vitesse)
elif direction == 'SW':
Controls.southWestTranslation(vitesse)
elif direction == 'NE':
Controls.northEastTranslation(vitesse)
elif direction =='NW':
Controls.northWestTranslation(vitesse)
else:
print('error')
return 'error'
def rotation(self, direction, vitesse):
if direction == 'CW':
Controls.clockwiseRotation(vitesse)
elif direction == 'ACW':
Controls.antiClockwiseRotation(vitesse)
else:
print('error')
return 'error'
def turbine(self, vitesse):
pass
def tuyau(self, axe, vitesse):
#axe : vertical / horizontal
pass
def stop(self):
Controls.stop()
def easy(self, mode, direction, vitesse):
if mode=='R':
self.rotation(direction, vitesse)
elif mode=='T':
self.translation(direction, vitesse)
else:
print('error')
return 'error'
def easyjson(self, jsondata):
# Easy but from JSON datas
self.easy(jsondata["mode"], jsondata["direction"], jsondata["vitesse"])