-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobot.java
More file actions
97 lines (88 loc) · 3.02 KB
/
Robot.java
File metadata and controls
97 lines (88 loc) · 3.02 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
package org.usfirst.frc.team5941.robot;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.VictorSP;
import edu.wpi.first.wpilibj.XboxController;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class Robot extends IterativeRobot {
final String defaultAuto = "Default";
final String customAuto = "My Auto";
String autoSelected;
SendableChooser<String> chooser = new SendableChooser<>();
VictorSP leftSide = new VictorSP(0);
VictorSP rightSide = new VictorSP(1);
VictorSP ballIntake = new VictorSP(9);
VictorSP leftSideB = new VictorSP(2);
VictorSP rightSideB = new VictorSP(3);
VictorSP ballShooter = new VictorSP(8);
XboxController xbox = new XboxController(0);
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
@Override
public void robotInit() {
chooser.addDefault("Default Auto", defaultAuto);
chooser.addObject("My Auto", customAuto);
SmartDashboard.putData("Auto choices", chooser);
}
/**
* 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 line to get the auto name from the text box below the Gyro
*
* You can add additional auto modes by adding additional comparisons to the
* switch structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*/
@Override
public void autonomousInit() {
autoSelected = chooser.getSelected();
// autoSelected = SmartDashboard.getString("Auto Selector",
// defaultAuto);
System.out.println("Auto selected: " + autoSelected);
}
/**
* This function is called periodically during autonomous
*/
@Override
public void autonomousPeriodic() {
switch (autoSelected) {
case customAuto:
// Put custom auto code here
break;
case defaultAuto:
default:
// Put default auto code here
break;
}
}
/**
* This function is called periodically during operator control
This makes the buttons on the controller do the controlling.
*/
@Override
public void teleopPeriodic() {
leftSide.set(-xbox.getRawAxis(1) * 0.2);
rightSide.set(xbox.getRawAxis(5) * 0.2);
leftSideB.set(-xbox.getRawAxis(1) * 0.2);
rightSideB.set(xbox.getRawAxis(5) * 0.2);
ballIntake.set(xbox.getRawAxis(2)*0.5);
ballShooter.set(xbox.getRawAxis(3)*0.75);
}
/**
* This function is called periodically during test mode
*/
@Override
public void testPeriodic() {
}
}