Converting controller input into swerve drive chassis speeds

I was looking at Sean Suns YouTube video on swerve drive on YouTube and am confused about one of the lines in the code.

In this line:

chassisSpeeds = ChassisSpeeds.fromFieldRelativeSpeeds(
xSpeed, ySpeed, turningSpeed, swerveSubsystem.getRotation2d());

Here is the link to the complete code:

Where x speed, y speed and turning speed are joystick controller inputs, if I’m holding down the left joystick controlling the y speed variable completely down am I telling the robot that it needs to move 1m per second in the y direction. Does it not make sense to maybe scale controller input with the max velocity of the robot? Maybe I’m misunderstanding how the chassis speed class works. Any help is appreciated.

You are correct, and it looks like it’s done here:

// 3. Make the driving smoother
xSpeed = xLimiter.calculate(xSpeed) * DriveConstants.kTeleDriveMaxSpeedMetersPerSecond;
ySpeed = yLimiter.calculate(ySpeed) * DriveConstants.kTeleDriveMaxSpeedMetersPerSecond;
turningSpeed = turningLimiter.calculate(turningSpeed)
        * DriveConstants.kTeleDriveMaxAngularSpeedRadiansPerSecond;

Ah thank you so much. I don’t know how I missed that lol.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.