Skip to content

Commit fbc8085

Browse files
Update Robot.cpp
1 parent 321b399 commit fbc8085

File tree

1 file changed

+32
-118
lines changed

1 file changed

+32
-118
lines changed

main/cpp/Robot.cpp

Lines changed: 32 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,21 @@ void Robot::RobotInit() {
1616
}
1717

1818
void Robot::RobotPeriodic() {
19-
cs::UsbCamera floorCamera = frc::CameraServer::GetInstance()->StartAutomaticCapture(0);
20-
cs::UsbCamera driverCamera = frc::CameraServer::GetInstance()->StartAutomaticCapture(1);
19+
UsbCamera floorCamera = CameraServer::GetInstance()->StartAutomaticCapture(0);
20+
UsbCamera driverCamera = CameraServer::GetInstance()->StartAutomaticCapture(1);
2121
driverCamera.SetResolution(320, 240);
2222
floorCamera.SetResolution(640, 480);
23-
cs::CvSink cvSink = frc::CameraServer::GetInstance()->GetVideo();
24-
cs::CvSource outputStream = frc::CameraServer::GetInstance()->PutVideo("Rectangle", 640, 480);
25-
cv::Mat mat;
23+
CvSink cvSink = CameraServer::GetInstance()->GetVideo();
24+
CvSource outputStream = CameraServer::GetInstance()->PutVideo("Rectangle", 640, 480);
25+
Mat mat;
2626
while (true) {
2727
if (cvSink.GrabFrame(mat) == 0) {
2828
outputStream.NotifyError(cvSink.GetError());
2929
}
30-
rectangle(mat, cv::Point(100, 100), cv::Point(400, 400), cv::Scalar(255, 255, 255), 5);
30+
rectangle(mat, Point(100, 100), Point(400, 400), Scalar(255, 255, 255), 5);
3131
outputStream.PutFrame(mat);
3232
}
33-
}
34-
35-
void Robot::AutonomousInit() {
36-
//NO AUTONOMOUS
37-
}
3833

