Skip to content

Commit

Permalink
tested pose est with the drive command but no worky
Browse files Browse the repository at this point in the history
  • Loading branch information
spellingcat committed Nov 11, 2023
1 parent 66162a2 commit 18a3961
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 141 deletions.
141 changes: 8 additions & 133 deletions src/main/deploy/pathplanner/pose test Blue.path
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"waypoints": [
{
"anchorPoint": {
"x": 2.3,
"y": 1.8
"x": 3.3,
"y": 1.0
},
"prevControl": null,
"nextControl": {
"x": 3.3000000000000003,
"y": 1.8
"x": 4.300000000000001,
"y": 1.0
},
"holonomicAngle": 180.0,
"isReversal": false,
Expand All @@ -24,140 +24,15 @@
},
{
"anchorPoint": {
"x": 4.737025208647575,
"y": 1.8
},
"prevControl": {
"x": 3.737025208647575,
"y": 1.8
},
"nextControl": {
"x": 3.737025208647575,
"y": 1.8
},
"holonomicAngle": 0,
"isReversal": true,
"velOverride": null,
"isLocked": false,
"isStopPoint": false,
"stopEvent": {
"names": [],
"executionBehavior": "parallel",
"waitBehavior": "none",
"waitTime": 0
}
},
{
"anchorPoint": {
"x": 2.5,
"y": 1.8
"x": 3.3,
"y": 1.0
},
"prevControl": {
"x": 2.014223686941068,
"y": 1.8
},
"nextControl": {
"x": 2.985776313058932,
"y": 1.8
},
"holonomicAngle": 180.0,
"isReversal": false,
"velOverride": null,
"isLocked": false,
"isStopPoint": false,
"stopEvent": {
"names": [],
"executionBehavior": "parallel",
"waitBehavior": "none",
"waitTime": 0
}
},
{
"anchorPoint": {
"x": 4.5,
"y": 1.8046074006839954
},
"prevControl": {
"x": 4.27385240613827,
"y": 1.8046074006839954
},
"nextControl": {
"x": 4.72614759386173,
"y": 1.8046074006839954
},
"holonomicAngle": 180.0,
"isReversal": false,
"velOverride": null,
"isLocked": false,
"isStopPoint": false,
"stopEvent": {
"names": [],
"executionBehavior": "parallel",
"waitBehavior": "none",
"waitTime": 0
}
},
{
"anchorPoint": {
"x": 2.5,
"y": 1.8
},
"prevControl": {
"x": 2.2428113772359337,
"y": 1.8
},
"nextControl": {
"x": 2.7571886227640663,
"y": 1.8
},
"holonomicAngle": 0,
"isReversal": false,
"velOverride": null,
"isLocked": false,
"isStopPoint": false,
"stopEvent": {
"names": [],
"executionBehavior": "parallel",
"waitBehavior": "none",
"waitTime": 0
}
},
{
"anchorPoint": {
"x": 4.5,
"y": 1.8
},
"prevControl": {
"x": 4.380109782805397,
"y": 1.8
},
"nextControl": {
"x": 4.619890217194603,
"y": 1.8
},
"holonomicAngle": 0.0,
"isReversal": false,
"velOverride": null,
"isLocked": false,
"isStopPoint": false,
"stopEvent": {
"names": [],
"executionBehavior": "parallel",
"waitBehavior": "none",
"waitTime": 0
}
},
{
"anchorPoint": {
"x": 2.3,
"y": 1.8
},
"prevControl": {
"x": 1.2999999999999998,
"y": 1.8
"y": 1.0
},
"nextControl": null,
"holonomicAngle": 0,
"holonomicAngle": 180.0,
"isReversal": false,
"velOverride": null,
"isLocked": false,
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,13 @@ public RobotContainer() {

autoSystemType.addDefaultOption("Choreo", AutoSystem.choreo);
autoSystemType.addOption("Path Planner", AutoSystem.pathplanner);

SmartDashboard.putData(
"pose test", swerveSubsystem.poseLockDriveCommand(
() -> 3.3, () -> 1, () -> 180, true, false));

}


/**
* Use this method to define your trigger->command mappings. Triggers can be created via the
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/frc/robot/subsystems/Swerve/SwerveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import java.util.NoSuchElementException;
import java.util.function.DoubleSupplier;
import org.littletonrobotics.junction.Logger;
import org.photonvision.PhotonCamera;
import org.photonvision.PhotonPoseEstimator.PoseStrategy;
import org.photonvision.targeting.PhotonPipelineResult;

Expand Down Expand Up @@ -255,7 +254,7 @@ public Command headingLockDriveCommand(
false);
}

public Command poseLockDriveCommand(
public CommandBase poseLockDriveCommand(
DoubleSupplier x,
DoubleSupplier y,
DoubleSupplier theta,
Expand All @@ -274,17 +273,17 @@ public Command poseLockDriveCommand(
deadband(
Constants.AutoConstants.xController.calculate(
pose.getX(), x.getAsDouble()),
0.05),
0),
() ->
deadband(
Constants.AutoConstants.yController.calculate(
pose.getY(), y.getAsDouble()),
0.05),
0),
() ->
deadband(
headingController.calculate(
pose.getRotation().getRadians() % (2 * Math.PI)),
0.05),
0),
fieldRelative,
isOpenLoop,
false)
Expand Down Expand Up @@ -513,9 +512,9 @@ public void setModuleStates(SwerveModuleState[] desiredStates) {

/** Return the pose of the drivebase, as estimated by the pose estimator. */
public Pose2d getPose() {
return wheelOnlyOdo.getPoseMeters();
// return wheelOnlyOdo.getPoseMeters();
// Use this if we want to use vision
// return poseEstimator.getEstimatedPosition();
return poseEstimator.getEstimatedPosition();
}

/** Resets the pose estimator to the given pose */
Expand Down Expand Up @@ -661,7 +660,7 @@ public void periodic() {
.estimatedPose;
Logger.getInstance().recordOutput("Vision Pose", visionMeasurement);
poseEstimator.addVisionMeasurement(visionMeasurement.toPose2d(), visionIOInputs.timestamp, VisionHelper.findVisionMeasurements(estPose));
resetOdometry(visionMeasurement.toPose2d());
//resetOdometry(visionMeasurement.toPose2d());
} catch (NoSuchElementException e) {}

double[] apriltagX = new double[visionIOInputs.targets.size() * 4];
Expand Down

0 comments on commit 18a3961

Please sign in to comment.