from Driver import PWMDriver as Driver class driver(): def setvitesse(self,pin,vitesse): print("le moteur avec le pin ",pin," avance à la vitesse", vitesse,".") dri=Driver() dri.set_esc(pin,vitesse) class Robot(): d = [1,2] g = [3,4] motors = [d[0],d[1],g[0],g[1]] class Translation(): motors = [] def init(self,v): self.motors = v def droit(self,v): rb = driver().setvitesse m = self.motors for i in range(len(m)): rb(m[i],v) def trv(self,v,d): rb = driver().setvitesse m = self.motors if d: rb(m[0],v) rb(m[3],v) else: rb(m[1],v) rb(m[2],v) def sd(self,v): rb = driver().setvitesse m = self.motors rb(m[0],v) rb(m[3],v) rb(m[1],v*-1) rb(m[2],v*-1) def Rotation(self,v): m = self.motors rb = driver().setvitesse rb(m[0],v) rb(m[1],v) rb(m[2],v*-1) rb(m[3],v*-1) Translation = Translation() Translation.init(motors) """ r = Robot() r.Translation.droit(1) r.Translation.trv(2,True) r.Translation.sd(5) r.Translation.sd(-5) r.Rotation(5) r.Rotation(-5) """