Skip to content

Commit

Permalink
Reset works now + more various updates
Browse files Browse the repository at this point in the history
  • Loading branch information
TimnJoey committed Dec 31, 2023
1 parent 760d958 commit 9eaafce
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 19 deletions.
24 changes: 24 additions & 0 deletions src/main/deploy/pathplanner/autos/New Auto.auto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1.0,
"startingPose": {
"position": {
"x": 1.5,
"y": 0.5
},
"rotation": 0
},
"command": {
"type": "sequential",
"data": {
"commands": [
{
"type": "path",
"data": {
"pathName": "Valk Testing Path"
}
}
]
}
},
"folder": null
}
6 changes: 3 additions & 3 deletions src/main/deploy/pathplanner/autos/Valk Testing.auto
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"version": 1.0,
"startingPose": {
"position": {
"x": 0.0,
"y": 0.0
"x": 1.5,
"y": 0.5
},
"rotation": 180.0
"rotation": 0.0
},
"command": {
"type": "sequential",
Expand Down
16 changes: 8 additions & 8 deletions src/main/deploy/pathplanner/paths/Valk Testing Path.path
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
"waypoints": [
{
"anchor": {
"x": 0.0,
"y": 0.0
"x": 1.5,
"y": 0.5
},
"prevControl": null,
"nextControl": {
"x": 0.8729429755192678,
"y": 0.0
"x": 1.0877785196461234,
"y": 0.4937454545319242
},
"isLocked": false
},
{
"anchor": {
"x": 0.5981713014108248,
"y": 0.0
"x": 0.19,
"y": 0.5
},
"prevControl": {
"x": 0.5935685068319716,
"y": 0.00475773116802268
"x": 0.18539720542114685,
"y": 0.5047577311680227
},
"nextControl": null,
"isLocked": false
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public void configureButtonBindings() {
@Override
public void populateDashboard() {
Shuffleboard.getTab("AutoBuilder");
Shuffleboard.getTab("AutoBuilder").add("Auto 1", autoChooser);
Shuffleboard.getTab("AutoBuilder").add("Auto", autoChooser);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Vision.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Vision(
}

public void setPose(Pose2d pose) {
odometry.resetPosition(Rotation2d.fromDegrees(driveMap.gyro().getAngle() - 180), getModulePositions(), pose);
estimator.resetPosition(Rotation2d.fromDegrees(driveMap.gyro().getAngle() - 180), getModulePositions(), pose);
}

// Estimated pose from a combination of vision and odometry
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/maps/subsystems/SwerveDriveMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class SwerveModuleData {
public double[] steeringTempC;
public SwerveModuleState desiredState = new SwerveModuleState();
public double steeringSetpoint;
public ChassisSpeeds speeds;

public SwerveModuleData(String name) {
this.name = name;
Expand All @@ -97,6 +98,8 @@ public void toLog(LogTable table) {
subTable.put("SteeringTempCelsius", this.steeringTempC);

subTable.put("SteeringSetpoint", this.steeringSetpoint);
// subTable.put("ChassisSpeeds", this.speeds);

}

public void fromLog(LogTable table) {
Expand All @@ -117,6 +120,7 @@ public void fromLog(LogTable table) {
this.steeringCurrentAmps = subTable.get("SteeringCurrentAmps", this.steeringCurrentAmps);
this.steeringTempC = subTable.get("SteeringTempCelsius", this.steeringTempC);
this.steeringSetpoint = subTable.get("SteeringSetpoint", this.steeringSetpoint);
// this.speeds = subTable.get("ChassisSpeeds", this.speeds);
}

public void update(SwerveModule module) {
Expand All @@ -129,6 +133,7 @@ public void update(SwerveModule module) {
this.steeringTempC = module.getSteeringMotor().getTemperatureC();
module.setDesiredState(this.desiredState);
this.steeringSetpoint = module.getSteeringMotor().get();
// this.speeds = module.ChassisSpeeds.get();
}

public SwerveModuleState getModuleStates() {
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/frc/robot/subsystems/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ public Pose2d getPose() {
return pose;
}

public void resetPose(Pose2d pose) {
this.pose = pose;
}

private Vision vision;
private Pose2d pose = new Pose2d();
private final DrivePID drivePID;
Expand Down Expand Up @@ -136,7 +132,7 @@ public Drive(SwerveDriveMap map) {

AutoBuilder.configureHolonomic(
this::getPose, // Robot pose supplier
this::resetPose, // Method to reset odometry (will be called if your auto has a starting pose)
vision::setPose, // Method to reset odometry (will be called if your auto has a starting pose)
this::getSpeeds, // ChassisSpeeds supplier. MUST BE ROBOT RELATIVE
this::move, // Method that will drive the robot given ROBOT RELATIVE ChassisSpeeds
new HolonomicPathFollowerConfig( // HolonomicPathFollowerConfig, this should likely live in your
Expand Down Expand Up @@ -294,7 +290,6 @@ private void move(final ChassisSpeeds speeds) {
io.rearRight.desiredState = moduleStates[3];

// All the states

}

public void setModuleStates(SwerveModuleState[] moduleStates) {
Expand Down

0 comments on commit 9eaafce

Please sign in to comment.