Skip to content

Commit 76aba97

Browse files
committed
moved limelight code and made more stuff
1 parent c734bbf commit 76aba97

10 files changed

+263
-261
lines changed

src/main/java/frc/robot/Modules/AimFire.java

+26-46
Original file line numberDiff line numberDiff line change
@@ -21,72 +21,52 @@ public static void shooter() {
2121

2222
/**
2323
* The function that will center the robot's aim on the target.
24-
*
24+
*
2525
* @param target The name of the target to aim at. ("top_hub","ball")
2626
*/
2727
public static void centerAim(ValidTargets target) {
2828
//https://i.kym-cdn.com/entries/icons/original/000/039/393/cover2.jpg
2929

3030
switch(target) {
31-
case top_hub:
32-
Limelight.setPipeline(0);
33-
Limelight.getLimelightData();
34-
if(Math.abs(Limelight.nonZeroLimelightHorAng)>RobotInformation.deadbandAngle) { //Is the number within the deadband range?
35-
if(Limelight.nonZeroLimelightHorAng>0) { //Positive
36-
// Turn right
37-
double motorSpeed = (Math.abs(Limelight.nonZeroLimelightHorAng * .9)/59.6)+.05;
38-
motorSpeed = Math.round(motorSpeed * 100) / 100.0;
39-
MotorControl.DriveCode.oldDriveTrain(motorSpeed, -motorSpeed);
40-
}
41-
if(Limelight.nonZeroLimelightHorAng<0) { //Negetive
42-
// Turn left
43-
double motorSpeed = (Math.abs(Limelight.nonZeroLimelightHorAng * .9)/59.6)+.05;
44-
motorSpeed = Math.round(motorSpeed * 100) / 100.0;
45-
MotorControl.DriveCode.oldDriveTrain(-motorSpeed, motorSpeed);
46-
}
47-
}
48-
// else {
49-
// DriveCode.oldDriveTrain(0, 0);
50-
// }
51-
break;
31+
case upper_hub: // Center on the Retroreflector regardless of wether upper or lower cause they are stacked
5232
case lower_hub:
53-
Limelight.setPipeline(0);
54-
Limelight.getLimelightData();
55-
if(Math.abs(Limelight.nonZeroLimelightHorAng)>RobotInformation.deadbandAngle) { //Is the number within the deadband range?
56-
if(Limelight.nonZeroLimelightHorAng>0) { //Positive
57-
// Turn right
58-
double motorSpeed = (Math.abs(Limelight.nonZeroLimelightHorAng * .9)/59.6)+.05;
59-
motorSpeed = Math.round(motorSpeed * 100) / 100.0;
60-
MotorControl.DriveCode.oldDriveTrain(motorSpeed, -motorSpeed);
61-
}
62-
if(Limelight.nonZeroLimelightHorAng<0) { //Negetive
63-
// Turn left
64-
double motorSpeed = (Math.abs(Limelight.nonZeroLimelightHorAng * .9)/59.6)+.05;
65-
motorSpeed = Math.round(motorSpeed * 100) / 100.0;
66-
MotorControl.DriveCode.oldDriveTrain(-motorSpeed, motorSpeed);
33+
VisionSystems.Limelight.setPipeline(0);
34+
if(Math.abs(VisionSystems.Limelight.nonZeroLimelightAngle)>RobotInformation.deadbandAngle) { //Is the number within the deadband range?
35+
if(VisionSystems.Limelight.nonZeroLimelightAngle>0) { //Positive
36+
// Turn right
37+
double motorSpeed = (Math.abs(VisionSystems.Limelight.nonZeroLimelightAngle * .9)/59.6)+.05;
38+
motorSpeed = Math.round(motorSpeed * 100) / 100.0;
39+
MotorControl.DriveCode.oldDriveTrain(motorSpeed, -motorSpeed);
40+
}
41+
if(VisionSystems.Limelight.nonZeroLimelightAngle<0) { //Negetive
42+
// Turn left
43+
double motorSpeed = (Math.abs(VisionSystems.Limelight.nonZeroLimelightAngle * .9)/59.6)+.05;
44+
motorSpeed = Math.round(motorSpeed * 100) / 100.0;
45+
MotorControl.DriveCode.oldDriveTrain(-motorSpeed, motorSpeed);
46+
}
6747
}
68-
}
69-
// else {
70-
// DriveCode.oldDriveTrain(0, 0);
71-
// }
48+
// else {
49+
// DriveCode.oldDriveTrain(0, 0);
50+
// }
7251
break;
7352

7453
case ball:
7554

55+
7656
break;
7757
}
7858
}
7959

80-
8160
/**
8261
* One click fire function
8362
*/
8463
public static void fire(ValidTargets target) { //TODO: One click fire
85-
if(Math.abs(Limelight.nonZeroLimelightHorAng)>RobotInformation.deadbandAngle) {
86-
centerAim(target);
87-
} else if(Math.abs(Limelight.nonZeroLimelightHorAng)<RobotInformation.deadbandAngle) {
64+
// if(Math.abs(Limelight.nonZeroLimelightHorAng)>RobotInformation.deadbandAngle) {
65+
// centerAim(target);
66+
// } else if(Math.abs(Limelight.nonZeroLimelightHorAng)<RobotInformation.deadbandAngle) {
67+
// }
68+
8869

89-
}
9070
}
9171

92-
}
72+
}

