Skip to content

Commit 7325072

Browse files
Update Literal Actual Program
1 parent aff470e commit 7325072

File tree

1 file changed

+74
-70
lines changed

1 file changed

+74
-70
lines changed

Literal Actual Program

Lines changed: 74 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@
44
/* must be accompanied by the FIRST BSD license file in the root directory of */
55
/* the project. */
66
/*----------------------------------------------------------------------------*/
7+
#include <thread>//
78

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>//
916
#include <frc/TimedRobot.h>
17+
#include <wpi/raw_ostream.h>//
18+
#include <frc/Joystick.h>
1019
#include <frc/Timer.h>
1120
#include <frc/PWMVictorSPX.h>
1221
#include <frc/drive/DifferentialDrive.h>
@@ -17,124 +26,118 @@
1726

1827
class Robot : public frc::TimedRobot {
1928
public:
20-
Robot() {}
2129

2230
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 {};
3439

3540
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();
4946
} else {
50-
Drive.ArcadeDrive(sqrt(xbox.GetRawAxis(1)) * -.7, sqrt(xbox.GetRawAxis(0)) * .5);
47+
compressor.Start();
5148
}
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+
5260
//HAB Lift(Untested)
5361
//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) {
5764
s_HABfront.Set(frc::DoubleSolenoid::kForward);
58-
} else if (xbox.GetRawAxis(2) == 0) {
65+
} else if (flightStick.GetRawButton(9) == 0) {
5966
s_HABfront.Set(frc::DoubleSolenoid::kReverse);
6067
} else {
6168
s_HABfront.Set(frc::DoubleSolenoid::kOff);
6269
}
6370
//Back(Untested)
64-
if (xbox.GetRawAxis(3) >= .5) {
71+
if (flightStick.GetRawButton(8) == 1) {
6572
s_HABback.Set(frc::DoubleSolenoid::kForward);
66-
} else if (xbox.GetRawAxis(3) == 0) {
73+
} else if (flightStick.GetRawButton(10) == 0) {
6774
s_HABback.Set(frc::DoubleSolenoid::kReverse);
6875
} else {
6976
s_HABback.Set(frc::DoubleSolenoid::kOff);
7077
}
71-
//Forklift(Workds)
78+
79+
//Forklift(Works) (B)
7280
//Forlift (Works)
7381
//POV is 0=UP 90=Right 180=Down 270=Left and 45 for all the angles
7482
//.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+
}
7999
} 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+
}
81105
}
82106
//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);//+
89109
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);
92112
m_rightIntake.Set(-.5);
93113
} else {
94114
m_leftIntake.Set(0);
95115
m_rightIntake.Set(0);
96116
}
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+
103118
//Hatch Panel Launcher(Works)
104119
//Hatch Panel Launcher(Works)
105120
//Set for 2 solenoids, still deciding wither it will be 1 or 2 solenoids
106121
//4 = Y on Qanda Arcade
107122
//1
108-
if (arcadePad.GetRawButton(4) == 1) {
123+
if (fightStick.GetRawButton(4) == 0) {
109124
s_panelLauncher.Set(frc::DoubleSolenoid::kForward);
110125
s_panelGetter.Set(frc::DoubleSolenoid::kForward);
111-
} else if (arcadePad.GetRawButton(4) == 0) {
126+
} else if (fightStick.GetRawButton(4) == 1) {
112127
s_panelLauncher.Set(frc::DoubleSolenoid::kReverse);
113128
s_panelGetter.Set(frc::DoubleSolenoid::kReverse);
114129
} else {
115130
s_panelLauncher.Set(frc::DoubleSolenoid::kOff);
116131
s_panelGetter.Set(frc::DoubleSolenoid::kOff);
117132
}
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-
*/
130133
}
131134
//Private
132135
private:
133136
//Declartions
134-
frc::Joystick xbox{1};
135-
frc::Joystick arcadePad{2};
137+
frc::Joystick fightStick{1};
138+
frc::Joystick flightStick{2};
136139
frc::Compressor compressor;
137-
frc::Timer time;
140+
frc::PowerDistributionPanel PDP;
138141
//Motors
139142
//Drivebase
140143
frc::PWMVictorSPX m_frontLeft{0};
@@ -161,6 +164,7 @@ class Robot : public frc::TimedRobot {
161164
frc::DoubleSolenoid s_HABback{6, 7};
162165
};
163166

167+
164168
//Main
165169
#ifndef RUNNING_FRC_TESTS
166170
int main() { return frc::StartRobot<Robot>(); }

0 commit comments

Comments
 (0)