Skip to content

Commit f0a98b5

Browse files
committed
work please +1
1 parent af9cfa8 commit f0a98b5

20 files changed

+196
-183
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package frc.team5115.Auto.AutoCommands;
2+
3+
import edu.wpi.first.wpilibj.GenericHID;
4+
import edu.wpi.first.wpilibj.Joystick;
5+
import edu.wpi.first.wpilibj2.command.CommandBase;
6+
import frc.team5115.Subsystems.Drivetrain;
7+
import frc.team5115.Subsystems.Limelight;
8+
import frc.team5115.Subsystems.Locationator;
9+
import frc.team5115.Subsystems.Shooter;
10+
11+
import static frc.team5115.Constants.JOYSTICK_Y_AXIS_ID;
12+
import static frc.team5115.Constants.Pipeline;
13+
14+
15+
public class AssistedShootHighGoal extends CommandBase {
16+
17+
Drivetrain drivetrain;
18+
Locationator locationator;
19+
Shooter shooter;
20+
Limelight limelight;
21+
Joystick joystick;
22+
23+
/*
24+
1. Aim at the thing using the limelight
25+
2. Shoot the balls while stopped.
26+
*/
27+
28+
public AssistedShootHighGoal(Drivetrain drivetrain, Shooter shooter, Limelight limelight, Joystick joystick) {
29+
this.drivetrain = drivetrain;
30+
this.shooter = shooter;
31+
this.limelight = limelight;
32+
this.joystick = joystick;
33+
addRequirements(drivetrain, shooter);
34+
limelight.setPipeline(Pipeline.GreenLedMode);
35+
System.out.println("Starting goal assist but not throttle constructor");
36+
37+
}
38+
39+
@Override
40+
public void initialize() {
41+
System.out.println("Starting High Goal Aiming but not throttle");
42+
}
43+
44+
@Override
45+
public void execute() {
46+
double angle = 127;
47+
if (limelight.hasTarget() && limelight.getYAngle() > 0) { // if we don't have a target
48+
angle = limelight.getXAngle();
49+
} else {
50+
System.out.println("Error No Target Found"); //todome set to shuffleboard.
51+
System.out.println(limelight.getYAngle());
52+
drivetrain.XBoxDrive(joystick);
53+
return;
54+
}
55+
//System.out.println("angle = " + (angle - locationator.getAngle()));
56+
drivetrain.relativeAngleHold(angle, -joystick.getRawAxis(JOYSTICK_Y_AXIS_ID));
57+
}
58+
59+
@Override
60+
public void end(boolean interrupted) {
61+
if (interrupted) System.out.println("Error: Interrupted");
62+
drivetrain.stop();
63+
}
64+
65+
@Override
66+
public boolean isFinished() {
67+
return false; //never needed, command ends itself.
68+
}
69+
}

src/main/java/frc/team5115/Auto/AutoCommands/DriveDistance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void execute() {
3232
System.out.println("targetLocation = " + targetLocation);
3333
double angle = locationator.getCurrentLocation().angleFrom(targetLocation);
3434
double throttle = Drivetrain.clamp(locationator.getCurrentLocation().distanceFrom(targetLocation)/50 * Drivetrain.clamp(Math.abs((25/(angle - locationator.getAngle()))),1),
35-
Constants.MAX_AUTO_THROTTLE);
35+
Constants.AUTO_MAX_THROTTLE);
3636
System.out.println("Angle hold: " + angle + " Throttle: " + throttle);
3737
drivetrain.angleHold(angle,throttle);
3838
}

src/main/java/frc/team5115/Auto/AutoCommands/FollowGreen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public void execute() {
5757
return;
5858
}
5959

60-
throttle = -(SHOOTIN_DISTANCE - limelight.calculateDistanceFromBase())/100;
61-
throttle = Drivetrain.clamp(throttle, MAX_AUTO_THROTTLE); //max speed 0.5. Also add a minimum speed of 0.1.
60+
throttle = -(AUTO_SHOOTIN_DISTANCE - limelight.calculateDistanceFromBase())/100;
61+
throttle = Drivetrain.clamp(throttle, AUTO_MAX_THROTTLE); //max speed 0.5. Also add a minimum speed of 0.1.
6262
//System.out.println("Distance from the base: " + limelight.calculateDistanceFromBase() + " throttle: " + throttle);
6363
throttle = 0; //eliminate to return forward backward handling.
6464
drivetrain.angleHold(angle, throttle);
Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
package frc.team5115.Auto.AutoCommands;
22

