Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwe_tried.java
More file actions
Latest commit
197 lines (175 loc) · 6.31 KB
/
Copy pathwe_tried.java
File metadata and controls
197 lines (175 loc) · 6.31 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
194
195
196
197
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 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. */
/*----------------------------------------------------------------------------*/
packageorg.usfirst.frc.team6468.robot;
importedu.wpi.first.wpilibj.IterativeRobot;
importedu.wpi.first.wpilibj.smartdashboard.SendableChooser;
importedu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
importedu.wpi.first.wpilibj.DigitalInput;
importedu.wpi.first.wpilibj.GenericHID;
importedu.wpi.first.wpilibj.Joystick;
importedu.wpi.first.wpilibj.XboxController;
importedu.wpi.first.wpilibj.buttons.*;
importedu.wpi.first.wpilibj.Servo;
importedu.wpi.first.wpilibj.Timer;
importedu.wpi.first.wpilibj.drive.DifferentialDrive;
importcom.ctre.phoenix.motorcontrol.can.*;
publicclassRobotextendsIterativeRobot {
privatestaticfinalStringkDefaultAuto = "Default";
privatestaticfinalStringkCustomAuto = "My Auto";
privateStringm_autoSelected;
privateSendableChooser<String> m_chooser = newSendableChooser<>();
privateXboxControllergamePad = newXboxController(1);
//private XboxController servocontroller = new XboxController(0);
//private Joystick joy = new Joystick(0);
//private JoystickButton button1 = new JoystickButton(joy, 1);
//private JoystickButton button2 = new JoystickButton(joy, 2);
privateServoclawLeft = newServo(0);
privateServoclawRight = newServo(1);
WPI_TalonSRX_verticalMotor = newWPI_TalonSRX(6);
WPI_TalonSRX_leftSlave1 = newWPI_TalonSRX(1);
WPI_TalonSRX_rightSlave1 = newWPI_TalonSRX(4);
WPI_TalonSRX_frontLeftMotor = newWPI_TalonSRX(2);
WPI_TalonSRX_frontRightMotor = newWPI_TalonSRX(3);
DifferentialDrive_drive = newDifferentialDrive(_frontLeftMotor, _frontRightMotor);
privateTimertimer = newTimer();
DigitalInputmicroSwitch = newDigitalInput(1);
intangle = 90;
publicvoidcloseClaw() {
//clawLeft.setAngle(clawLeft.getAngle()+5);
/*clawLeft.setAngle(145);
clawRight.setAngle(clawRight.getAngle()-5);
System.out.println(clawRight.getAngle());
*/
angle++;
clawLeft.setAngle(140);
//clawRight.setAngle(73.5);
}
publicvoidopenClaw() {
/*if(clawRight.getAngle() <= 120 && clawLeft.getAngle() >= 70) {
clawLeft.setAngle(clawLeft.getAngle()-5);
clawRight.setAngle(clawRight.getAngle()+5);
System.out.println(clawRight.getAngle());
}
*/
clawLeft.setAngle(90);
clawRight.setAngle(90);
}
@Override
publicvoidrobotInit() {
//clawLeft.setAngle(180);
//clawRight.setAngle(0);
m_chooser.addDefault("Default Auto", kDefaultAuto);
m_chooser.addObject("My Auto", kCustomAuto);
SmartDashboard.putData("Auto choices", m_chooser);
_rightSlave1.follow(_frontRightMotor);
_leftSlave1.follow(_frontLeftMotor);
}
/**
* 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
*
* <p>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
publicvoidautonomousInit() {
m_autoSelected = m_chooser.getSelected();
// autoSelected = SmartDashboard.getString("Auto Selector",
// defaultAuto);
System.out.println("Auto selected: " + m_autoSelected);
}
/**
* This function is called periodically during autonomous.
*/
@Override
publicvoidautonomousPeriodic() {
switch (m_autoSelected) {
casekCustomAuto:
// Put custom auto code here
break;
casekDefaultAuto:
default:
// Put default auto code here
break;
}
}
/**
* This function is called periodically during operator control.
*/
@Override
publicvoidteleopPeriodic() {
booleanopen = true;
booleanclosed = false;
doubleclawState = clawLeft.getAngle();
//double joyY = joy.getY();
doubleclawDeg = clawLeft.getAngle();
doubleRTrig = gamePad.getTriggerAxis(GenericHID.Hand.kRight);
doubleLTrig = gamePad.getTriggerAxis(GenericHID.Hand.kLeft);
doubleRStickX = gamePad.getX(GenericHID.Hand.kRight);
doubleLStickY = -gamePad.getY(GenericHID.Hand.kLeft);
booleanRBump = gamePad.getBumper(GenericHID.Hand.kRight);
booleanLBump = gamePad.getBumper(GenericHID.Hand.kLeft);
//boolean joyTrig = joy.getRawButton(1);
//boolean joyButton = joy.getRawButton(2);
booleanswitchState = microSwitch.get();
//VERTICAL SAFETY CONDITOIN
//if(switchState == true && joyY < 0) _verticalMotor.set(0);
//DRIVE FUNCTION
_drive.arcadeDrive(LStickY*.75, RStickX*.75);
//if(RBump==true) _frontLeftMotor.set(0);
//System.out.println(_frontLeftMotor.get());
//System.out.println(joyY);
//_verticalMotor.set(joyY);
//VERTICAL LIFT **TEST JOYSTICK**
/*if(LTrig != 0 && RTrig == 0) _verticalMotor.set(LTrig);
else if(RTrig != 0 && LTrig == 0) _verticalMotor.set(-RTrig);
else _verticalMotor.set(0);
System.out.println(_verticalMotor.get());
*/
/*
if(gamePad.getAButton() == true)
{
clawLeft.setAngle(180);
clawRight.setAngle(0);
}
if(gamePad.getAButton() == true)
{
clawLeft.setAngle(0);
clawRight.setAngle(180);
}
*/
//System.out.println( clawLeft.get());
if(LTrig != 0 ) openClaw();
if(RTrig != 0 ) closeClaw();
//else clawLeft.setAngle(clawLeft.getAngle());
//if(clawState == open) openClaw();
//if(clawState == closed) closeClaw();
/* for(double x = clawDeg; joyTrig == true && x < 180; x++) {
System.out.println("+++++++++++++++");
System.out.println(joyTrig+" "+x);
claw.setAngle(x);
clawDeg = x;
}
for(double x = clawDeg; joyButton == true && x > 0; x--) {
System.out8.println("--------------");
System.out.println(joyButton+" "+x);
claw.setAngle(x);
clawDeg = x;
}
*/
}
/**
* This function is called periodically during test mode.
*/
@Override
publicvoidtestPeriodic() {
}
}