-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ThePinkAlliance/develop
- Loading branch information
Showing
19 changed files
with
398 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/ThePinkAlliance/core/annotations/Untested.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.ThePinkAlliance.core.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
|
||
public @interface Untested { | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/ThePinkAlliance/core/ctre/talon/TalonUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.ThePinkAlliance.core.ctre.talon; | ||
|
||
public abstract class TalonUtils { | ||
|
||
public static double FULL_TALON_ROTATION_TICKS = 2048; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
src/main/java/com/ThePinkAlliance/core/limelight/Limelight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package com.ThePinkAlliance.core.limelight; | ||
|
||
import edu.wpi.first.networktables.NetworkTable; | ||
import edu.wpi.first.networktables.NetworkTableEntry; | ||
import edu.wpi.first.networktables.NetworkTableInstance; | ||
|
||
public class Limelight { | ||
|
||
public enum LED_MODE { | ||
BLINK(2), | ||
ON(3), | ||
OFF(1), | ||
PIPELINE(0); | ||
|
||
private int mode; | ||
|
||
LED_MODE(int mode) { | ||
this.mode = mode; | ||
} | ||
|
||
public int get() { | ||
return mode; | ||
} | ||
} | ||
|
||
public enum GAME_TARGET_HEIGHTS { | ||
RAPID_REACT_TOP_HUB(102.375); | ||
|
||
private double height; | ||
|
||
GAME_TARGET_HEIGHTS(double height) { | ||
this.height = height; | ||
} | ||
|
||
public double get() { | ||
return height; | ||
} | ||
} | ||
|
||
LED_MODE CURRENT_LED_MODE; | ||
|
||
double HEIGHT_FROM_FLOOR; | ||
double MOUNTED_ANGLE; | ||
double REFLECTED_TAPE_HEIGHT; | ||
double HORIZONTAL_OFFSET; | ||
|
||
NetworkTable table; | ||
NetworkTableEntry ty; | ||
NetworkTableEntry tx; | ||
NetworkTableEntry tv; | ||
NetworkTableEntry ledMode; | ||
|
||
/** | ||
* @param height_from_floor The limelight lens height from the floor in inches. | ||
* @param mounted_angle The current pitch angle of the limelight on its mount. | ||
*/ | ||
public Limelight(double height_from_floor, double mounted_angle) { | ||
this.HEIGHT_FROM_FLOOR = height_from_floor; | ||
this.MOUNTED_ANGLE = mounted_angle; | ||
this.REFLECTED_TAPE_HEIGHT = GAME_TARGET_HEIGHTS.RAPID_REACT_TOP_HUB.get(); | ||
this.HORIZONTAL_OFFSET = 0; | ||
|
||
configureLimelight(); | ||
} | ||
|
||
/** | ||
* @param height_from_floor The limelight lens height from the floor in inches. | ||
* @param mounted_angle The current pitch angle of the limelight on its mount. | ||
* @param horizontal_offset The angluar offset of the limelight from the center of the robot. | ||
*/ | ||
public Limelight( | ||
double height_from_floor, | ||
double mounted_angle, | ||
double horizontal_offset | ||
) { | ||
this.HEIGHT_FROM_FLOOR = height_from_floor; | ||
this.MOUNTED_ANGLE = mounted_angle; | ||
this.REFLECTED_TAPE_HEIGHT = GAME_TARGET_HEIGHTS.RAPID_REACT_TOP_HUB.get(); | ||
this.HORIZONTAL_OFFSET = horizontal_offset; | ||
|
||
configureLimelight(); | ||
} | ||
|
||
private void configureLimelight() { | ||
this.CURRENT_LED_MODE = LED_MODE.OFF; | ||
|
||
this.table = NetworkTableInstance.getDefault().getTable("limelight"); | ||
this.ty = this.table.getEntry("ty"); | ||
this.tx = this.table.getEntry("tx"); | ||
|
||
this.ledMode = this.table.getEntry("ledMode"); | ||
this.tv = this.table.getEntry("tv"); | ||
|
||
// Configure the limelight led's, camera mode and pipeline | ||
this.ledMode.setNumber(this.CURRENT_LED_MODE.get()); | ||
this.table.getEntry("camMode").setNumber(0); | ||
this.table.getEntry("pipeline").setNumber(0); | ||
} | ||
|
||
/** | ||
* | ||
* @param targetHeight The height of the reflective tape in inches. | ||
*/ | ||
public void configureTargetHeight(double targetHeight) { | ||
this.REFLECTED_TAPE_HEIGHT = targetHeight; | ||
} | ||
|
||
/** | ||
* | ||
* @param targetHeight The height of the reflective tape in inches. | ||
*/ | ||
public void configureTargetHeight(GAME_TARGET_HEIGHTS targetHeight) { | ||
this.configureTargetHeight(targetHeight.get()); | ||
} | ||
|
||
public double calculateAngleOffset() { | ||
return tx.getDouble(0) + HORIZONTAL_OFFSET; | ||
} | ||
|
||
/** | ||
* | ||
* @return if any valid targets are found. | ||
*/ | ||
public boolean foundTarget() { | ||
return tv.getDouble(0) > 0; | ||
} | ||
|
||
/** | ||
* | ||
* @return amount of valid targets are found. | ||
*/ | ||
public double foundTargets() { | ||
return tv.getDouble(0); | ||
} | ||
|
||
/** | ||
* Returns the horizontal difference from the center of the detected target. | ||
*/ | ||
public double getHorizontalDiff() { | ||
return this.tx.getDouble(0); | ||
} | ||
|
||
public double calculateDistance() { | ||
double verticalOffset = ty.getDouble(0); | ||
double targetAngleDeg = MOUNTED_ANGLE + verticalOffset; | ||
|
||
return ( | ||
(REFLECTED_TAPE_HEIGHT - HEIGHT_FROM_FLOOR) / | ||
Math.tan(Math.toRadians(targetAngleDeg)) | ||
); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/com/ThePinkAlliance/core/limelight/LimelightConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.ThePinkAlliance.core.limelight; | ||
|
||
public class LimelightConstants {} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/ThePinkAlliance/core/math/InterpolatingTimestamp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.ThePinkAlliance.core.math; | ||
|
||
import edu.wpi.first.math.interpolation.TimeInterpolatableBuffer.InterpolateFunction; | ||
|
||
public class InterpolatingTimestamp implements InterpolateFunction<Double> { | ||
|
||
@Override | ||
public Double interpolate(Double start, Double end, double t) { | ||
return null; | ||
} | ||
} |
Oops, something went wrong.