tr2023-robot/Robot.py

49 lines
1.6 KiB
Python
Raw Normal View History

2023-03-25 09:33:33 +00:00
import RobotCompletCode
Controls = RobotCompletCode.MotorizedPlatform()
class Robot:
def init(self):
Controls.init()
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 stop(self):
Controls.stop()
def easy(self, mode, direction, vitesse):
if mode=='R':
self.rotation(direction, vitesse)
elif mode=='T':
self.translation(diretion, vitesse)
else:
print('error')
return 'error'
def easyjson(self, jsondata):
# Easy but from JSON datas
self.easy(jsondata["mode"], jsondata["direction"], jsondata["vitesse"])