3-
import edu.wpi.first.wpilibj.GenericHID;
4-
import edu.wpi.first.wpilibj.Joystick;
53
import edu.wpi.first.wpilibj2.command.CommandBase;
6-
import frc.team5115.Constants;
74
import frc.team5115.Subsystems.Drivetrain;
5+
import frc.team5115.Subsystems.Feeder;
86
import frc.team5115.Subsystems.Limelight;
97
import frc.team5115.Subsystems.Locationator;
108

11-
import static frc.team5115.Constants.MAX_AUTO_THROTTLE;
9+
import static frc.team5115.Constants.*;
1210

1311
public class PickupBallAuto extends CommandBase {
1412

1513
Drivetrain drivetrain;
1614
Locationator locationator;
1715
Limelight limelight;
18-
private final Joystick joystick;
16+
Feeder feeder;
1917
boolean foundBall;
2018

21-
public PickupBallAuto(Drivetrain drivetrain, Locationator locationator, Limelight limelight, Joystick joystick) {
22-
this.drivetrain = drivetrain;
23-
this.locationator = locationator;
24-
this.limelight = limelight;
25-
this.joystick = joystick;
26-
foundBall = false;
27-
}
2819

29-
public PickupBallAuto(Drivetrain drivetrain, Locationator locationator, Limelight limelight) {
20+
public PickupBallAuto(Drivetrain drivetrain, Locationator locationator, Limelight limelight, Feeder feeder) {
3021
this.drivetrain = drivetrain;
3122
this.locationator = locationator;
3223
this.limelight = limelight;
33-
joystick = null;
24+
this.feeder = feeder;
3425
foundBall = false;
3526
}
3627
/*
@@ -40,7 +31,7 @@ public PickupBallAuto(Drivetrain drivetrain, Locationator locationator, Limeligh
4031

4132
@Override
4233
public void initialize() {
43-
limelight.setPipeline(Constants.Pipeline.CustomGripPipeline);
34+
limelight.setPipeline(Pipeline.Balls);
4435
drivetrain.stop();
4536
}
4637
/*on loop:
@@ -49,44 +40,37 @@ public void initialize() {
4940
double lastAngle;
5041
@Override
5142
public void execute() {
43+
limelight.setPipeline(Pipeline.Balls);
44+
System.out.println("working");
5245
double angle;
53-
if (limelight.hasTarget() && limelight.getYAngle() + Constants.CAMERA_ANGLE < 0) { // if we have a target
46+
if (limelight.hasTarget()) { // if we have a target
47+
System.out.println("Have target");
5448
angle = limelight.getXAngle() + locationator.getAngle();
5549
foundBall = true;
5650
lastAngle = angle;
5751
} else {
58-
System.out.println("Can't find a ball.");
52+
5953
if(foundBall) //if we have found that shit before, go there.
60-
drivetrain.angleHold(lastAngle, MAX_AUTO_THROTTLE);
54+
drivetrain.angleHold(lastAngle, AUTO_MAX_THROTTLE);
6155
else
6256
drivetrain.stop();
6357
return;
6458
}
65-
boolean targetForDistance = false;
59+
6660
//true means it rolls after it. It will stop if it stops. False means it just goes at a constant speed.
67-
double throttle;
68-
if(targetForDistance) {
69-
double distanceFromBall = limelight.calculateDistanceFromBall();
70-
throttle = -(30 - limelight.calculateDistanceFromBase())
71-
/ 30;
72-
}else {
73-
throttle = MAX_AUTO_THROTTLE;
74-
}
61+
double throttle = AUTO_MAX_THROTTLE;
7562
System.out.println("throttle = " + throttle);
76-
throttle = Drivetrain.clamp(throttle, MAX_AUTO_THROTTLE); //max speed 0.5. Also add a minimum speed of 0.1.
7763
//throttle = 0;
7864
drivetrain.angleHold(angle, throttle);
7965
}
8066

8167
@Override
8268
public void end(boolean interrupted) {
83-
if (interrupted) System.out.println("Error: Interrupted");
84-
System.out.println("Done!");
8569
drivetrain.stop();
8670
}
8771

8872
@Override
8973
public boolean isFinished() {
90-
return false;
74+
return false;//feeder.isBall();
9175
} //todome make this from the intake sensor math.
9276
}

src/main/java/frc/team5115/Auto/AutoCommands/ShootHighGoal.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public void execute() {
5353
// System.out.println("limelight = " + limelight.calculateDistanceFromBase());
5454
// System.out.println("locationator = " + locationator.getUltrasonicDistanceInches());
5555

56-
throttle = -(SHOOTIN_DISTANCE - limelight.calculateDistanceFromBase())
56+
throttle = -(AUTO_SHOOTIN_DISTANCE - limelight.calculateDistanceFromBase())
5757
/ 50;
58-
throttle = Drivetrain.clamp(throttle, MAX_AUTO_THROTTLE); //max speed 0.5. Also add a minimum speed of 0.1.
58+
throttle = Drivetrain.clamp(throttle, AUTO_MAX_THROTTLE); //max speed 0.5. Also add a minimum speed of 0.1.
5959
System.out.println("Distance from the base: " + limelight.calculateDistanceFromBase() + " throttle: " + throttle);
6060
//System.out.println("angle = " + (angle - locationator.getAngle()));
6161
} else {
Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
21
package frc.team5115.Auto;
32

43
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
5-
import frc.team5115.Auto.AutoCommands.DriveDistance;
6-
import frc.team5115.Auto.AutoCommands.PickupBallAuto;
74
import frc.team5115.Auto.AutoCommands.ShootHighGoal;
5+
import frc.team5115.Constants;
86
import frc.team5115.Subsystems.Drivetrain;
97
import frc.team5115.Subsystems.Limelight;
108
import frc.team5115.Subsystems.Locationator;
@@ -14,7 +12,8 @@ public class AutoSeries extends SequentialCommandGroup {
1412

1513
public AutoSeries(Drivetrain drivetrain, Locationator locationator, Shooter shooter, Limelight limelight) {
1614

17-
System.out.println("Creating auto series.");
15+
limelight.setPipeline(Constants.Pipeline.DriveCamera);
16+
1817
final Loc2D overLineLocation = new Loc2D(
1918
locationator.getCurrentLocation().getX(), //goes strait forward.
2019
120);
@@ -23,23 +22,12 @@ public AutoSeries(Drivetrain drivetrain, Locationator locationator, Shooter shoo
2322

2423

2524
//These commands do a basic auto series.
26-
if(true) {
2725
addCommands(
2826
new ShootHighGoal(drivetrain,
2927
locationator,
3028
shooter,
3129
limelight)
32-
/*
33-
// Drive backward the specified distance
34-
new DriveDistance(afterShootLocation,
35-
drivetrain,
36-
locationator)
37-
*/
30+
//new PickupBallAuto(drivetrain,locationator,limelight)
3831
);
39-
} else {
40-
addCommands(
41-
new PickupBallAuto(drivetrain, locationator, limelight)
42-
);
43-
}
4432
}
45-
}
33+
}

