-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinits.py
45 lines (37 loc) · 1.66 KB
/
inits.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
"""
Inits wpilib objects
"""
import wpilib
from map import Map
class Component(object):
def __init__(self):
# Mapping object stores port numbers for all connected motors, sensors, and joysticks. See map.py.
Mapping = Map()
# Init drivetrain
self.driveTrain = [wpilib.Spark(Mapping.frontLeftM),
wpilib.Spark(Mapping.frontRightM),
wpilib.Spark(Mapping.backLeftM),
wpilib.Spark(Mapping.backRightM)]
self.driveTrain[0].setInverted(True)
self.driveTrain[2].setInverted(True)
# Init motors
self.elevatorM = wpilib.Spark(Mapping.elevatorM)
self.elevatorM.setInverted(True)
#self.winchM = wpilib.Spark(Mapping.winchM)
self.intakeM = wpilib.Spark(Mapping.intakeM)
self.jawsM = wpilib.Spark(Mapping.jawsM)
self.backLift = wpilib.Spark(Mapping.backLift)
self.frontLift = wpilib.Spark(Mapping.frontLift)
self.backWheel = wpilib.Spark(Mapping.backWheel)
# Soleniods
self.jawsSol = wpilib.DoubleSolenoid(Mapping.jawsSol['out'], Mapping.jawsSol['in'])
# Init sensors
self.gyroS = wpilib.AnalogGyro(Mapping.gyroS)
self.elevatorLimitS = wpilib.DigitalInput(Mapping.elevatorLimitS)
self.jawsLimitS = wpilib.DigitalInput(Mapping.jawsLimitS)
self.metaboxLimitS = wpilib.DigitalInput(Mapping.metaboxLimitS)
# Encoders
self.elevatorEncoderS = wpilib.Encoder(7, 8, True)
self.elevatorEncoderS.setDistancePerPulse(0.08078)
self.driveYEncoderS = wpilib.Encoder(2, 3)
self.driveYEncoderS.setDistancePerPulse(0.015708)