successfully open and close client socket after deploying
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / Robot.java
CommitLineData
38a404b3
KZ
1package org.usfirst.frc.team3501.robot;
2
20ac8fc8
CZ
3import java.io.DataInputStream;
4import java.io.DataOutputStream;
56e995e6 5import java.io.IOException;
266eb93e 6import java.net.ServerSocket;
56e995e6 7
53d61b3e 8import org.usfirst.frc.team3501.robot.Constants.Defense;
2947642e 9import org.usfirst.frc.team3501.robot.subsystems.DefenseArm;
047383c3 10import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
e47f0862 11import org.usfirst.frc.team3501.robot.subsystems.IntakeArm;
02cb494e 12import org.usfirst.frc.team3501.robot.subsystems.Scaler;
40348cab
E
13import org.usfirst.frc.team3501.robot.subsystems.Shooter;
14
38a404b3
KZ
15import edu.wpi.first.wpilibj.IterativeRobot;
16import edu.wpi.first.wpilibj.command.Scheduler;
3366a59a
ME
17import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
18import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
38a404b3
KZ
19
20public class Robot extends IterativeRobot {
21 public static OI oi;
22 public static DriveTrain driveTrain;
40348cab 23 public static Shooter shooter;
2c9f5abb 24
02cb494e 25 public static Scaler scaler;
c97fbce2 26
a96fa926 27 public static IntakeArm intakeArm;
200caf63 28 public static DefenseArm defenseArm;
38a404b3 29
88e66b4e 30 // Sendable Choosers send a drop down menu to the Smart Dashboard.
3366a59a 31 SendableChooser positionChooser;
6947c8a4 32 SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
20ac8fc8 33 positionFourDefense, positionFiveDefense;
56e995e6 34
266eb93e 35 ServerSocket roboRIO;
20ac8fc8
CZ
36 DataInputStream beagleBoneInput;
37 DataOutputStream beagleBoneOutput;
38 DataInputStream roboRIOInput;
39 DataOutputStream roboRIOOutput;
3366a59a 40
38a404b3
KZ
41 @Override
42 public void robotInit() {
56e995e6 43 try {
266eb93e
CZ
44 roboRIO = new ServerSocket(1024);
45 System.out.println("successfully opened");
20ac8fc8
CZ
46 // // create input stream for beagle bone to receive response from roboRIO
47 // roboRIOInput = new DataInputStream(roboRIO.getInputStream());
48 // // create output stream to send information to the server socket
49 // roboRIOOutput = new DataOutputStream(roboRIO.getOutputStream());
50
266eb93e
CZ
51 roboRIO.close();
52 System.out.println("successfully closed");
20ac8fc8
CZ
53 } catch (IOException e) {
54 System.out.println(e);
55 }
3366a59a 56
20ac8fc8
CZ
57 // driveTrain = new DriveTrain();
58 // oi = new OI();
59 //
60 // shooter = new Shooter();
61 // scaler = new Scaler();
62 // intakeArm = new IntakeArm();
63 //
64 // initializeSendableChoosers();
65 // addPositionChooserOptions();
66 // addDefensesToAllDefenseSendableChoosers();
67 // sendSendableChoosersToSmartDashboard();
9742fe2e 68
3366a59a
ME
69 }
70
6947c8a4
ME
71 private void initializeSendableChoosers() {
72 positionChooser = new SendableChooser();
73 positionOneDefense = new SendableChooser();
74 positionTwoDefense = new SendableChooser();
75 positionThreeDefense = new SendableChooser();
76 positionFourDefense = new SendableChooser();
77 positionFiveDefense = new SendableChooser();
78 }
79
29d59f48
ME
80 private void addPositionChooserOptions() {
81 positionChooser.addDefault("Position 1", 1);
82 positionChooser.addObject("Position 2", 2);
83 positionChooser.addObject("Position 3", 3);
84 positionChooser.addObject("Position 4", 4);
85 positionChooser.addObject("Position 5", 5);
86 }
87
9742fe2e 88 private void addDefensesToAllDefenseSendableChoosers() {
29d59f48
ME
89 addDefenseOptions(positionOneDefense);
90 addDefenseOptions(positionTwoDefense);
91 addDefenseOptions(positionThreeDefense);
92 addDefenseOptions(positionFourDefense);
93 addDefenseOptions(positionFiveDefense);
94 }
95
96 private void addDefenseOptions(SendableChooser chooser) {
3366a59a
ME
97 chooser.addDefault("Portcullis", Defense.PORTCULLIS);
98 chooser.addObject("Sally Port", Defense.SALLY_PORT);
99 chooser.addObject("Rough Terrain", Defense.ROUGH_TERRAIN);
100 chooser.addObject("Low Bar", Defense.LOW_BAR);
101 chooser.addObject("Cheval De Frise", Defense.CHEVAL_DE_FRISE);
102 chooser.addObject("Drawbridge", Defense.DRAWBRIDGE);
103 chooser.addObject("Moat", Defense.MOAT);
104 chooser.addObject("Rock Wall", Defense.ROCK_WALL);
38a404b3
KZ
105 }
106
29d59f48
ME
107 private void sendSendableChoosersToSmartDashboard() {
108 SmartDashboard.putData("PositionChooser", positionChooser);
109 SmartDashboard.putData("Position One Defense Chooser", positionOneDefense);
110 SmartDashboard.putData("Position Two Defense Chooser", positionTwoDefense);
111 SmartDashboard.putData("Position Three Defense Chooser",
112 positionThreeDefense);
e23bfd98
E
113 SmartDashboard.putData("Position Four Defense Chooser",
114 positionFourDefense);
115 SmartDashboard.putData("Position Five Defense Chooser",
116 positionFiveDefense);
d06ee698 117
e23bfd98
E
118 SmartDashboard.putData("Position Four Defense Chooser",
119 positionFourDefense);
120 SmartDashboard.putData("Position Five Defense Chooser",
121 positionFiveDefense);
122
123 shooter = new Shooter();
d06ee698 124
29d59f48
ME
125 }
126
38a404b3
KZ
127 @Override
128 public void autonomousInit() {
3366a59a
ME
129 Scheduler.getInstance().run();
130
20ac8fc8
CZ
131 // // get options chosen from drop down menu
132 // Integer chosenPosition = (Integer) positionChooser.getSelected();
133 // Integer chosenDefense = 0;
134 //
135 // if (chosenPosition == 1)
136 // chosenDefense = (Integer) positionOneDefense.getSelected();
137 // else if (chosenPosition == 2)
138 // chosenDefense = (Integer) positionTwoDefense.getSelected();
139 // else if (chosenPosition == 3)
140 // chosenDefense = (Integer) positionThreeDefense.getSelected();
141 // else if (chosenPosition == 4)
142 // chosenDefense = (Integer) positionFourDefense.getSelected();
143 // else if (chosenPosition == 5)
144 // chosenDefense = (Integer) positionFiveDefense.getSelected();
145 //
146 // System.out.println("Chosen Position: " + chosenPosition);
147 // System.out.println("Chosen Defense: " + chosenDefense);
38a404b3
KZ
148 }
149
150 @Override
151 public void autonomousPeriodic() {
152 Scheduler.getInstance().run();
38a404b3
KZ
153 }
154
155 @Override
156 public void teleopInit() {
157 }
158
159 @Override
160 public void teleopPeriodic() {
161 Scheduler.getInstance().run();
1e039ebd
E
162 }
163
38a404b3 164}