# Limelight pipeline and code help

help

Hi all,

I am the single programmer for my team and with our first competition on week 1 I was wondering if anyone could provide some assistance with the limelight code and pipeline.

First off, the pipeline seems to be really iffy… It begins to track a static elevator, climber bar, and most commonly the ceiling lights. I do not know how to tune the pipeline to not do this beyond include/exclude/eyedropper. This only seems to be a problem when tracking past the trench.

If anyone could DM me a pre-tuned pipeline that I could tweak that would be great.

Now regarding the code… What I have works 60% of the time. It seems the tracking angle is off more than I want it to be and only works in the “right” correction direction. The goToDistance method is entirely broken.

This is my limelight.java code

``````	public static void dumbLineup(double distance) {
Limelight.testFeed();
double x = Math.abs(Limelight.getX()) - 5;
double power = x * 0.03;
if (Limelight.getX() >= 5d || Limelight.getX() <= -5d) {
if (Limelight.getX() > 5) {
// System.out.println("Should Be Moving Right");
if (Limelight.getX() < 5) {
goToDistance(distance); // go to distance
}
}
} else if (Limelight.getX() < -5) {
if (Limelight.getX() > -5) {
goToDistance(distance); // go to distance
}
}
}

public static void goToDistance(double setDistanceInInches) {
double distance = Utils.distanceCalulator(Limelight.getY());
System.out.println(distance);

if (distance <= setDistanceInInches - 10) { // 10 acts as a range
DriveTrain.drive(-0.3, -0.3); // should go back if distance is short
} else if (distance >= setDistanceInInches + 10) { // 10 acts as a range
DriveTrain.drive(0.3, 0.3); // should drive forward
} else {
DriveTrain.drive(0, 0);
}
}
``````

This is my distance calculator…

``````	public static double distanceCalulator(double ty) {
return ((Constants.POWERPORT_HEIGHT - Constants.CAMERA_HEIGHT) / (Math.tan(degToRad(Constants.CAMERA_ANGLE) + degToRad(ty))));
}
``````

This is my teleop.java code where its executed

``````if (driver.getLeftBumper()) { // If the left bumper is pressed
Limelight.changePipeline(1); // changes Limelight vision pipeline to 1

if (Limelight.hasValidTargets()) { // If limelight sees a target
if (driver.getLeftBumper()) {
driver.setLeftRumble(0.8);
driver.setRightRumble(0.8);

//If Limelight X cross hair is set X distance away
if (Limelight.getX() <= 6d && Limelight.getX() >= -6d) {
} else {
Limelight.dumbLineup(120); //Limelight lineup
}
} else {
if (DriveTrain.ispidEnabled()) {
DriveTrain.pidDisable(); // Turn off pid
}
DriveTrain.curvatureDrive(linearSpeed, curveSpeed, driver.getRightBumper()); // Drive Curvature
}
``````

Any help would be appreciated! Thanks.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.