39-
void Robot::AutonomousPeriodic() { //Same code for both Auto and Teleop, can't find a way to continue from one to other so both modes have the same code
4034
//Compressor
4135
if (fightStick.GetRawButton(8) == 1) {
4236
compressor.Start();
@@ -67,19 +61,19 @@ void Robot::AutonomousPeriodic() { //Same code for both Auto and Teleop, can't f
6761
//HAB Lift(???)
6862
//Font
6963
if (flightStick.GetRawButton(7) == 1) {
70-
s_HABfront.Set(frc::DoubleSolenoid::kForward);
64+
s_HABfront.Set(DoubleSolenoid::kForward);
7165
} else if (flightStick.GetRawButton(7) == 0) {
72-
s_HABfront.Set(frc::DoubleSolenoid::kReverse);
66+
s_HABfront.Set(DoubleSolenoid::kReverse);
7367
} else {
74-
s_HABfront.Set(frc::DoubleSolenoid::kOff);
68+
s_HABfront.Set(DoubleSolenoid::kOff);
7569
}
7670
//Back
7771
if (flightStick.GetRawButton(8) == 1) {
78-
s_HABback.Set(frc::DoubleSolenoid::kForward);
72+
s_HABback.Set(DoubleSolenoid::kForward);
7973
} else if (flightStick.GetRawButton(8) == 0) {
80-
s_HABback.Set(frc::DoubleSolenoid::kReverse);
74+
s_HABback.Set(DoubleSolenoid::kReverse);
8175
} else {
82-
s_HABback.Set(frc::DoubleSolenoid::kOff);
76+
s_HABback.Set(DoubleSolenoid::kOff);
8377
}
8478

8579
//Forklift Thomas special clutch idea for forklift
@@ -118,119 +112,39 @@ void Robot::AutonomousPeriodic() { //Same code for both Auto and Teleop, can't f
118112
//Hatch Panel Launcher
119113
//They are set backwards if time is avaible would like to switch them around in both the code and wiring
120114
if (fightStick.GetRawButton(4) == 0) {
121-
s_panelLauncherBottom.Set(frc::DoubleSolenoid::kForward);
122-
s_panelLauncherTop.Set(frc::DoubleSolenoid::kForward);
115+
s_panelLauncherBottom.Set(DoubleSolenoid::kForward);
116+
s_panelLauncherTop.Set(DoubleSolenoid::kForward);
123117
} else if (fightStick.GetRawButton(4) == 1) {
124-
s_panelLauncherBottom.Set(frc::DoubleSolenoid::kReverse);
125-
s_panelLauncherTop.Set(frc::DoubleSolenoid::kReverse);
118+
s_panelLauncherBottom.Set(DoubleSolenoid::kReverse);
119+
s_panelLauncherTop.Set(DoubleSolenoid::kReverse);
126120
} else {
127-
s_panelLauncherBottom.Set(frc::DoubleSolenoid::kForward);
128-
s_panelLauncherTop.Set(frc::DoubleSolenoid::kForward);
121+
s_panelLauncherBottom.Set(DoubleSolenoid::kForward);
122+
s_panelLauncherTop.Set(DoubleSolenoid::kForward);
129123
}
130-
//input.GetVoltage();
124+
SmartDashboard::PutNumber("Pi Value", pi.GetVoltage());
125+
//Add delay
131126
}
132127

133-
void Robot::TeleopInit() {
134-
//Nothing that I can think of
128+
void Robot::AutonomousInit() {
129+
//NO AUTONOMOUS
135130
}
136131

137-
void Robot::TeleopPeriodic() {
138-
//Compressor
139-
if (fightStick.GetRawButton(8) == 1) {
140-
compressor.Start();
141-
} else {
142-
compressor.Stop();
143-
}
144-
145-
//Drive
146-
if (flightStick.GetRawButton(2) == 1) { //Slow
147-
if (flightStick.GetRawAxis(1) > 0 || flightStick.GetRawAxis(1) < 0) {
148-
Drive.CurvatureDrive((flightStick.GetRawAxis(1) * pow(time.Get(), 2)) * -1 * speedSlow, flightStick.GetRawAxis(2) * turningSpeedFast, flightStick.GetRawButton(1));
149-
} else {
150-
time.Reset();
151-
}
152-
} else if (flightStick.GetRawButton(12/*Will Change*/) == 1) { // Fast
153-
if (flightStick.GetRawAxis(1) > 0 || flightStick.GetRawAxis(1) < 0) {
154-
Drive.CurvatureDrive((flightStick.GetRawAxis(1) * pow(time.Get(), 2)) * -1 * speedFast, flightStick.GetRawAxis(2) * turningSpeedFast, flightStick.GetRawButton(1));
155-
} else {
156-
time.Reset();
157-
}
158-
} else { //Normal
159-
if (flightStick.GetRawAxis(1) > 0 || flightStick.GetRawAxis(1) < 0) {
160-
Drive.CurvatureDrive((flightStick.GetRawAxis(1) * pow(time.Get(), 2)) * -1 * speedNormal, flightStick.GetRawAxis(2) * turningSpeedSlow, flightStick.GetRawButton(1));
161-
} else {
162-
time.Reset();
163-
}
164-
}
165-
//HAB Lift(???)
166-
//Font
167-
if (flightStick.GetRawButton(7) == 1) {
168-
s_HABfront.Set(frc::DoubleSolenoid::kForward);
169-
} else if (flightStick.GetRawButton(7) == 0) {
170-
s_HABfront.Set(frc::DoubleSolenoid::kReverse);
171-
} else {
172-
s_HABfront.Set(frc::DoubleSolenoid::kOff);
173-
}
174-
//Back
175-
if (flightStick.GetRawButton(8) == 1) {
176-
s_HABback.Set(frc::DoubleSolenoid::kForward);
177-
} else if (flightStick.GetRawButton(8) == 0) {
178-
s_HABback.Set(frc::DoubleSolenoid::kReverse);
179-
} else {
180-
s_HABback.Set(frc::DoubleSolenoid::kOff);
181-
}
132+
void Robot::AutonomousPeriodic() {
133+
//Nothing
134+
}
182135

183-
//Forklift Thomas special clutch idea for forklift
184-
//POV is 0=UP 90=Right 180=Down 270=Left and 45 for all the angles
185-
//.GetPOV("0") is the number for the POV system things switch
186-
if (fightStick.GetPOV(0) == 315) { //Up
187-
if (fightStick.GetRawButton(5) == 1) {
188-
m_forklift.Set(upSpeedFast);
189-
} else {
190-
m_forklift.Set(upSpeedNormal);
191-
}
192-
} else if (fightStick.GetPOV(0) == 225) { //Down
193-
if (fightStick.GetRawButton(5) == 1) {
194-
m_forklift.Set(downSpeedFast);
195-
} else {
196-
m_forklift.Set(downSpeedNormal);
197-
}
198-
} else if (fightStick.GetPOV(0) == 270) { //Stall
199-
m_forklift.Set(stall);
200-
} else {
201-
m_forklift.Set(0);
202-
}
203-
204-
//Ball Intake
205-
if (fightStick.GetRawButton(1) == 1) {
206-
m_leftIntake.Set(.5);//+
207-
m_rightIntake.Set(-.5);
208-
} else if (fightStick.GetRawButton(3) == 1) {
209-
m_leftIntake.Set(-.5);
210-
m_rightIntake.Set(.5);
211-
} else {
212-
m_leftIntake.Set(0);
213-
m_rightIntake.Set(0);
214-
}
136+
void Robot::TeleopInit() {
137+
//Nothing
138+
}
215139

216-
//Hatch Panel Launcher
217-
//They are set backwards if time is avaible would like to switch them around in both the code and wiring
218-
if (fightStick.GetRawButton(4) == 0) {
219-
s_panelLauncherBottom.Set(frc::DoubleSolenoid::kForward);
220-
s_panelLauncherTop.Set(frc::DoubleSolenoid::kForward);
221-
} else if (fightStick.GetRawButton(4) == 1) {
222-
s_panelLauncherBottom.Set(frc::DoubleSolenoid::kReverse);
223-
s_panelLauncherTop.Set(frc::DoubleSolenoid::kReverse);
224-
} else {
225-
s_panelLauncherBottom.Set(frc::DoubleSolenoid::kForward);
226-
s_panelLauncherTop.Set(frc::DoubleSolenoid::kForward);
227-
}
228-
//input.GetVoltage();
140+
void Robot::TeleopPeriodic() {
141+
//Nothing
229142
}
230143

231144
void Robot::TestPeriodic() {
145+
//Nothing
232146
}
233147

234148
#ifndef RUNNING_FRC_TESTS
235-
int main() { return frc::StartRobot<Robot>(); }
149+
int main() { return StartRobot<Robot>(); }
236150
#endif

0 commit comments

Comments
 (0)