-
Notifications
You must be signed in to change notification settings - Fork 0
/
oil_supporter.py
78 lines (61 loc) · 1.92 KB
/
oil_supporter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import math
import os
import time
from pybricks.ev3devices import (ColorSensor, GyroSensor, InfraredSensor,
Motor, TouchSensor, UltrasonicSensor)
from pybricks.hubs import EV3Brick
from pybricks.media.ev3dev import Font, ImageFile, SoundFile
from pybricks.parameters import Button, Color, Direction, Port, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import DataLog, StopWatch, wait
import linefollow
from common import *
from gyrostraight import *
from gyroturno import *
from pidlinefollow import *
#
# Mission goals:
# -> Mechanically allign between oil plant and energy storage
# -> Pump oil three times
# -> Hook oil truck and drive home
#
def main():
get_to_oil()
pump_oil()
hookcart_gohome()
def get_to_oil():
#set acceleration
acceleration("distance", 20)
acceleration("heading", 20)
#reset gyro against wall
gyro.reset_angle(angle=0)
#get behind oil
gyro_straight(distance=200, reset_angle=30, speed=200, GCV=2.5/2)
gyro_straight(distance=300, reset_angle=0, speed=200, GCV=2.5/2)
#mechanically allign between oil plant and energy storage. (push into oil)
gyro_straight(speed=300, reset_angle=0, target_time = 2.0)
def pump_oil():
#faster acceleration
acceleration("distance", 100)
acceleration("heading", 100)
#pump oil 3 times
for _ in range(3):
#back out of oil
gyro_straight(distance=45, reset_angle=0, speed=-100)
gyro_stop()
#slight turn towards oil
robot.turn(5)
#push into oil and wait
robot.drive(speed=400, turn_rate=0)
time.sleep(0.75)
gyro_stop()
def hookcart_gohome():
#slower acceleration
acceleration("distance", 37)
acceleration("heading", 30)
#back up and go home
gyro_straight(distance=200, speed=-200)
robot.drive(speed=-300, turn_rate=25)
time.sleep(2)
robot.stop()
gyro_stop()