Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR for vision branch - working note detection and new drive method. #62

Merged
merged 28 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c3e3518
added the drive to note position code back
SJJCoding Feb 6, 2024
d38721f
Implemented limelight get to distance command, should be able to run …
SJJCoding Feb 7, 2024
3112274
forgor to commit all the files in the last push
SJJCoding Feb 7, 2024
66ddf50
fixed limelight subsystem from gunga selling
SJJCoding Feb 10, 2024
e7f48bd
Merge remote-tracking branch 'upstream/main'
SJJCoding Feb 10, 2024
f7ffce4
implemented jonah rotation method
SJJCoding Feb 10, 2024
686d8dd
fixed command stuff and hopefully better turning methods
SJJCoding Feb 14, 2024
e75a199
Merge remote-tracking branch 'upstream/main'
SJJCoding Feb 21, 2024
42f8b9f
Cleaned up simpleDrive
SJJCoding Feb 22, 2024
0f9e8bc
Merge branch 'robototes:main' into main
SJJCoding Feb 22, 2024
f8ad4b8
Fixed the majority of PR comments
SJJCoding Feb 23, 2024
3c77ece
Merge branch 'main' of https://github.com/SJJCoding/Crescendo2024
SJJCoding Feb 23, 2024
8673859
Update src/main/java/frc/team2412/robot/subsystems/LimelightSubsystem…
SJJCoding Feb 23, 2024
ae0af8f
oscillation issue probably fixed
SJJCoding Feb 23, 2024
fa4def3
working turning method, fixed drivepower
SJJCoding Feb 24, 2024
456417f
Cleaned up a bunch of logic, removed the need for a DriveCommand or s…
SJJCoding Feb 25, 2024
5384c13
Some more PR related changes
SJJCoding Feb 25, 2024
189f119
Removed the old drive and turn power curves due to redundancy and re …
SJJCoding Feb 25, 2024
f781926
Majority of PR comments fixed
SJJCoding Feb 29, 2024
1d88e45
Merge branch 'main' into main
SJJCoding Mar 12, 2024
f57e583
spotlessapply
SJJCoding Mar 12, 2024
d68609d
Merge branch 'main' of https://github.com/SJJCoding/Crescendo2024
SJJCoding Mar 12, 2024
f34c970
fixed pr comments (again)
SJJCoding Mar 19, 2024
6dc22cc
Merge branch 'main' into main
SJJCoding Mar 19, 2024
e30a7bf
spotlessapply maybe
SJJCoding Mar 20, 2024
cfc6016
Merge branch 'main' of https://github.com/SJJCoding/Crescendo2024
SJJCoding Mar 20, 2024
1e6874b
removed redundant methods from limelightsubsystem
SJJCoding Mar 20, 2024
73b94f7
more cleanup
SJJCoding Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/frc/team2412/robot/Controls.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void bindDrivebaseControls() {
// leaving this code in in case we need to test outside of auto
/*
public void bindLimelightControls() {
getWithinDistanceTrigger.onTrue(
getWithinDistanceTrigger.whileTrue(
new DriveToNoteCommand(s.drivebaseSubsystem, s.limelightSubsystem));
}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ public DriveToNoteCommand(

@Override
public void execute() {
Translation2d move =
new Translation2d(
INVERT_DRIVE_DIRECTION
* Units.inchesToMeters(limelightSubsystem.getDistanceFromTargetInches()),
0.0);
Rotation2d turn =
new Rotation2d()
.fromDegrees(2 * INVERT_DRIVE_DIRECTION * limelightSubsystem.getHorizontalOffset());
drivebaseSubsystem.drive(move, turn, false);
if (limelightSubsystem.hasTargets()) {
Translation2d move =
new Translation2d(
INVERT_DRIVE_DIRECTION
* Units.inchesToMeters(limelightSubsystem.getDistanceFromTargetInches()),
0.0);
Rotation2d turn =
new Rotation2d()
.fromDegrees(2 * INVERT_DRIVE_DIRECTION * limelightSubsystem.getHorizontalOffset());
drivebaseSubsystem.drive(move, turn, false);
}
}

@Override
public boolean isFinished() {
return (limelightSubsystem.isWithinDistance());
return (limelightSubsystem.isWithinDistance() || !limelightSubsystem.hasTargets());
SJJCoding marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package frc.team2412.robot.subsystems;

import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableInstance;
Expand All @@ -23,7 +19,6 @@ public class LimelightSubsystem extends SubsystemBase {
final NetworkTable networkTable;

String currentPoseString;
String targetPoseString;

// network tables

Expand All @@ -34,7 +29,6 @@ public LimelightSubsystem() {

// logging
currentPoseString = "";
targetPoseString = "";

networkTable = NetworkTableInstance.getDefault().getTable("limelight");
ShuffleboardTab limelightTab = Shuffleboard.getTab("Limelight");
Expand All @@ -59,10 +53,6 @@ public LimelightSubsystem() {
.addString("Current Pose ", this::getCurrentPoseString)
.withPosition(0, 1)
.withSize(4, 1);
limelightTab
.addString("Target Pose ", this::getTargetPoseString)
.withPosition(0, 2)
.withSize(4, 1);
GOAL_DISTANCE_FROM_NOTE =
limelightTab
.addPersistent("Goal distance", 20.0)
Expand Down Expand Up @@ -102,41 +92,17 @@ public double getDistanceFromTargetInches() {

// distance = (W x F) / P
// returns inches for testing purposes, will divide by 39.3700787 to return meters
return (14 * focal_length) / getBoxWidth();
}

// tan(degree) * distance = sideways distance

// target height / tan(vertical angle)

public Pose2d getTargetPose(Pose2d currentPose) {

// math thing to get target pose using current pose

Rotation2d targetHeading =
new Rotation2d(
currentPose.getRotation().getRadians() + Units.degreesToRadians(getHorizontalOffset()));

double targetDistance = Units.inchesToMeters(getDistanceFromTargetInches());

Translation2d translationOffset = new Translation2d(targetDistance, targetHeading);
Pose2d targetPose =
new Pose2d(currentPose.getTranslation().plus(translationOffset), targetHeading);

currentPoseString = currentPose.toString();
targetPoseString = targetPose.toString();

return targetPose;
if (hasTargets()) {
return (14 * focal_length) / getBoxWidth();
} else {
return 0.0;
}
}

public String getCurrentPoseString() {
return currentPoseString;
}

public String getTargetPoseString() {
return targetPoseString;
}

public boolean isWithinDistance() {
return (getDistanceFromTargetInches() <= GOAL_DISTANCE_FROM_NOTE.getDouble(20.0));
}
Expand Down
Loading