exponents on joystick now implemented correctly
This commit is contained in:
parent
68da3c630c
commit
fa34ef00fe
@ -111,8 +111,8 @@ public class RobotContainer {
|
|||||||
|
|
||||||
drivetrain.setDefaultCommand(
|
drivetrain.setDefaultCommand(
|
||||||
drivetrain.drive(
|
drivetrain.drive(
|
||||||
() -> Math.pow(driver.getLeftY(), 3),
|
() -> driver.getLeftY(),
|
||||||
() -> Math.pow(driver.getLeftX(), 3),
|
() -> driver.getLeftX(),
|
||||||
() -> driver.getRightX(),
|
() -> driver.getRightX(),
|
||||||
() -> true
|
() -> true
|
||||||
)
|
)
|
||||||
|
@ -9,4 +9,6 @@ public class OIConstants {
|
|||||||
public static final String kAutoTab = "Auto Tab";
|
public static final String kAutoTab = "Auto Tab";
|
||||||
public static final String kSensorsTab = "Sensors Tab";
|
public static final String kSensorsTab = "Sensors Tab";
|
||||||
public static final String kApriltagTab = "Apriltag Tab";
|
public static final String kApriltagTab = "Apriltag Tab";
|
||||||
|
|
||||||
|
public static final double kJoystickExponential = 3;
|
||||||
}
|
}
|
||||||
|
@ -323,8 +323,10 @@ public class Drivetrain extends SubsystemBase {
|
|||||||
*/
|
*/
|
||||||
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
|
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
|
||||||
// Convert the commanded speeds into the correct units for the drivetrain
|
// Convert the commanded speeds into the correct units for the drivetrain
|
||||||
double xSpeedDelivered = xSpeed * DrivetrainConstants.kMaxSpeedMetersPerSecond;
|
double p = Math.sqrt(Math.pow(xSpeed, 2) + Math.pow(ySpeed, 2));
|
||||||
double ySpeedDelivered = ySpeed * DrivetrainConstants.kMaxSpeedMetersPerSecond;
|
|
||||||
|
double xSpeedDelivered = xSpeed * (Math.pow(p, OIConstants.kJoystickExponential) / p) * DrivetrainConstants.kMaxSpeedMetersPerSecond;
|
||||||
|
double ySpeedDelivered = ySpeed * (Math.pow(p, OIConstants.kJoystickExponential) / p) * DrivetrainConstants.kMaxSpeedMetersPerSecond;
|
||||||
double rotDelivered = rot * DrivetrainConstants.kMaxAngularSpeed;
|
double rotDelivered = rot * DrivetrainConstants.kMaxAngularSpeed;
|
||||||
|
|
||||||
var swerveModuleStates = DrivetrainConstants.kDriveKinematics.toSwerveModuleStates(
|
var swerveModuleStates = DrivetrainConstants.kDriveKinematics.toSwerveModuleStates(
|
||||||
|
Loading…
Reference in New Issue
Block a user