Skip to content

Commit 0ded0b6

Browse files
Update Literal Actual Program
All the base functions are done except things related to vision and auto
1 parent dde2dea commit 0ded0b6

File tree

1 file changed

+93
-65
lines changed

1 file changed

+93
-65
lines changed

Literal Actual Program

Lines changed: 93 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55
/* the project. */
66
/*----------------------------------------------------------------------------*/
77

8-
//Pins and Controller input are not final, must change before testing/make a remote map
9-
/*Game Pad Mapping(This starts at 1, might have to shift everything to start at 0)
8+
/*
9+
XBox
1010
Axis:
11-
Left Stick X = 0 (Drivebase)
12-
Left Stick Y = 1 (Drivebase)
13-
Left Trigger = 2 (Back HAB Lift)
14-
Right Trigger = 3 (Front HAB Lift)
15-
Right Stick X = 4 ()
16-
Right Stick Y = 5 ()
11+
Left Stick X = 1
12+
Left Stick Y = 2
13+
Left Trigger = 3
14+
Right Trigger = 4
15+
Right Stick X = 5
16+
Right Stick Y = 6
1717

1818
Button:
19-
A = 0 (First Layer of Forklift)
20-
B = 1 (Second Layer of Forklift)
21-
X = 2 (Grab Ball)
22-
Y = 3 (Launch Ball)
23-
Left Trigger = 4 (Grab Panel)
24-
Right Trigger = 5 (Launch Panel)
25-
Options? = 6
26-
Start? = 7
27-
Left Stick = 8
28-
Right Stick = 9
19+
A = 1
20+
B = 2
21+
X = 3
22+
Y = 4
23+
Left Trigger = 5
24+
Right Trigger = 6
25+
Options? = 7
26+
Start? = 8
27+
Left Stick = 9
28+
Right Stick = 10
2929
*/
3030
#include <frc/Joystick.h>
3131
#include <frc/TimedRobot.h>
@@ -46,52 +46,90 @@ class Robot : public frc::TimedRobot {
4646
void AutonomousPeriodic() override {}
4747

4848
void TeleopInit() override {
49-
compressor1.Start();
49+
compressor.Start();
5050
}
5151

5252
void TeleopPeriodic() override {
53-
//Drivebase
54-
Drive.ArcadeDrive(throttle.GetRawAxis(1), wheel.GetRawAxis(0)); //Don't know what axis, 1 and 0 are just filler
55-
//Forlift (Untested)
56-
if (xbox.GetRawButton(1) == 1) {
57-
m_forklift.Set(xbox.GetRawAxis(1) / 5);
58-
} else if (xbox.GetRawButton(1) == 0) {
59-
m_forklift.Set(xbox.GetRawAxis(1));
53+
//Drivebase(Works)
54+
//The * -1 is to inverse motors, and the / 2 is to slow down regular turing and the / 3 if for presicion drive
55+
//the else if statments is mostly likely unneeded, will test with and without so see if it is needed
56+
// 3 = A button
57+
if (xbox.GetRawButton(3) == 1) {
58+
Drive.ArcadeDrive(xbox.GetRawAxis(1) * -1 / 3, xbox.GetRawAxis(0) / 3);
59+
} else if (xbox.GetRawButton(3) == 0) {
60+
Drive.ArcadeDrive(xbox.GetRawAxis(1) * -1, xbox.GetRawAxis(0) / 2);
61+
} else {
62+
Drive.ArcadeDrive(xbox.GetRawAxis(1) * -1, xbox.GetRawAxis(0) / 2);
63+
}
64+
//HAB lift
65+
//Front(Untested)
66+
//Using trigger axis for ease of use for operator but idk if the code will work like I have it
67+
if (xbox.GetRawAxis(2) >= .5) {
68+
s_HABfront.Set(frc::DoubleSolenoid::kForward);
69+
} else if (xbox.GetRawAxis(2) == 0) {
70+
s_HABfront.Set(frc::DoubleSolenoid::kReverse);
6071
} else {
61-
m_forklift.Set(xbox.GetRawAxis(1));
72+
s_HABfront.Set(frc::DoubleSolenoid::kOff);
73+
}
74+
//Back(Untested)
75+
if (xbox.GetRawAxis(3) >= .5) {
76+
s_HABback.Set(frc::DoubleSolenoid::kForward);
77+
} else if (xbox.GetRawAxis(3) == 0) {
78+
s_HABback.Set(frc::DoubleSolenoid::kReverse);
79+
} else {
80+
s_HABback.Set(frc::DoubleSolenoid::kOff);
6281
}
63-
//Ball Intake (Works)
64-
m_leftIntake.Set(xbox.GetRawAxis(5) / 3); //devide 3 only there for now since we don't have the 2nd gearbox
65-
m_rightIntake.Set(xbox.GetRawAxis(5));
6682

67-
//The Hatch Panel Getter/Grabber (Untested)
68-
//???? X or Y maybe
69-
if (xbox.GetRawButton(panelGetterForward) == 1) {
70-
s_panelGetter.Set(frc::DoubleSolenoid::kForward);
71-
} else if (xbox.GetRawButton(panelLauncherReverse) == 0) {
72-
s_panelGetter.Set(frc::DoubleSolenoid::kReverse);
73-
} //I do not know if I will need the else or if I shoudl change the else if to an else statement
74-
else {
75-
s_panelLauncher.Set(frc::DoubleSolenoid::kOff);
83+
//Forlift (Untested)
84+
//POV is 0=UP 90=Right 180=Down 270=Left and 45 for all the angles
85+
// the "== 1" might have to be "== 0/180" corresponcding to the angle
86+
if (arcadePad.GetPOV(0) == 1) {
87+
m_forklift.Set(.5);
88+
} else if (arcadePad.GetPOV(180) == 1) {
89+
m_forklift.Set(-.5);
90+
} else {
91+
m_forklift.Set(0);
7692
}
77-
//The Hatch Panel Launcher (Works)
78-
//A button
79-
if (xbox.GetRawButton(panelLauncherForward) == 1) {
80-
s_panelLauncher.Set(frc::DoubleSolenoid::kForward);
81-
} else if (xbox.GetRawButton(panelLauncherReverse) == 0) {
82-
s_panelLauncher.Set(frc::DoubleSolenoid::kReverse);
93+
94+
//Ball Intake (Untested)
95+
//This is the button test
96+
// the / 3 is since one of the motors is currently missing a gearbox but we will have the gear box before comp
97+
if (arcadePad.GetRawButton(1) == 1) {
98+
m_leftIntake.Set(-1 / 3);
99+
m_rightIntake.Set(-1);
100+
} else if (arcadePad.GetRawButton(3) == 1) {
101+
m_leftIntake.Set(1 / 3);
102+
m_rightIntake.Set(1);
103+
} else {
104+
m_leftIntake.Set(0);
105+
m_rightIntake.Set(0);
83106
}
84-
else {
85-
s_panelLauncher.Set(frc::DoubleSolenoid::kOff);
107+
//(Untested)
108+
//This is the button/axis test, this is what we want if it works but can use code abouve incase this does not work
109+
//The button layout with the top code is better than this one so idk what we will use in the end
110+
//R2 and L2 axis(buttons on physical board)
111+
m_leftIntake.Set(arcadePad.GetRawAxis(3) * -1 / 3); //devide 3 only there for now since we don't have the 2nd gearbox
112+
m_rightIntake.Set(arcadePad.GetRawAxis(2));
113+
114+
//Hatch Panel Launcher(Works)
115+
//4 = Y on Qanda Arcade
116+
if (arcadePad.GetRawButton(4) == 1) {
117+
s_panelLauncherTop1.Set(frc::DoubleSolenoid::kReverse);
118+
s_panelLauncherBottom2.Set(frc::DoubleSolenoid::kReverse);
119+
} else if (arcadePad.GetRawButton(4) == 0) {
120+
s_panelLauncherTop1.Set(frc::DoubleSolenoid::kForward);
121+
s_panelLauncherBottom2.Set(frc::DoubleSolenoid::kForward);
122+
} else {
123+
s_panelLauncherBottom2.Set(frc::DoubleSolenoid::kOff);
124+
s_panelLauncherTop1.Set(frc::DoubleSolenoid::kOff);
86125
}
87126
}
88127

89128
private:
90129
//Declartions
91130
frc::Joystick xbox{1};
92-
frc::Joystick wheel{2}; //Don't know what port, 1 is filler
93-
frc::Joystick throttle{3}; //Don't know what port, 2 is filler
94-
frc::Compressor compressor1;
131+
frc::Joystick arcadePad{2};
132+
frc::Compressor compressor;
95133
//Motors
96134
//Drivebase
97135
frc::PWMVictorSPX m_frontLeft{0};
@@ -111,26 +149,16 @@ class Robot : public frc::TimedRobot {
111149
frc::DifferentialDrive Drive{m_left, m_right};
112150

113151
//Pneumatics/Solenoids
114-
//Hatch Panel Launcher (Works)
115-
/*frc::DoubleSolenoid s_panelLauncher{0, 1};
116-
static constexpr int panelLauncherForward = 1;
117-
static constexpr int panelLauncherReverse = 2;*/
118-
// test on triggers(untested)
119-
frc::DoubleSolenoid s_panelLauncher{0, 1};
120-
static constexpr int panelLauncherForward = 5;
121-
static constexpr int panelLauncherReverse = 1;
122-
//Hatch Panel Getter "trigger" (Untested)
123-
frc::DoubleSolenoid s_panelGetter{2, 3};
124-
static constexpr int panelGetterForward = 4;
125-
static constexpr int panelGetterReverse = 2;
152+
//Hatch Panel Launcher
153+
frc::DoubleSolenoid s_panelLauncherBottom2{0, 1};
154+
frc::DoubleSolenoid s_panelLauncherTop1{2, 3};
155+
frc::DoubleSolenoid s_HABfront{4, 5};
156+
frc::DoubleSolenoid s_HABback{6, 7};
126157
};
127158

128159
#ifndef RUNNING_FRC_TESTS
129160
int main() { return frc::StartRobot<Robot>(); }
130161
#endif
131-
132-
133-
134162
/*
135163
#include <frc/Joystick.h>
136164
#include <frc/PWMVictorSPX.h>

0 commit comments

Comments
 (0)