Skip to content

Commit bae5911

Browse files
authoredFeb 21, 2019
Create ...
1 parent 75fe1d0 commit bae5911

File tree

1 file changed

+194
-0
lines changed

1 file changed

+194
-0
lines changed
 

‎...

+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
#include <thread>//
8+
9+
#include <frc/AnalogInput.h>
10+
#include <iostream>
11+
#include <frc/PowerDistributionPanel.h>
12+
#include <cameraserver/CameraServer.h>//
13+
#include <opencv2/core/core.hpp>//
14+
#include <opencv2/core/types.hpp>//
15+
#include <opencv2/imgproc/imgproc.hpp>//
16+
#include <wpi/raw_ostream.h>//
17+
#include <frc/TimedRobot.h>
18+
#include <wpi/raw_ostream.h>//
19+
#include <frc/Joystick.h>
20+
#include <frc/Timer.h>
21+
#include <frc/PWMVictorSPX.h>
22+
#include <frc/drive/DifferentialDrive.h>
23+
#include <frc/SpeedControllerGroup.h>
24+
#include <frc/DoubleSolenoid.h>
25+
#include <frc/Solenoid.h>
26+
#include <frc/Compressor.h>
27+
28+
class Robot : public frc::TimedRobot {
29+
public:
30+
31+
void RobotInit() override {
32+
compressor.Stop ();
33+
frc::CameraServer::GetInstance()->StartAutomaticCapture(0);
34+
frc::CameraServer::GetInstance()->StartAutomaticCapture(1);
35+
}
36+
void RobotPeriodic() override {};
37+
void AutonomousInit() override {};
38+
void AutonomousPeriodic() override {};
39+
void TeleopInit() override {};
40+
41+
void TeleopPeriodic() override {
42+
//PDP Current Output
43+
//frc::SmartDashboard::PutString(PDP.GetCurrent(0));
44+
//Compressor "Switch..."
45+
if (fightStick.GetRawButton(8) == 1) {
46+
compressor.Start();
47+
} else {
48+
compressor.Stop();
49+
}
50+
51+
//Drive(Works)
52+
/*(Second test, this is a test to switch from curvature drive to arcadedrive, arcade drive has the thrust set to 0 at all times)
53+
if (flightStick.GetRawButton(1) == 0) {
54+
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.5, flightStick.GetRawAxis(2) * .5, flightStick.GetRawButton(5)); // 0(X) or 2(Z)
55+
} else if (flightStick.GetRawButton(1) == 1) {
56+
Drive.TankDrive(flightStick.GetRawAxis(1) * .45, flightStick.GetRawAxis(2) * .45);
57+
} else {
58+
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.5, flightStick.GetRawAxis(2) * .5, flightStick.GetRawButton(5));
59+
}*/
60+
61+
//(Original Code of drive, if none of the top works I can set the overall turn to a smaller number or I can try and see if multipling the
62+
//statement that activates tank turn?)
63+
/*
64+
if (flightStick.GetRawButton(2) == 1) {
65+
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.7, flightStick.GetRawAxis(2) * .7, flightStick.GetRawButton(1));
66+
} else if (flightStick.GetRawButton(2) == 0) {
67+
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.5, flightStick.GetRawAxis(2) * .7, flightStick.GetRawButton(1));
68+
} else {
69+
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.5, flightStick.GetRawAxis(2) * .7, flightStick.GetRawButton(1));
70+
}
71+
*/
72+
if (flightStick.GetRawButton(2) == 1) {
73+
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.7, flightStick.GetRawAxis(2) * .7, flightStick.GetRawButton(1));
74+
} else if (flightStick.GetRawButton(2) == 0) {
75+
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.5, flightStick.GetRawAxis(2) * .7, flightStick.GetRawButton(1));
76+
} else {
77+
Drive.CurvatureDrive(flightStick.GetRawAxis(1) * -.5, flightStick.GetRawAxis(2) * .7, flightStick.GetRawButton(1));
78+
}
79+
//HAB Lift(Works... Might now have???)
80+
//HAB lift
81+
//Font(Untested)
82+
if (flightStick.GetRawButton(7) == 1) {
83+
s_HABfront.Set(frc::DoubleSolenoid::kForward);
84+
} else if (flightStick.GetRawButton(7) == 0) {
85+
s_HABfront.Set(frc::DoubleSolenoid::kReverse);
86+
} else {
87+
s_HABfront.Set(frc::DoubleSolenoid::kOff);
88+
}
89+
//Back(Untested)
90+
if (flightStick.GetRawButton(8) == 1) {
91+
s_HABback.Set(frc::DoubleSolenoid::kForward);
92+
} else if (flightStick.GetRawButton(8) == 0) {
93+
s_HABback.Set(frc::DoubleSolenoid::kReverse);
94+
} else {
95+
s_HABback.Set(frc::DoubleSolenoid::kOff);
96+
}
97+
98+
//Forklift(Works) (B)
99+
//Forlift (Works)
100+
//POV is 0=UP 90=Right 180=Down 270=Left and 45 for all the angles
101+
//.GetPOV("0") is the number for the POV system things switch
102+
if (fightStick.GetRawButton(2) == 1) {
103+
if (fightStick.GetPOV(0) == 0) {
104+
if (fightStick.GetRawButton(5) == 1) {
105+
m_forklift.Set(-.5);
106+
} else if (fightStick.GetRawButton(5) == 0) {
107+
m_forklift.Set(-.4);
108+
} else {
109+
m_forklift.Set(-.4);
110+
}
111+
} else if (fightStick.GetPOV(0) == 180) {
112+
if (fightStick.GetRawButton(5) == 1) {
113+
m_forklift.Set(-.03);
114+
} else if (fightStick.GetRawButton(5) == 0) {
115+
m_forklift.Set(-.045);//.005 might be too small???
116+
} else {
117+
m_forklift.Set(-.045);
118+
}
119+
} else {
120+
m_forklift.Set(-.2);
121+
}
122+
} else {
123+
m_forklift.Set(0);
124+
}
125+
126+
127+
//Ball Intake(Works)
128+
if (fightStick.GetRawButton(1) == 1) {
129+
m_leftIntake.Set(.5);//+
130+
m_rightIntake.Set(-.5);
131+
} else if (fightStick.GetRawButton(3) == 1) {
132+
m_leftIntake.Set(-.5);
133+
m_rightIntake.Set(.5);
134+
} else {
135+
m_leftIntake.Set(0);
136+
m_rightIntake.Set(0);
137+
}
138+
139+
//Hatch Panel Launcher(Works)
140+
//Hatch Panel Launcher(Works)
141+
//Set for 2 solenoids, still deciding wither it will be 1 or 2 solenoids
142+
//4 = Y on Qanda Arcade
143+
//1
144+
if (fightStick.GetRawButton(4) == 0) {
145+
s_panelLauncher.Set(frc::DoubleSolenoid::kForward);
146+
s_panelGetter.Set(frc::DoubleSolenoid::kForward);
147+
} else if (fightStick.GetRawButton(4) == 1) {
148+
s_panelLauncher.Set(frc::DoubleSolenoid::kReverse);
149+
s_panelGetter.Set(frc::DoubleSolenoid::kReverse);
150+
} else {
151+
s_panelLauncher.Set(frc::DoubleSolenoid::kForward);
152+
s_panelGetter.Set(frc::DoubleSolenoid::kForward);
153+
}
154+
//input.GetVoltage();
155+
}
156+
//Private
157+
private:
158+
//Analog PI (PWM)
159+
//frc::AnalogInput input{0};
160+
//Declartions
161+
frc::Joystick fightStick{1};
162+
frc::Joystick flightStick{2};
163+
frc::Compressor compressor;
164+
//frc::PowerDistributionPanel PDP;
165+
//Motors
166+
//Drivebase
167+
frc::PWMVictorSPX m_frontLeft{0};
168+
frc::PWMVictorSPX m_backLeft{1};
169+
frc::PWMVictorSPX m_frontRight{2};
170+
frc::PWMVictorSPX m_backRight{3};
171+
//Ball Intake
172+
frc::PWMVictorSPX m_leftIntake{4}; //No Gearbox Currently
173+
frc::PWMVictorSPX m_rightIntake{5};
174+
//Forlift
175+
frc::PWMVictorSPX m_forklift{6};
176+
//Groups
177+
//Drivebase
178+
frc::SpeedControllerGroup m_left{m_frontLeft, m_backLeft};
179+
frc::SpeedControllerGroup m_right{m_frontRight, m_backRight};
180+
//Setting Drive
181+
frc::DifferentialDrive Drive{m_left, m_right};
182+
//Pneumatics/Solenoids
183+
//Hatch Panel Launcher
184+
frc::DoubleSolenoid s_panelLauncher{0, 1};
185+
frc::DoubleSolenoid s_panelGetter{2, 3}; // will have to change this variable and the one above depending on if we have the Getter/Slider or not
186+
frc::DoubleSolenoid s_HABfront{4, 5};
187+
frc::DoubleSolenoid s_HABback{6, 7};
188+
};
189+
190+
191+
//Main
192+
#ifndef RUNNING_FRC_TESTS
193+
int main() { return frc::StartRobot<Robot>(); }
194+
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.