-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import math | ||
import time | ||
|
||
from robot.robot_r2 import Robot | ||
|
||
|
||
# Fermé/ouvert | ||
# pince 1 : 10, 120 pince gauche id=0 | ||
# pince 2 : 175, 60 pince droite id=1 il vz dans le mauvais sens | ||
# pont levis : 70, 25 id = 2 (PWM13) | ||
def dist_to_time(distance: float): # la distance est exprimé en mm et le temps en secondes | ||
return distance / 131 | ||
|
||
|
||
async def run(robot: Robot): | ||
robot.arduino.send("R2+set_led_color=green") | ||
await robot.movement.async_forward(speed=100, duration=dist_to_time(570)) # étape 1 | ||
await robot.movement.async_turn_right(speed=100, duration=1.45) # étape 2 | ||
# ouverture pince | ||
robot.servos.set_servo_angle(0, 120) | ||
robot.servos.set_servo_angle(1, 60) | ||
await robot.movement.async_forward(speed=100, duration=dist_to_time(830)) # etape3 TODO | ||
# robot.servos.set_servo_angle(0, 120) | ||
# robot.servos.set_servo_angle(1, 60) | ||
await robot.movement.async_move(direction=math.pi / 2, turn=1, speed=100, duration=2.5) # Etape4 | ||
# await robot.movement.async_turn_right(speed=100, duration=1.40) | ||
await robot.movement.async_forward(speed=100, duration=dist_to_time(350)) # Etape 5 | ||
await robot.movement.async_turn_left(speed=100, duration=1.3) # Etape 6 | ||
await robot.movement.async_forward(speed=100, duration=dist_to_time(200)) # Etape 7 | ||
await robot.movement.async_backward(speed=100, duration=dist_to_time(150)) # Etape 8 | ||
# fermeture pince | ||
robot.servos.set_servo_angle(0, 10) | ||
robot.servos.set_servo_angle(1, 175) | ||
await robot.movement.async_turn_left(speed=100, duration=1.6) # Etape 9 | ||
await robot.movement.async_forward(speed=100, duration=dist_to_time(270)) # Etape 10 | ||
await robot.movement.async_right(speed=100, duration=dist_to_time(670), stop_ir_after=0) # Etape 11 | ||
await robot.movement.async_backward(speed=100, duration=dist_to_time(350), stop_ir_after=0) # Etape 12 | ||
await robot.movement.async_right(speed=100, duration=dist_to_time(50), stop_ir_after=0) # tape contre la paroie #Etape 13 | ||
# Cerise | ||
robot.servos.set_servo_angle(2, 70) | ||
time.sleep(0.5) | ||
robot.servos.set_servo_angle(2, 25) | ||
time.sleep(2.5) | ||
await robot.movement.async_right(speed=100, duration=dist_to_time(100), stop_ir_after=0) | ||
time.sleep(2.5) | ||
robot.servos.set_servo_angle(2, 70) | ||
time.sleep(0.5) | ||
|
||
await robot.movement.async_forward(speed=100, duration=dist_to_time(380)) # Etape 14 | ||
await robot.movement.async_left(speed=100, duration=dist_to_time(1650), stop_ir_after=11.5) # Etape 15#156cm de déplacement | ||
await robot.movement.async_backward(speed=100, duration=dist_to_time(450)) # Etape 16 | ||
|
||
robot.score = 49 # TODO estimation | ||
|
||
robot.servos.set_servo_angle(0, 10) | ||
robot.servos.set_servo_angle(1, 175) | ||
robot.servos.set_servo_angle(2, 70) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters