-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobot.py
50 lines (39 loc) · 1.46 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
import wpilib
import time
import threading
from queue import Queue
from wpilib import Preferences
class MyRobot(wpilib.SampleRobot):
def __init__(self):
super().__init__()
import config
self.hid_sp = config.hid_sp
self.ds = config.ds
self.navx = config.navx
self.achange_motor = config.pickup_achange_motor2
def disabled(self):
while self.isDisabled():
tinit = time.time()
self.hid_sp.poll()
print("Pitch: " , self.navx.pitch, "Roll: ", self.navx.roll, "Yaw: ", self.navx.yaw, "Compass heading: ", self.navx.compass_heading, "Fused heading: ", self.navx.fused_heading)
# print("Pitch: " , self.navx.pitch)
# print("Roll: ", self.navx.roll)
# print("Yaw: ", self.navx.yaw)
# print("Compass heading: ", self.navx.compass_heading)
# print("Fused heading: ", self.navx.fused_heading)
self.safeSleep(tinit, .04)
def autonomous(self):
pass
def operatorControl(self):
while self.isOperatorControl() and self.isEnabled():
tinit = time.time()
self.hid_sp.poll()
self.safeSleep(tinit, .04)
def safeSleep(self, tinit, duration):
tdif = .04 - (time.time() - tinit)
if tdif > 0:
time.sleep(tdif)
if tdif <= 0:
print("Code running slowly!")
if __name__ == "__main__":
wpilib.run(MyRobot)