tr2023-robot/Robot.py

67 lines
2.1 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()
2023-03-25 10:55:37 +00:00
def set_range(self, name:str, mini:int, maxi:int):
Controls.set_range(name,mini,maxi)
2023-03-25 09:33:33 +00:00
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):
print(direction, vitesse)
2023-03-25 09:33:33 +00:00
if direction == 'CW':
print('vitesse')
2023-03-25 09:33:33 +00:00
Controls.clockwiseRotation(vitesse)
elif direction == 'ACW':
print(vitesse)
2023-03-25 09:33:33 +00:00
Controls.antiClockwiseRotation(vitesse)
else:
print('error')
return 'error'
def turbine_aspirer(self):
Controls.set_raw_esc('turbine', 230)
def turbine_stop(self):
Controls.set_raw_esc('turbine', 0)
def turbine_souffler(self):
Controls.set_raw_esc('turbine', 251)
2023-03-25 10:55:37 +00:00
def tuyau(self, axe, vitesse):
#axe : vertical / horizontal
pass
2023-03-25 09:33:33 +00:00
def stop(self):
Controls.stop()
def easy(self, mode, direction, vitesse):
if mode=='R':
self.rotation(direction, vitesse)
elif mode=='T':
2023-03-25 10:55:37 +00:00
self.translation(direction, vitesse)
2023-03-25 09:33:33 +00:00
else:
print('error')
return 'error'
def easyjson(self, jsondata):
# Easy but from JSON datas
self.easy(jsondata["mode"], jsondata["direction"], jsondata["vitesse"])