auto tuning + inverted DT sides
This commit is contained in:
parent
57e308f050
commit
cbf973e946
@ -8,19 +8,19 @@
|
|||||||
},
|
},
|
||||||
"prevControl": null,
|
"prevControl": null,
|
||||||
"nextControl": {
|
"nextControl": {
|
||||||
"x": 2.3216735004898608,
|
"x": 1.7449183616315946,
|
||||||
"y": 5.541275082550166
|
"y": 5.55472336015897
|
||||||
},
|
},
|
||||||
"isLocked": false,
|
"isLocked": false,
|
||||||
"linkedName": null
|
"linkedName": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"x": 2.289197721252586,
|
"x": 2.294543620426272,
|
||||||
"y": 5.541275082550166
|
"y": 5.541275082550166
|
||||||
},
|
},
|
||||||
"prevControl": {
|
"prevControl": {
|
||||||
"x": 1.2891977212525858,
|
"x": 1.2945436204262721,
|
||||||
"y": 5.541275082550166
|
"y": 5.541275082550166
|
||||||
},
|
},
|
||||||
"nextControl": null,
|
"nextControl": null,
|
||||||
|
@ -133,7 +133,7 @@ public class RobotContainer {
|
|||||||
1.0,
|
1.0,
|
||||||
1.0
|
1.0
|
||||||
).raceWith(
|
).raceWith(
|
||||||
new WaitCommand(0.5)
|
new WaitCommand(1.0)
|
||||||
).andThen(
|
).andThen(
|
||||||
shooter.angleSpeedsSetpoints(
|
shooter.angleSpeedsSetpoints(
|
||||||
() -> ShooterConstants.kShooterLoadAngle,
|
() -> ShooterConstants.kShooterLoadAngle,
|
||||||
@ -228,7 +228,7 @@ public class RobotContainer {
|
|||||||
drivetrain.teleopCommand(
|
drivetrain.teleopCommand(
|
||||||
() -> { return driver.getLeftY() * (invertXYDrive ? -1 : 1); },
|
() -> { return driver.getLeftY() * (invertXYDrive ? -1 : 1); },
|
||||||
() -> { return driver.getLeftX() * (invertXYDrive ? -1 : 1); },
|
() -> { return driver.getLeftX() * (invertXYDrive ? -1 : 1); },
|
||||||
() -> { return -driver.getRightX() * (invertXYDrive ? -1 : 1); },
|
() -> { return driver.getRightX() * (invertXYDrive ? -1 : 1); },
|
||||||
OIConstants.kTeleopDriveDeadband
|
OIConstants.kTeleopDriveDeadband
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -451,6 +451,6 @@ public class RobotContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Command getAutonomousCommand() {
|
public Command getAutonomousCommand() {
|
||||||
return drivetrain.zeroHeadingCommand().andThen(autoChooser.getSelected());
|
return autoChooser.getSelected();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ public final class DrivetrainConstants {
|
|||||||
|
|
||||||
// Angular offsets of the modules relative to the chassis in radians
|
// Angular offsets of the modules relative to the chassis in radians
|
||||||
|
|
||||||
public static final double kFrontLeftChassisAngularOffset = Math.PI;
|
public static final double kFrontLeftChassisAngularOffset = 0.0;// Math.PI
|
||||||
public static final double kFrontRightChassisAngularOffset = -Math.PI / 2;
|
public static final double kFrontRightChassisAngularOffset = Math.PI / 2;//-Math.PI / 2;
|
||||||
public static final double kBackLeftChassisAngularOffset = Math.PI / 2;
|
public static final double kBackLeftChassisAngularOffset = -Math.PI/2;//Math.PI / 2;
|
||||||
public static final double kBackRightChassisAngularOffset = 0;
|
public static final double kBackRightChassisAngularOffset = Math.PI; //0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public static final double kFrontLeftChassisAngularOffset = -2*Math.PI;
|
public static final double kFrontLeftChassisAngularOffset = -2*Math.PI;
|
||||||
@ -40,15 +40,15 @@ public final class DrivetrainConstants {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// SPARK MAX CAN IDs
|
// SPARK MAX CAN IDs
|
||||||
public static final int kFrontLeftDrivingCanId = 8;
|
public static final int kFrontLeftDrivingCanId = 1;//8
|
||||||
public static final int kRearLeftDrivingCanId = 3;
|
public static final int kRearLeftDrivingCanId = 6;//3
|
||||||
public static final int kFrontRightDrivingCanId = 6;
|
public static final int kFrontRightDrivingCanId = 3;//6
|
||||||
public static final int kRearRightDrivingCanId = 1;
|
public static final int kRearRightDrivingCanId = 8;//1
|
||||||
|
|
||||||
public static final int kFrontLeftTurningCanId = 4;
|
public static final int kFrontLeftTurningCanId = 5;//4
|
||||||
public static final int kRearLeftTurningCanId = 7;
|
public static final int kRearLeftTurningCanId = 2;//7
|
||||||
public static final int kFrontRightTurningCanId = 2;
|
public static final int kFrontRightTurningCanId = 7;//2
|
||||||
public static final int kRearRightTurningCanId = 5;
|
public static final int kRearRightTurningCanId = 4;//5
|
||||||
|
|
||||||
public static final double kTurnToleranceDeg = 0;
|
public static final double kTurnToleranceDeg = 0;
|
||||||
public static final double kTurnRateToleranceDegPerS = 0;
|
public static final double kTurnRateToleranceDegPerS = 0;
|
||||||
|
@ -29,10 +29,12 @@ public class Climber extends SubsystemBase {
|
|||||||
|
|
||||||
public Command setSpeedWithSupplier(DoubleSupplier speed) {
|
public Command setSpeedWithSupplier(DoubleSupplier speed) {
|
||||||
return run(() -> {
|
return run(() -> {
|
||||||
if(shooterAngle.getAsDouble() <= ShooterConstants.kShooterLoadAngle){
|
if(shooterAngle.getAsDouble() > ShooterConstants.kShooterLoadAngle){
|
||||||
|
|
||||||
motor1.set(VictorSPXControlMode.PercentOutput, speed.getAsDouble());
|
motor1.set(VictorSPXControlMode.PercentOutput, speed.getAsDouble());
|
||||||
|
|
||||||
|
}else{
|
||||||
|
motor1.set(VictorSPXControlMode.PercentOutput, 0.0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -207,6 +207,8 @@ public class Drivetrain extends SubsystemBase {
|
|||||||
* @param pose The pose to which to set the odometry.
|
* @param pose The pose to which to set the odometry.
|
||||||
*/
|
*/
|
||||||
public void resetOdometry(Pose2d pose) {
|
public void resetOdometry(Pose2d pose) {
|
||||||
|
m_gyro.setAngleAdjustment(pose.getRotation().getDegrees());
|
||||||
|
|
||||||
m_poseEstimator.resetPosition(
|
m_poseEstimator.resetPosition(
|
||||||
Rotation2d.fromDegrees(getGyroAngle()),
|
Rotation2d.fromDegrees(getGyroAngle()),
|
||||||
new SwerveModulePosition[] {
|
new SwerveModulePosition[] {
|
||||||
@ -304,21 +306,29 @@ public class Drivetrain extends SubsystemBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void driveWithChassisSpeeds(ChassisSpeeds speeds) {
|
public void driveWithChassisSpeeds(ChassisSpeeds speeds) {
|
||||||
speeds.omegaRadiansPerSecond = -speeds.omegaRadiansPerSecond;
|
//speeds.omegaRadiansPerSecond = -speeds.omegaRadiansPerSecond;
|
||||||
|
ChassisSpeeds discreteSpeeds = ChassisSpeeds.discretize(speeds, 0.2);
|
||||||
|
SwerveModuleState[] newStates = DrivetrainConstants.kDriveKinematics.toSwerveModuleStates(discreteSpeeds);
|
||||||
|
SwerveDriveKinematics.desaturateWheelSpeeds(newStates, DrivetrainConstants.kMaxSpeedMetersPerSecond);
|
||||||
|
setModuleStates(newStates);
|
||||||
|
|
||||||
|
/*
|
||||||
|
//speeds.omegaRadiansPerSecond = -speeds.omegaRadiansPerSecond;
|
||||||
SwerveModuleState[] states = DrivetrainConstants.kDriveKinematics.toSwerveModuleStates(speeds);
|
SwerveModuleState[] states = DrivetrainConstants.kDriveKinematics.toSwerveModuleStates(speeds);
|
||||||
|
|
||||||
m_frontLeft.setDesiredState(states[0]);
|
m_frontLeft.setDesiredState(states[0]);
|
||||||
m_frontRight.setDesiredState(states[1]);
|
m_frontRight.setDesiredState(states[1]);
|
||||||
m_rearLeft.setDesiredState(states[2]);
|
m_rearLeft.setDesiredState(states[2]);
|
||||||
m_rearRight.setDesiredState(states[3]);
|
m_rearRight.setDesiredState(states[3]);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command teleopCommand(DoubleSupplier xSpeed, DoubleSupplier ySpeed, DoubleSupplier rotation, double deadband) {
|
public Command teleopCommand(DoubleSupplier xSpeed, DoubleSupplier ySpeed, DoubleSupplier rotation, double deadband) {
|
||||||
return run(() -> {
|
return run(() -> {
|
||||||
drive(
|
drive(
|
||||||
-MathUtil.applyDeadband(xSpeed.getAsDouble(), deadband),
|
MathUtil.applyDeadband(xSpeed.getAsDouble(), deadband),
|
||||||
-MathUtil.applyDeadband(ySpeed.getAsDouble(), deadband),
|
MathUtil.applyDeadband(ySpeed.getAsDouble(), deadband),
|
||||||
-MathUtil.applyDeadband(rotation.getAsDouble(), deadband),
|
MathUtil.applyDeadband(rotation.getAsDouble(), deadband),
|
||||||
() -> fieldRelativeControl,
|
() -> fieldRelativeControl,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user