Skip to content

Commit

Permalink
log pose with AdvKit
Browse files Browse the repository at this point in the history
  • Loading branch information
StewardHail3433 committed Mar 24, 2024
1 parent 85d3aa6 commit 967fc84
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main/java/frc/robot/subsystems/drive/DriveIO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package frc.robot.subsystems.drive;

import org.littletonrobotics.junction.AutoLog;

import edu.wpi.first.math.geometry.Pose2d;
import swervelib.SwerveDrive;

public class DriveIO {
@AutoLog
public static class DriveIOInputs {
public Pose2d pose;
public double poseX = 0.0;
public double poseY = 0.0;
public double poseRotInDegrees = 0.0;
}

/** Updates the set of loggable inputs. */
public void updateInputs(DriveIOInputs inputs, SwerveDrive swerveDrive) {
inputs.pose = swerveDrive.getPose();
inputs.poseX = inputs.pose.getTranslation().getX();
inputs.poseY = inputs.pose.getTranslation().getY();
inputs.poseRotInDegrees = inputs.pose.getRotation().getDegrees();
}

// Other methods for controlling the drive subsystem...
}
14 changes: 14 additions & 0 deletions src/main/java/frc/robot/subsystems/drive/DriveSwerveYAGSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import frc.robot.util.DevilBotState;
import java.io.File;
import org.littletonrobotics.junction.AutoLogOutput;
import org.littletonrobotics.junction.Logger;

import swervelib.SwerveDrive;
import swervelib.SwerveDriveTest;
import swervelib.parser.PIDFConfig;
Expand All @@ -25,6 +27,12 @@ public class DriveSwerveYAGSL extends DriveBase {
private SwerveDrive swerveDrive;
@AutoLogOutput private boolean fieldOrientedDrive = false;

// @AutoLogOutput
DriveIO io = new DriveIO();
private final DriveIOInputsAutoLogged inputs = new DriveIOInputsAutoLogged();



public DriveSwerveYAGSL(String configPath) {
swerveJsonDirectory = new File(Filesystem.getDeployDirectory(), configPath);

Expand Down Expand Up @@ -144,4 +152,10 @@ public double getAngle() {
public void lockPose() {
swerveDrive.lockPose();
}

@Override
public void periodic() {
io.updateInputs(inputs, swerveDrive);
Logger.processInputs("Drive", inputs);
}
}

0 comments on commit 967fc84

Please sign in to comment.