1 package org
.usfirst
.frc
.team3501
.robot
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Defense
;
4 import org
.usfirst
.frc
.team3501
.robot
.commands
.shooter
.ResetCatapult
;
5 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DefenseArm
;
6 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.DriveTrain
;
7 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.IntakeArm
;
8 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Scaler
;
9 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
11 import edu
.wpi
.first
.wpilibj
.I2C
;
12 import edu
.wpi
.first
.wpilibj
.I2C
.Port
;
13 import edu
.wpi
.first
.wpilibj
.IterativeRobot
;
14 import edu
.wpi
.first
.wpilibj
.command
.Scheduler
;
15 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SendableChooser
;
16 import edu
.wpi
.first
.wpilibj
.smartdashboard
.SmartDashboard
;
18 public class Robot
extends IterativeRobot
{
20 public static DriveTrain driveTrain
;
21 public static Shooter shooter
;
23 public static Scaler scaler
;
25 public static IntakeArm intakeArm
;
26 public static DefenseArm defenseArm
;
28 static I2C Wire
= new I2C(Port
.kOnboard
, 42);
30 // Sendable Choosers send a drop down menu to the Smart Dashboard.
31 SendableChooser positionChooser
;
32 SendableChooser positionOneDefense
, positionTwoDefense
, positionThreeDefense
,
33 positionFourDefense
, positionFiveDefense
;
36 public void robotInit() {
37 driveTrain
= new DriveTrain();
40 shooter
= new Shooter();
41 scaler
= new Scaler();
42 intakeArm
= new IntakeArm();
44 initializeSendableChoosers();
45 addPositionChooserOptions();
46 addDefensesToAllDefenseSendableChoosers();
47 sendSendableChoosersToSmartDashboard();
51 private void initializeSendableChoosers() {
52 positionChooser
= new SendableChooser();
53 positionOneDefense
= new SendableChooser();
54 positionTwoDefense
= new SendableChooser();
55 positionThreeDefense
= new SendableChooser();
56 positionFourDefense
= new SendableChooser();
57 positionFiveDefense
= new SendableChooser();
60 private void addPositionChooserOptions() {
61 positionChooser
.addDefault("Position 1", 1);
62 positionChooser
.addObject("Position 2", 2);
63 positionChooser
.addObject("Position 3", 3);
64 positionChooser
.addObject("Position 4", 4);
65 positionChooser
.addObject("Position 5", 5);
68 private void addDefensesToAllDefenseSendableChoosers() {
69 addDefenseOptions(positionOneDefense
);
70 addDefenseOptions(positionTwoDefense
);
71 addDefenseOptions(positionThreeDefense
);
72 addDefenseOptions(positionFourDefense
);
73 addDefenseOptions(positionFiveDefense
);
76 private void addDefenseOptions(SendableChooser chooser
) {
77 chooser
.addDefault("Portcullis", Defense
.PORTCULLIS
);
78 chooser
.addObject("Sally Port", Defense
.SALLY_PORT
);
79 chooser
.addObject("Rough Terrain", Defense
.ROUGH_TERRAIN
);
80 chooser
.addObject("Low Bar", Defense
.LOW_BAR
);
81 chooser
.addObject("Cheval De Frise", Defense
.CHEVAL_DE_FRISE
);
82 chooser
.addObject("Drawbridge", Defense
.DRAWBRIDGE
);
83 chooser
.addObject("Moat", Defense
.MOAT
);
84 chooser
.addObject("Rock Wall", Defense
.ROCK_WALL
);
87 private void sendSendableChoosersToSmartDashboard() {
88 SmartDashboard
.putData("PositionChooser", positionChooser
);
89 SmartDashboard
.putData("Position One Defense Chooser", positionOneDefense
);
90 SmartDashboard
.putData("Position Two Defense Chooser", positionTwoDefense
);
91 SmartDashboard
.putData("Position Three Defense Chooser",
92 positionThreeDefense
);
93 SmartDashboard
.putData("Position Four Defense Chooser",
95 SmartDashboard
.putData("Position Five Defense Chooser",
98 SmartDashboard
.putData("Position Four Defense Chooser",
100 SmartDashboard
.putData("Position Five Defense Chooser",
101 positionFiveDefense
);
103 shooter
= new Shooter();
108 public void autonomousInit() {
109 Scheduler
.getInstance().run();
111 // get options chosen from drop down menu
112 Integer chosenPosition
= (Integer
) positionChooser
.getSelected();
113 Integer chosenDefense
= 0;
115 if (chosenPosition
== 1)
116 chosenDefense
= (Integer
) positionOneDefense
.getSelected();
117 else if (chosenPosition
== 2)
118 chosenDefense
= (Integer
) positionTwoDefense
.getSelected();
119 else if (chosenPosition
== 3)
120 chosenDefense
= (Integer
) positionThreeDefense
.getSelected();
121 else if (chosenPosition
== 4)
122 chosenDefense
= (Integer
) positionFourDefense
.getSelected();
123 else if (chosenPosition
== 5)
124 chosenDefense
= (Integer
) positionFiveDefense
.getSelected();
126 System
.out
.println("Chosen Position: " + chosenPosition
);
127 System
.out
.println("Chosen Defense: " + chosenDefense
);
131 public void autonomousPeriodic() {
132 Scheduler
.getInstance().run();
136 public void teleopInit() {
137 Scheduler
.getInstance().add(new ResetCatapult()); // Reset catapult at start
142 public void teleopPeriodic() {
143 Scheduler
.getInstance().run();
144 String WriteString
= "go";
145 char[] CharArray
= WriteString
.toCharArray();
146 byte[] WriteData
= new byte[CharArray
.length
];
147 for (int i
= 0; i
< CharArray
.length
; i
++) {
148 WriteData
[i
] = (byte) CharArray
[i
];
150 Wire
.transaction(WriteData
, WriteData
.length
, null, 0);