Skip to content

Commit

Permalink
Merge branch 'main' into 126-make-trap-sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
1038 Pit authored and 1038 Pit committed Apr 4, 2024
2 parents 907d0ac + 5038798 commit d21eaac
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 114 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.3.1"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
},
{
"anchor": {
"x": 8.54,
"y": 7.34
"x": 8.515833783804318,
"y": 7.4608705342766815
},
"prevControl": {
"x": 7.904677120863775,
"y": 7.5503162432548745
"x": 7.825878671700363,
"y": 7.3556231442947215
},
"nextControl": null,
"isLocked": false,
Expand Down Expand Up @@ -82,7 +82,7 @@
},
"goalEndState": {
"velocity": 0,
"rotation": 0.0,
"rotation": 8.62,
"rotateFast": false
},
"reversed": false,
Expand Down
14 changes: 7 additions & 7 deletions src/main/deploy/pathplanner/paths/From midline note to amp.path
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"waypoints": [
{
"anchor": {
"x": 8.540000000000001,
"y": 7.343809471653955
"x": 8.515833783804318,
"y": 7.4608705342766815
},
"prevControl": null,
"nextControl": {
"x": 8.683718987153075,
"y": 7.280092322567236
"x": 8.659552770957392,
"y": 7.397153385189962
},
"isLocked": false,
"linkedName": "MidAcquireTopNote"
Expand Down Expand Up @@ -48,11 +48,11 @@
},
{
"anchor": {
"x": 1.95,
"x": 2.0,
"y": 8.1
},
"prevControl": {
"x": 2.514708547080911,
"x": 2.5647085470809112,
"y": 8.05967115979816
},
"nextControl": null,
Expand Down Expand Up @@ -83,7 +83,7 @@
"reversed": false,
"folder": null,
"previewStartingState": {
"rotation": 0.0,
"rotation": 8.62,
"velocity": 0
},
"useDefaultConstraints": true
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/frc/robot/commands/ShootPasserCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ public ShootPasserCommand() {
@Override
public void initialize() {
timer.start();
passer.shoot();
}

@Override
public void execute() {
scoring.feedForPasser();
passer.shoot();
if (!storage.noteExitingStorage()) {
storage.stopStorage();
} else {
if (timer.get() > 0.25) {
scoring.feedForPasser();
storage.runStorage();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/frc/robot/constants/DrawbridgeConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class DrawbridgeConstants {
public static final int rightServoPort = 3;

public static final double minLeftDrawbridgeExtension = 0.0;
public static final double maxLeftDrawbridgeExtension = 0.3;
public static final double minRightDrawbridgeExtension = 0.08;
public static final double maxRightDrawbridgeExtension = 0.45;
public static final double maxLeftDrawbridgeExtension = 0.65;
public static final double minRightDrawbridgeExtension = 0.0;
public static final double maxRightDrawbridgeExtension = 0.6;
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/constants/NeoMotorConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public final class NeoMotorConstants {
public static final double kVortexFreeSpeedRpm = 6784;
public static final double kNeo550FreeSpeedRpm = 11000;
public static final int kMaxNeoCurrent = 50; // amps
public static final int kMaxVortexCurrent = 50; // amps
public static final int kMaxVortexCurrent = 70; // amps
public static final int kMaxNeo550Current = 20; // amps
public static final double kMinPower = 0.05;
public static final double kMaxPower = 1.0;
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/frc/robot/constants/PneumaticsConstants.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class ScoringElevatorConstants {
public static final double elevatorEncoderConversionFactor = 1 / (maxElevatorEncoderCounts / maxElevatorInches);

public static final double groundSetpoint = 0;
public static final double ampSetpoint = 4.0;
public static final double passerSetpoint = 6.0;
public static final double ampSetpoint = 4.5;
public static final double passerSetpoint = 6.75;
public static final double trapSetpoint = 15.0;

public static final double maxDistance = 0;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/frc/robot/constants/VisionConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ public final class VisionConstants {
public static final String kValuesTopic = "values";
public static final String kRecordingTopic = "recording";
public static final String kStreamCam0 = "shouldStream0";
public static final String kEnabled0Topic = "on0";
public static final String kEnabled1Topic = "on1";
public static final String kEnabled0Topic = "enable0";
public static final String kEnabled1Topic = "enable1";

public static final double width = 640;
public static final double height = 480;
public static final double width = 1280;
public static final double height = 720;
public static final double fov = 100;

public static final double driveP = 0.005;
public static final double driveI = 0;
Expand Down
85 changes: 28 additions & 57 deletions src/main/java/frc/robot/subsystems/Vision.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@
public class Vision extends SubsystemBase {
// Enum for different things vision can find
public enum VisionTarget {
APR1(0),
APT2(1),
APT3(2),
APT4(3),
APT5(4),
APT6(5),
APT7(6),
APT8(7),
APT9(8),
APT10(9),
APT11(10),
APT12(11),
APT13(12),
APT14(13),
APT15(14),
APT16(15),
GAVIN(16),
NOTE(17);
NOTE(0),
APR1(1),
APT2(2),
APT3(3),
APT4(4),
APT5(5),
APT6(6),
APT7(7),
APT8(8),
APT9(9),
APT10(10),
APT11(11),
APT12(12),
APT13(13),
APT14(14),
APT15(15),
APT16(16);

public final int id;

Expand All @@ -57,7 +56,7 @@ public enum CameraStream {
private boolean recording = false;
private boolean enabled0 = false;
private boolean enabled1 = false;
private List<VisionData> visionData;
private List<VisionData> visionData = new ArrayList<VisionData>();

// Network Tables Setup
NetworkTableInstance inst = NetworkTableInstance.getDefault();
Expand All @@ -84,18 +83,21 @@ public static Vision getInstance() {
}

private Vision() {
streamCam0Publisher.set(true);
enabled0Publisher.set(false);
enabled1Publisher.set(false);
recordingPublisher.set(false);
}

@Override
public void periodic() {
String value = valuesSubscriber.get();
try {
JSONArray unparsedData = (JSONArray) jsonParser.parse(value);
visionData = new ArrayList<VisionData>();
visionData.clear();
for (Object data : unparsedData) {
JSONObject jsonObject = (JSONObject) data;
VisionData mappedData = new VisionData((String) jsonObject.get("x"), (String) jsonObject.get("y"),
(String) jsonObject.get("area"), (String) jsonObject.get("conf"),
(String) jsonObject.get("id"));
visionData.add(mappedData);
}
Expand Down Expand Up @@ -166,46 +168,15 @@ public double getY(VisionTarget target) {
return -1;
}

public double getArea(VisionTarget target) {
for (int i = 0; i < visionData.size(); i++) {
if (visionData.get(i).getTarget() == target) {
return visionData.get(i).getArea();
}
}
return -1;
}

public double getAngle(VisionTarget target) {
double x = getX(target);
double y = getY(target);
if (x < VisionConstants.width / 2) {
x = -getX(target);
}
if (y < VisionConstants.height / 2) {
y = -y;

if (x == -1) {
return 0;
}
return Math.toDegrees(Math.atan(x / y));
}

public double getDistance(VisionTarget target) {
double y = getY(target);
double oldY = 0.0;
x = x - (VisionConstants.width / 2);

if (target == VisionTarget.NOTE) {
if (y > oldY) {
oldY = y;
return 0;
} else {
oldY = 0.0;
return -1;
}

} else if (target.id >= VisionTarget.APR1.id && target.id <= VisionTarget.APT16.id) {
double area = getArea(target);
return area;
} else {
return 1;
}
return x / (VisionConstants.width / (VisionConstants.fov / 2));
}

}
14 changes: 3 additions & 11 deletions src/main/java/frc/robot/utils/VisionData.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@
public class VisionData {
private double x;
private double y;
private double area;
private double confidence;
private VisionTarget target;

public VisionData(String x, String y, String area, String confidence, String target) {
public VisionData(String x, String y, String target) {
System.out.println("x " + x + " y " + y);
this.x = Double.parseDouble(x);
this.y = Double.parseDouble(y);
this.area = Double.parseDouble(area);
this.confidence = Double.parseDouble(confidence);
this.target = VisionTarget.values()[Integer.parseInt(target)];
}

@Override
public String toString() {
return "x: " + this.x + " y: " + this.y + " area: " + this.area + " conf: " + this.confidence + " tgt: "
+ this.target;
return "x: " + this.x + " y: " + this.y + " area: " + " tgt: " + this.target;
}

public double getX() {
Expand All @@ -34,8 +30,4 @@ public double getY() {
public VisionTarget getTarget() {
return target;
}

public double getArea() {
return area;
}
}
6 changes: 3 additions & 3 deletions vendordeps/PathplannerLib.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fileName": "PathplannerLib.json",
"name": "PathplannerLib",
"version": "2024.2.4",
"version": "2024.2.8",
"uuid": "1b42324f-17c6-4875-8e77-1c312bc8c786",
"frcYear": "2024",
"mavenUrls": [
Expand All @@ -12,15 +12,15 @@
{
"groupId": "com.pathplanner.lib",
"artifactId": "PathplannerLib-java",
"version": "2024.2.4"
"version": "2024.2.8"
}
],
"jniDependencies": [],
"cppDependencies": [
{
"groupId": "com.pathplanner.lib",
"artifactId": "PathplannerLib-cpp",
"version": "2024.2.4",
"version": "2024.2.8",
"libName": "PathplannerLib",
"headerClassifier": "headers",
"sharedLibrary": false,
Expand Down
10 changes: 5 additions & 5 deletions vendordeps/REVLib.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fileName": "REVLib.json",
"name": "REVLib",
"version": "2024.2.3",
"version": "2024.2.4",
"frcYear": "2024",
"uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb",
"mavenUrls": [
Expand All @@ -12,14 +12,14 @@
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-java",
"version": "2024.2.3"
"version": "2024.2.4"
}
],
"jniDependencies": [
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-driver",
"version": "2024.2.3",
"version": "2024.2.4",
"skipInvalidPlatforms": true,
"isJar": false,
"validPlatforms": [
Expand All @@ -37,7 +37,7 @@
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-cpp",
"version": "2024.2.3",
"version": "2024.2.4",
"libName": "REVLib",
"headerClassifier": "headers",
"sharedLibrary": false,
Expand All @@ -55,7 +55,7 @@
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-driver",
"version": "2024.2.3",
"version": "2024.2.4",
"libName": "REVLibDriver",
"headerClassifier": "headers",
"sharedLibrary": false,
Expand Down

0 comments on commit d21eaac

Please sign in to comment.