forked from isubsmith/rc2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot.py
81 lines (63 loc) · 2.5 KB
/
robot.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
79
80
81
from os.path import dirname, basename
from subsystems.turret import Turret
from wpilib import Joystick, run, TimedRobot
from wpilib import TimedRobot, run
from controllers import DriverController, ShooterController
from subsystems import Chassis, Turret, Autonomous, Magazine
from hardware import ADXRS450
from tools import Timer
from constants import kS, kV, TRACKWIDTH, TURRET_SHOOT_MOTORS
from wpilib.trajectory import TrajectoryUtil
from glob import glob as files
filenames = files(dirname(__file__) + "/paths/*.json")
try:
filenames.sort(key=lambda filename: int(basename(filename).split(".")[0]))
except:
raise Exception(
"Files in `path` folder MUST follow 'INTEGER.*.json' pattern, where `INTEGER` is any integer value")
print("Path filenames are:", filenames)
trajectories = list(
map(TrajectoryUtil.fromPathweaverJson, filenames))
@run
class Kthugdess(TimedRobot):
def robotInit(self):
# self.chassis = Chassis()
self.turret = Turret()
# self.gyro = ADXRS450()
# Add it in when it's ready! Also, don't forget the CAN ids.
# self.mag = Magazine()
self.controller = DriverController(0)
# self.test = None
# self.chassis.reset_encoders()
# self.auto = Autonomous(kS, kV, TRACKWIDTH, trajectories)
# self.reset()
# def reset(self):
# self.auto.reset()
# self.auto.start(self.chassis, self.gyro)
# autonomousInit = reset
# teleopInit = reset
# def autonomousPeriodic(self):
# if self.auto.is_paused():
# print("SHOOT")
# self.auto.resume(self.chassis, self.gyro)
# elif not self.auto.is_done():
# self.auto.update(self.chassis, self.gyro)
def teleopPeriodic(self):
# self.chassis.arcade_drive(-self.controller.forward(),
# self.controller.turn())
self.turret.update()
# if self.controller.shoot():
# self.turret.shoot()
# else:
# self.turret.idle()
# self.singulator.update(self.turret.at_full_speed())
# else:
# self.turret.stop_shooting()
# self.singulator.stop_all_motors()
# if self.controller.intake():
# self.singulator.run_intake()
# No need to put in an else because we will get all the balls and then stop all motors after shooting.
'''if self.controller.shift():
self.chassis.set_high_gear()
else:
self.chassis.set_low_gear()'''