For starters i should note that I am following team 364’s falcon base swerve code using mk4i modules.
I have a rough idea of how a command to balance your robot on the charging station would work in theory. Give your pidcontroller a setpoint (something like 0 degrees pitch) and then have it calculate an output based off of your error then feed it to your drive method. Within actual application this should be simple enough with tank system using a differential drive method to control your drive base.
Im confused on what would be the swerve equivalent of feeding your pid calculated values to your drive method since for translation control (forward and strafe) it accepts a translation2d value instead of a double. This is the exact method for reference:
public void drive(
Translation2d translation, double rotation, boolean fieldRelative, boolean isOpenLoop) {
SwerveModuleState[] states =
DriveConstants.kDriveKinematics.toSwerveModuleStates(
fieldRelative
? ChassisSpeeds.fromFieldRelativeSpeeds(
translation.getX(), translation.getY(), rotation, getRotation2d())
: new ChassisSpeeds(translation.getX(), translation.getY(), rotation));
SwerveDriveKinematics.desaturateWheelSpeeds(states, DriveConstants.kMaxSpeedMetersPerSecond);
for (SwerveModule mod : modules) {
mod.setDesiredState(states[mod.moduleNumber], isOpenLoop);
}
}
Any help/ideas are greatly appreciated.