src/main/java/frc/robot/Modules/BallTracking.java

-25
This file was deleted.

src/main/java/frc/robot/Modules/Climbers.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ public static void climbrotation() {
3434
Robot.climbRotation.set(ControlMode.PercentOutput, 0);
3535
}
3636
}
37-
}
37+
}

src/main/java/frc/robot/Modules/FunStuff.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package frc.robot.Modules;
22

3-
import frc.robot.Modules.Limelight.Limelight_Light_States;
3+
import frc.robot.Modules.VisionSystems.Limelight.Limelight_Light_States;
44

55
public class FunStuff {
66
public static enum Music {
@@ -9,7 +9,7 @@ public static enum Music {
99
}
1010

1111
public static void RAVE_MODE() {
12-
Limelight.setLEDS(Limelight_Light_States.blink);
12+
VisionSystems.Limelight.setLEDS(Limelight_Light_States.blink);
1313
MotorControl.DriveCode.oldDriveTrain(0.6, -0.6);
1414
}
1515

@@ -21,4 +21,4 @@ public static void playMusic(Music sound) {
2121

2222
}
2323
}
24-
}
24+
}

src/main/java/frc/robot/Modules/Intake.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public static void rollers() { // Had absolute value of getRightY, would never b
2121
}
2222

2323
/** The stupid thing that looks cool but doesnt really work // edit: it works apparently
24-
* This function is called when the left joystick is moved in the Y direction.
24+
* This function is called when the left joystick is moved in the Y direction.
2525
* If the joystick is moved up, the wrist is set to the output of the joystick multiplied by the
26-
* transfer percentage.
26+
* transfer percentage.
2727
* If the joystick is moved down, the wrist is set to 0
2828
*/
2929
public static void wrist() {

src/main/java/frc/robot/Modules/Limelight.java

-136
This file was deleted.

src/main/java/frc/robot/Modules/MotorControl.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
public class MotorControl {
1919
/**
2020
* Given the ideal velocity and the transfer percentage, return the RPM
21-
*
21+
*
2222
* @param idealVelocity the velocity you want to achieve in meters per second
2323
* @param transferPercent the percentage of the ideal velocity that is transferred to the wheel.
2424
* @return The RPM of the motor.
@@ -29,7 +29,7 @@ public static double getRPM(double idealVelocity, double transferPercent) {
2929

3030
/**
3131
* This function returns the current velocity of the motor. The motor must be a Falcon500
32-
*
32+
*
3333
* @param motor The motor you want to get the velocity of.
3434
* @return The integrated sensor velocity of the motor.
3535
*/
@@ -39,7 +39,7 @@ public static double getCurrentVelocity(WPI_TalonFX motor) { // If using a Talon
3939

4040
/**
4141
* This function returns the current position of the motor. The motor must be a Falcon500
42-
*
42+
*
4343
* @param motor The motor you want to get the current position of.
4444
* @return The current position of the motor.
4545
*/
@@ -96,10 +96,10 @@ public static void motor_init() {
9696
// Robot.shooterFly.config_kD(0, RobotInformation.PID_Values.flywheel.kD, 1); // (D) Differentiable Term
9797

9898
}
99-
99+
100100
/**
101101
* This function sets the RPM of a motor
102-
*
102+
*
103103
* @param position The motor position to set the RPM for.
104104
* @param RPM The RPM of the motor.
105105
*/
@@ -116,7 +116,7 @@ public static void setRPM(MotorPositions position, int RPM) {
116116

117117
break;
118118
case Extension:
119-
119+
120120
break;
121121
case Rotation:
122122

@@ -127,22 +127,25 @@ public static void setRPM(MotorPositions position, int RPM) {
127127
}
128128
}
129129

130+
/**
131+
* This class is used to control the drivetrain of the robot
132+
*/
130133
public static class DriveCode {
131134
/** Main Drive Call */
132135
public static void tankDrive() {
133136
if ((Math.abs(Robot.rightJoy.getY()) > 0.2) || Math.abs(Robot.leftJoy.getY()) > 0.2) {
134137
Robot.drive.tankDrive((-Robot.rightJoy.getY() * RobotInformation.DriveTeamInfo.driverPercentage), (Robot.leftJoy.getY() * RobotInformation.DriveTeamInfo.driverPercentage));// TODO: adjust deadzones
135138
}
136139
}
137-
140+
138141
/** Move the Robot Backwards at -0.1 speed (should be a PID loop imo) */
139142
public static void moveBack() {
140143
Robot.drive.tankDrive(-0.1, -0.1);
141144
}
142-
145+
143146
/**
144147
* Drive the robot using the left and right master motors at the given motor speeds.*
145-
*
148+
*
146149
* @param motorSpeedLeft The speed that you want the left motor to go.
147150
* @param motorSpeedRight The speed that you want the right side to go.
148151
*/

0 commit comments

Comments
 (0)