Skip to content

Commit e6f7a9d

Browse files
committed
multiple CAN buses are a thing now
1 parent 480ed4d commit e6f7a9d

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

CANPDP/robot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def robotInit(self):
1919
"""Robot initialization function"""
2020

2121
# Object for dealing with the Power Distribution Panel (PDP).
22-
self.pdp = wpilib.PowerDistribution()
22+
self.pdp = wpilib.PowerDistribution(0)
2323

2424
# Put the PDP itself to the dashboard
2525
wpilib.SmartDashboard.putData("PDP", self.pdp)

GameData/robot.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import wpilib
99
import ntcore
1010

11+
CAN_BUS = 0
1112
PNUE_MOD_TYPE = wpilib.PneumaticsModuleType.CTREPCM
1213

1314

@@ -18,10 +19,10 @@ class MyRobot(wpilib.TimedRobot):
1819

1920
def robotInit(self):
2021
# A way of demonstrating the difference between the game data strings
21-
self.blue = wpilib.Solenoid(PNUE_MOD_TYPE, 0)
22-
self.red = wpilib.Solenoid(PNUE_MOD_TYPE, 1)
23-
self.green = wpilib.Solenoid(PNUE_MOD_TYPE, 2)
24-
self.yellow = wpilib.Solenoid(PNUE_MOD_TYPE, 3)
22+
self.blue = wpilib.Solenoid(CAN_BUS, PNUE_MOD_TYPE, 0)
23+
self.red = wpilib.Solenoid(CAN_BUS, PNUE_MOD_TYPE, 1)
24+
self.green = wpilib.Solenoid(CAN_BUS, PNUE_MOD_TYPE, 2)
25+
self.yellow = wpilib.Solenoid(CAN_BUS, PNUE_MOD_TYPE, 3)
2526
# Set game data to empty string by default
2627
self.gameData = ""
2728
# Get the SmartDashboard table from networktables

HatchbotInlined/subsystems/hatchsubsystem.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ def __init__(self) -> None:
1616
super().__init__()
1717

1818
self.hatchSolenoid = wpilib.DoubleSolenoid(
19+
0,
1920
constants.kHatchSolenoidModule,
2021
constants.kHatchSolenoidModuleType,
21-
*constants.kHatchSolenoidPorts
22+
*constants.kHatchSolenoidPorts,
2223
)
2324

2425
def grabHatch(self) -> commands2.Command:

HatchbotTraditional/subsystems/hatchsubsystem.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ def __init__(self) -> None:
1515
super().__init__()
1616

1717
self.hatchSolenoid = wpilib.DoubleSolenoid(
18+
0,
1819
constants.kHatchSolenoidModule,
1920
constants.kHatchSolenoidModuleType,
20-
*constants.kHatchSolenoidPorts
21+
*constants.kHatchSolenoidPorts,
2122
)
2223

2324
def grabHatch(self) -> None:

Solenoid/robot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@ def robotInit(self):
2828
# Solenoid corresponds to a single solenoid.
2929
# In this case, it's connected to channel 0 of a PH with the default CAN ID.
3030
self.solenoid = wpilib.Solenoid(
31-
moduleType=wpilib.PneumaticsModuleType.REVPH, channel=0
31+
busId=0, moduleType=wpilib.PneumaticsModuleType.REVPH, channel=0
3232
)
3333

3434
# DoubleSolenoid corresponds to a double solenoid.
3535
# In this case, it's connected to channels 1 and 2 of a PH with the default CAN ID.
3636
self.doubleSolenoid = wpilib.DoubleSolenoid(
37+
busId=0,
3738
moduleType=wpilib.PneumaticsModuleType.REVPH,
3839
forwardChannel=1,
3940
reverseChannel=2,
4041
)
4142

4243
# Compressor connected to a PH with a default CAN ID (1)
43-
self.compressor = wpilib.Compressor(wpilib.PneumaticsModuleType.REVPH)
44+
self.compressor = wpilib.Compressor(0, wpilib.PneumaticsModuleType.REVPH)
4445

4546
self.kSolenoidButton = 1
4647
self.kDoubleSolenoidForwardButton = 2

0 commit comments

Comments
 (0)