# We use a config.json file to manage the robot and a lot of stuff like limits or offsets on the motors with closing(pypot.robot.from_json('config.json')) as megabot: for m in megabot.motors: m.compliant = False #Initialisation of the differents legs of the robot leg1 = corrected_leg(megabot.leg1, 0) leg2 = corrected_leg(megabot.leg2, -65) leg3 = corrected_leg(megabot.leg3, -115) leg4 = corrected_leg(megabot.leg4, -180) leg5 = corrected_leg(megabot.leg5, 115) leg6 = corrected_leg(megabot.leg6, 65) #Initialisation of the robot robot = corrected_robot([leg1, leg2, leg3, leg4, leg5, leg6], [leg1, leg3, leg5], [leg2, leg4, leg6]) #Initialisation of all the running variables robot.goto([0, 0, 0]) #Position Continue = True #Do we have to continu ? Gaz = False #Deplacement circle = False #Rotation Joy_X_Axis = 0 Joy_Y_Axis = 0 Speed_Axis = 0.0 # Throttle axis Alt_Axis = 0 while Continue: if Is_Joystick: Joy_X_Axis = joystick.get_axis(0) Joy_Y_Axis = joystick.get_axis(1) Abs_Speed_Axis = joystick.get_axis(2)
#On va maintenant utiliser un fichier de configuration #Il nous permettra de limiter nos demandes aux angles valides with closing(pypot.robot.from_json('config.json')) as megabot: for m in megabot.motors : m.compliant = False; leg1 = corrected_leg(megabot.leg1, 0) leg2 = corrected_leg(megabot.leg2, -90) leg3 = corrected_leg(megabot.leg3, -90) leg4 = corrected_leg(megabot.leg4, -180) leg5 = corrected_leg(megabot.leg5, 90) leg6 = corrected_leg(megabot.leg6, 90) robot = corrected_robot([leg1, leg2, leg3, leg4, leg5, leg6]) robot.goto([0, 0]) continuer = 1 gaz=False while continuer: for event in pygame.event.get(): #Attente des evenements if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE): continuer = 0 if event.type == MOUSEMOTION: #Si mouvement de souris #On change les coordonnees du Reticule Reticulte_x = event.pos[0]-L_Reticule/2 Reticulte_y = event.pos[1]-H_Reticule/2 if event.type == MOUSEBUTTONDOWN or (event.type == KEYDOWN and event.key == K_SPACE) : gaz = not(gaz) if gaz == 1 :
# We use a config.json file to manage the robot and a lot of stuff like limits or offsets on the motors with closing(pypot.robot.from_json('config.json')) as megabot: for m in megabot.motors : m.compliant = False; #Initialisation of the differents legs of the robot leg1 = corrected_leg(megabot.leg1, 0) leg2 = corrected_leg(megabot.leg2, -65) leg3 = corrected_leg(megabot.leg3, -115) leg4 = corrected_leg(megabot.leg4, -180) leg5 = corrected_leg(megabot.leg5, 115) leg6 = corrected_leg(megabot.leg6, 65) #Initialisation of the robot robot = corrected_robot([leg1, leg2, leg3, leg4, leg5, leg6], [leg1, leg3, leg5], [leg2, leg4, leg6]) #Initialisation of all the running variables robot.goto([0, 0, 0]) #Position Continue = True #Do we have to continu ? Gaz=False #Deplacement circle = False #Rotation Joy_X_Axis = 0 Joy_Y_Axis = 0 Speed_Axis = 0.0 # Throttle axis Alt_Axis = 0 while Continue: if Is_Joystick : Joy_X_Axis = joystick.get_axis(0) Joy_Y_Axis = joystick.get_axis(1) Abs_Speed_Axis = joystick.get_axis(2)
#On va maintenant utiliser un fichier de configuration #Il nous permettra de limiter nos demandes aux angles valides with closing(pypot.robot.from_json('config.json')) as megabot: for m in megabot.motors: m.compliant = False leg1 = corrected_leg(megabot.leg1, 0) leg2 = corrected_leg(megabot.leg2, -90) leg3 = corrected_leg(megabot.leg3, -90) leg4 = corrected_leg(megabot.leg4, -180) leg5 = corrected_leg(megabot.leg5, 90) leg6 = corrected_leg(megabot.leg6, 90) robot = corrected_robot([leg1, leg2, leg3, leg4, leg5, leg6]) robot.goto([0, 0]) continuer = 1 gaz = False while continuer: for event in pygame.event.get(): #Attente des evenements if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE): continuer = 0 if event.type == MOUSEMOTION: #Si mouvement de souris #On change les coordonnees du Reticule Reticulte_x = event.pos[0] - L_Reticule / 2 Reticulte_y = event.pos[1] - H_Reticule / 2 if event.type == MOUSEBUTTONDOWN or (event.type == KEYDOWN and event.key == K_SPACE): gaz = not (gaz)