Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
stuff for multi note
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSkylake committed Jan 30, 2024
1 parent 43f855a commit ec0d404
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ public class Constants {

public static final Transform3d FRONT_APRILTAG_CAMERA_OFFSET = new Transform3d(0, 0, 0.43815, new Rotation3d(0, Math.toRadians(-23.6607), 0));
public static final Transform3d REAR_APRILTAG_CAMERA_OFFSET = new Transform3d(0, 0, 0, new Rotation3d());
public static final double FRONT_NOTE_CAMERA_HFOV = 53;

}
4 changes: 3 additions & 1 deletion src/main/java/frc/robot/subsystems/cameras/Note.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
import java.util.ArrayList;
import java.util.List;

import edu.wpi.first.math.Nat;
import edu.wpi.first.math.estimator.KalmanFilter;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.numbers.N1;

public class Note {
public Translation2d position;
private List<Translation2d> pointCloud;
private final double MAX_ERROR_METERS = 0.5;


public Note(Translation2d initialPose) {
this.position = initialPose;
this.pointCloud = new ArrayList<>();
Expand Down
33 changes: 19 additions & 14 deletions src/main/java/frc/robot/subsystems/cameras/NoteDetectorCamera.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,29 @@ private Note getNearestNote() {
@Override
public void periodic() {
for (PhotonTrackedTarget t : getTargets()) {
// Translation2d notePose = estimateNotePose(t);

// if (notes.isEmpty()) {
// notes.add(new Note(notePose));
// } else {
// for (Note n : notes) {
// if (!n.addPose(notePose)) {
// notes.add(new Note(notePose));
// break;
// }
// }
// }
Translation2d notePose = estimateNotePose(t);

if (notes.isEmpty()) {
notes.add(new Note(notePose));
} else {
for (Note n : notes) {
if (!n.addPose(notePose)) {
notes.add(new Note(notePose));
}
}
}



notes.get(0).addPose(notePose);
}

RobotContainer.field.getObject("note").setPose(new Pose2d(notes.get(0).position, new Rotation2d()));
//RobotContainer.field.getObject("note").setPose(new Pose2d(getNearestNote().position, new Rotation2d()));
List<Pose2d> allNotes = new ArrayList<>();
for (Note n : notes) {
allNotes.add(new Pose2d(n.position, new Rotation2d()));
}

RobotContainer.field.getObject("note").setPoses(allNotes);
}


Expand Down

0 comments on commit ec0d404

Please sign in to comment.