4
4
/* must be accompanied by the FIRST BSD license file in the root directory of */
5
5
/* the project. */
6
6
/*----------------------------------------------------------------------------*/
7
+ #include <thread>//
7
8
8
- #include <frc/Joystick.h>
9
+ #include <iostream>
10
+ #include <frc/PowerDistributionPanel.h>
11
+ #include <cameraserver/CameraServer.h>//
12
+ #include <opencv2/core/core.hpp>//
13
+ #include <opencv2/core/types.hpp>//
14
+ #include <opencv2/imgproc/imgproc.hpp>//
15
+ #include <wpi/raw_ostream.h>//
9
16
#include <frc/TimedRobot.h>
17
+ #include <wpi/raw_ostream.h>//
18
+ #include <frc/Joystick.h>
10
19
#include <frc/Timer.h>
11
20
#include <frc/PWMVictorSPX.h>
12
21
#include <frc/drive/DifferentialDrive.h>
17
26
18
27
class Robot : public frc::TimedRobot {
19
28
public:
20
- Robot() {}
21
29
22
30
void RobotInit() override {
23
- compressor.Stop();
24
- };
25
- void RobotPeriodic() override {}
26
- void AutonomousInit() override {
27
- time.Reset();
28
- time.Start();
29
- };
30
-
31
- void AutonomousPeriodic() override {
32
- };
33
- void TeleopInit() override {}
31
+ compressor.Start ();
32
+ frc::CameraServer::GetInstance()->StartAutomaticCapture(0);
33
+ frc::CameraServer::GetInstance()->StartAutomaticCapture(1);
34
+ }
35
+ void RobotPeriodic() override {};
36
+ void AutonomousInit() override {};
37
+ void AutonomousPeriodic() override {};
38
+ void TeleopInit() override {};
34
39
35
40
void TeleopPeriodic() override {
36
- //Miscelanious
37
- //Compressor Toggle(Later Amigo)
38
-
39
- //Drive(Workds)
40
- //Drivebase(Works)
41
- //Want to test /3 for presion turning only
42
- //The * -1 is to inverse motors, and the / 2 is to slow down regular turing and the / 2 if for presicion drive
43
- //the else if statments is mostly likely unneeded, will test with and without so see if it is needed
44
- // 3 = A button
45
- if (xbox.GetRawButton(3) == 1) {
46
- Drive.ArcadeDrive(sqrt(xbox.GetRawAxis(1)) * -.5, sqrt(xbox.GetRawAxis(0)) * .5);
47
- } else if (xbox.GetRawButton(3) == 0) {
48
- Drive.ArcadeDrive(sqrt(xbox.GetRawAxis(1)) * -.7, sqrt(xbox.GetRawAxis(0)) * .5);
41
+ //PDP Current Output
42
+ //frc::SmartDashboard::PutString(PDP.GetCurrent(0));
43
+ //Compressor "Switch..."
44
+ if (fightStick.GetRawButton(8) == 1) {
45
+ compressor.Stop();
49
46
} else {
50
- Drive.ArcadeDrive(sqrt(xbox.GetRawAxis(1)) * -.7, sqrt(xbox.GetRawAxis(0)) * .5 );
47
+ compressor.Start( );
51
48
}
49
+
50
+ //Drive(Works)
51
+ //Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.5, flightStick.GetRawAxis(2) * .5, flightStick.GetRawButton(1)); // 0(X) or 2(Z)
52
+ if (flightStick.GetRawButton(2) == 1) {
53
+ Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.7, flightStick.GetRawAxis(2) * .7, flightStick.GetRawButton(1));
54
+ } else if (flightStick.GetRawButton(2) == 0) {
55
+ Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.5, flightStick.GetRawAxis(2) * .7, flightStick.GetRawButton(1));
56
+ } else {
57
+ Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.5, flightStick.GetRawAxis(2) * .7, flightStick.GetRawButton(1));
58
+ }
59
+
52
60
//HAB Lift(Untested)
53
61
//HAB lift
54
- //Front(Untested)
55
- //Using trigger axis for ease of use for operator but idk if the code will work like I have it
56
- if (xbox.GetRawAxis(2) >= .5) {
62
+ //Font(Untested)
63
+ if (flightStick.GetRawButton(7) == 1) {
57
64
s_HABfront.Set(frc::DoubleSolenoid::kForward);
58
- } else if (xbox.GetRawAxis(2 ) == 0) {
65
+ } else if (flightStick.GetRawButton(9 ) == 0) {
59
66
s_HABfront.Set(frc::DoubleSolenoid::kReverse);
60
67
} else {
61
68
s_HABfront.Set(frc::DoubleSolenoid::kOff);
62
69
}
63
70
//Back(Untested)
64
- if (xbox.GetRawAxis(3) >= .5 ) {
71
+ if (flightStick.GetRawButton(8) == 1 ) {
65
72
s_HABback.Set(frc::DoubleSolenoid::kForward);
66
- } else if (xbox.GetRawAxis(3 ) == 0) {
73
+ } else if (flightStick.GetRawButton(10 ) == 0) {
67
74
s_HABback.Set(frc::DoubleSolenoid::kReverse);
68
75
} else {
69
76
s_HABback.Set(frc::DoubleSolenoid::kOff);
70
77
}
71
- //Forklift(Workds)
78
+
79
+ //Forklift(Works) (B)
72
80
//Forlift (Works)
73
81
//POV is 0=UP 90=Right 180=Down 270=Left and 45 for all the angles
74
82
//.GetPOV("0") is the number for the POV system things switch
75
- if (arcadePad.GetPOV(0) == 0) {
76
- m_forklift.Set(.5);
77
- } else if (arcadePad.GetPOV(0) == 180) {
78
- m_forklift.Set(-.5);
83
+ if (fightStick.GetPOV(0) == 0) {
84
+ if (fightStick.GetRawButton(5) == 1) {
85
+ m_forklift.Set(-.5);
86
+ } else if (fightStick.GetRawButton(5) == 0) {
87
+ m_forklift.Set(-.4);
88
+ } else {
89
+ m_forklift.Set(-.4);
90
+ }
91
+ } else if (fightStick.GetPOV(0) == 180) {
92
+ if (fightStick.GetRawButton(5) == 1) {
93
+ m_forklift.Set(-.03);
94
+ } else if (fightStick.GetRawButton(5) == 0) {
95
+ m_forklift.Set(-.04);
96
+ } else {
97
+ m_forklift.Set(-.04);
98
+ }
79
99
} else {
80
- m_forklift.Set(0);
100
+ if (fightStick.GetRawButton(2) == 1) {
101
+ m_forklift.Set(-.2);
102
+ } else {
103
+ m_forklift.Set(0);
104
+ }
81
105
}
82
106
//Ball Intake(Works)
83
- //Ball Intake (Does not work)
84
- //RJ wants this for button layout coherancy
85
- //This is the button test
86
- // the / 3 is since one of the motors is currently missing a gearbox but we will have the gear box before comp
87
- if (arcadePad.GetRawButton(1) == 1) {
88
- m_leftIntake.Set(-.16);//+
107
+ if (fightStick.GetRawButton(1) == 1) {
108
+ m_leftIntake.Set(-.5);//+
89
109
m_rightIntake.Set(.5);
90
- } else if (arcadePad .GetRawButton(3) == 1) {
91
- m_leftIntake.Set(.16 );
110
+ } else if (fightStick .GetRawButton(3) == 1) {
111
+ m_leftIntake.Set(.5 );
92
112
m_rightIntake.Set(-.5);
93
113
} else {
94
114
m_leftIntake.Set(0);
95
115
m_rightIntake.Set(0);
96
116
}
97
- //(Untested)
98
- //This is the button/axis test, this is what we want if it works but can use code abouve incase this does not work
99
- //The button layout with the top code is better than this one so idk what we will use in the end
100
- //R2 and L2 axis(buttons on physical board)
101
- //m_leftIntake.Set(arcadePad.GetRawAxis(3) * -1 / 3); //divide 3 only there for now since we don't have the 2nd gearbox
102
- //m_rightIntake.Set(arcadePad.GetRawAxis(2));
117
+
103
118
//Hatch Panel Launcher(Works)
104
119
//Hatch Panel Launcher(Works)
105
120
//Set for 2 solenoids, still deciding wither it will be 1 or 2 solenoids
106
121
//4 = Y on Qanda Arcade
107
122
//1
108
- if (arcadePad .GetRawButton(4) == 1 ) {
123
+ if (fightStick .GetRawButton(4) == 0 ) {
109
124
s_panelLauncher.Set(frc::DoubleSolenoid::kForward);
110
125
s_panelGetter.Set(frc::DoubleSolenoid::kForward);
111
- } else if (arcadePad .GetRawButton(4) == 0 ) {
126
+ } else if (fightStick .GetRawButton(4) == 1 ) {
112
127
s_panelLauncher.Set(frc::DoubleSolenoid::kReverse);
113
128
s_panelGetter.Set(frc::DoubleSolenoid::kReverse);
114
129
} else {
115
130
s_panelLauncher.Set(frc::DoubleSolenoid::kOff);
116
131
s_panelGetter.Set(frc::DoubleSolenoid::kOff);
117
132
}
118
- //Slider/Panel Getter(Untested)
119
- //Slider/Panel Getter(Untested)
120
- //Will only used if Hatch Panel uses only 1 solenoids
121
- /*
122
- if (arcadePad.GetRawButton(6) == 1) {
123
- s_panelGetter.Set(frc::DoubleSolenoid::kReverse);
124
- } else if (arcadePad.GetRawButton(6) == 0) {
125
- s_panelGetter.Set(frc::DoubleSolenoid::kForward);
126
- } else {
127
- s_panelGetter.Set(frc::DoubleSolenoid::kOff);
128
- }
129
- */
130
133
}
131
134
//Private
132
135
private:
133
136
//Declartions
134
- frc::Joystick xbox {1};
135
- frc::Joystick arcadePad {2};
137
+ frc::Joystick fightStick {1};
138
+ frc::Joystick flightStick {2};
136
139
frc::Compressor compressor;
137
- frc::Timer time ;
140
+ frc::PowerDistributionPanel PDP ;
138
141
//Motors
139
142
//Drivebase
140
143
frc::PWMVictorSPX m_frontLeft{0};
@@ -161,6 +164,7 @@ class Robot : public frc::TimedRobot {
161
164
frc::DoubleSolenoid s_HABback{6, 7};
162
165
};
163
166
167
+
164
168
//Main
165
169
#ifndef RUNNING_FRC_TESTS
166
170
int main() { return frc::StartRobot<Robot>(); }
0 commit comments