-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobot.java
More file actions
193 lines (164 loc) · 6.51 KB
/
Robot.java
File metadata and controls
193 lines (164 loc) · 6.51 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc.robot;
import edu.wpi.cscore.HttpCamera;
import edu.wpi.cscore.UsbCamera;
import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.commands.autons.CrossLineAuton;
import frc.robot.commands.autons.MoveToHeadingAuton;
import frc.robot.subsystems.Climber;
import frc.robot.subsystems.Drive;
import frc.robot.subsystems.Intake;
import frc.robot.subsystems.Winch;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the TimedRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the build.gradle file in the
* project.
*/
public class Robot extends TimedRobot {
public static Drive drive;
public static Intake intake;
public static Winch winch;
public static Climber climber;
public static OI m_oi;
Command m_autonomousCommand;
SendableChooser<Command> m_chooser = new SendableChooser<>();
Command autoCommand;
Compressor compressor;
/*
* public static UsbCamera CAMERA0; public static UsbCamera CAMERA1; public
* static VideoSink SERVER;
*/
private HttpCamera limelightFeed;
UsbCamera camera;
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
@Override
public void robotInit() {
//Camera
//camera = CameraServer.getInstance().startAutomaticCapture();
climber = new Climber(RobotMap.climber, RobotMap.climber2);
m_oi = new OI();
drive = new Drive(RobotMap.left1, RobotMap.left2, RobotMap.right1, RobotMap.right2, RobotMap.driveShifter);
winch = new Winch(RobotMap.winch, RobotMap.winchUpperSwitch, RobotMap.winchLowerSwitch);
intake = new Intake(RobotMap.intake);
// chooser.addOption("My Auto", new MyAutoCommand());
SmartDashboard.putData("Auto mode", m_chooser);
compressor = new Compressor(0);
compressor.setClosedLoopControl(true);
compressor.start();
// Display limelight stuff on shuffleboard
NetworkTableInstance.getDefault().getTable("limelight").getEntry("pipeline").setNumber(0);
NetworkTableInstance.getDefault().getTable("limelight").getEntry("ledMode").setNumber(0);
NetworkTableInstance.getDefault().getTable("limelight").getEntry("camMode").setNumber(0);
/*
* ShuffleboardTab driverShuffleboardTab = Shuffleboard.getTab("ll stream");
* limelightFeed = new HttpCamera("limelight",
* "http://limelight.local:5800/stream.mjpg");
* driverShuffleboardTab.add("ll stream", limelightFeed).withPosition(0,
* 0).withSize(15, 8);
*/
//m_chooser.addOption("Move To Heading", new MoveToHeadingAuton(drive, RobotMap.cameraServo, RobotMap.ultrasonicSensor, winch));
SmartDashboard.putData("Auto mode", m_chooser);
m_chooser.addOption("Move To Heading", new MoveToHeadingAuton(drive, RobotMap.ultrasonicSensor, winch));
m_chooser.addOption("Cross Line", new CrossLineAuton(drive, winch));
m_oi.init();
//autoCommand = new MoveToHeadingAuton(drive, RobotMap.ultrasonicSensor, winch);
}
/**
* This function is called every robot packet, no matter the mode. Use
* this for items like diagnostics that you want ran during disabled,
* autonomous, teleoperated and test.
*
* <p>This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.
*/
@Override
public void robotPeriodic() {
}
/**
* This function is called once each time the robot enters Disabled mode.
* You can use it to reset any subsystem information you want to clear when
* the robot is disabled.
*/
@Override
public void disabledInit() {
compressor.stop();
}
@Override
public void disabledPeriodic() {
Scheduler.getInstance().run();
}
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString code to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional commands to the
* chooser code above (like the commented example) or additional comparisons
* to the switch structure below with additional strings & commands.
*/
@Override
public void autonomousInit() {
m_autonomousCommand = m_chooser.getSelected();
/*
* String autoSelected = SmartDashboard.getString("Auto Selector",
* "Default"); switch(autoSelected) { case "My Auto": autonomousCommand
* = new MyAutoCommand(); break; case "Default Auto": default:
* autonomousCommand = new ExampleCommand(); break; }
*/
// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.start();
}
compressor.start();
}
/**
* This function is called periodically during autonomous.
*/
@Override
public void autonomousPeriodic() {
Scheduler.getInstance().run();
}
@Override
public void teleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
}
compressor.start();
}
/**
* This function is called periodically during operator control.
*/
@Override
public void teleopPeriodic() {
Scheduler.getInstance().run();
}
/**
* This function is called periodically during test mode.
*/
@Override
public void testPeriodic() {
}
}