src/main/java/frc/team5115/Commands/Intake/DriverIntake.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package frc.team5115.Commands.Intake;
22

33
import edu.wpi.first.wpilibj2.command.CommandBase;
4-
import frc.team5115.Robot.RobotContainer;
54
import frc.team5115.Subsystems.Intake;
65

76
public class DriverIntake extends CommandBase {

src/main/java/frc/team5115/Commands/Intake/IntakeBalls.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package frc.team5115.Commands.Intake;
22

33
import edu.wpi.first.wpilibj2.command.CommandBase;
4-
import frc.team5115.Robot.RobotContainer;
54
import frc.team5115.Subsystems.Intake;
65

76
public class IntakeBalls extends CommandBase {

src/main/java/frc/team5115/Commands/Intake/ReverseIntake.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package frc.team5115.Commands.Intake;
22

33
import edu.wpi.first.wpilibj2.command.CommandBase;
4-
import frc.team5115.Robot.RobotContainer;
54
import frc.team5115.Subsystems.Intake;
65

76
public class ReverseIntake extends CommandBase {

src/main/java/frc/team5115/Commands/Shooter/Shoot.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package frc.team5115.Commands.Shooter;
22
import edu.wpi.first.wpilibj2.command.CommandBase;
3-
import frc.team5115.Robot.*;
43
import frc.team5115.Subsystems.Shooter;
54

65
public class Shoot extends CommandBase {

0 commit comments

Comments
 (0)