Skip to content

Drive level 2 remake#16

Open
AryanKammili wants to merge 25 commits intoproductionfrom
drive-level-2-remake
Open

Drive level 2 remake#16
AryanKammili wants to merge 25 commits intoproductionfrom
drive-level-2-remake

Conversation

@AryanKammili
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/main/java/frc/robot/AutonCommands.java
// ex: this.robotDrive = robotDrive;
this.drive = drive;

autoChooser = new SendableChooser<>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barbute @AnshulBompada @Manyata-Patel, everyone needs to get on the same page on how the choosers will be created.

default:
// Instantiate subsystems that are driven by playback of recorded sessions. (IO modules)
drive = new Drive( new Module[] {
new Module("FL", new ModuleIO(){}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't create concrete instances of interfaces. Does this compile?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be tested with replay

Comment thread src/main/java/frc/robot/RobotContainer.java Outdated
Comment thread src/main/java/frc/robot/RobotContainer.java
Comment thread src/main/java/frc/robot/drive/DriveConstants.java Outdated
Comment thread src/main/java/frc/robot/drive/Module.java Outdated
Comment thread src/main/java/frc/robot/drive/Module.java Outdated
Comment thread src/main/java/frc/robot/drive/Module.java Outdated
Comment thread src/main/java/frc/robot/drive/ModuleIO.java Outdated
Comment thread src/main/java/frc/robot/RobotContainer.java

driverController.povLeft().onTrue(drive.setDriveStateCommandContinued(DriveState.SNIPER_LEFT)).onFalse(drive.setDriveStateCommand(DriveState.TELEOP));

driverController.b().onTrue(drive.setDriveStateCommandContinued(DriveState.DRIFT_TEST)).onFalse(drive.setDriveStateCommand(DriveState.TELEOP));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please define "Drift"?

private void configureButtonBindings() {
driverController.x().onTrue(Commands.runOnce(() -> {drive.resetGyro();}));

driverController.povUp().onTrue(drive.setDriveStateCommandContinued(DriveState.SNIPER_UP)).onFalse(drive.setDriveStateCommand(DriveState.TELEOP));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "UP" with the drivebase?

azimuthVoltageControl = new VoltageOut(0);
driveVoltageControl = new VoltageOut(0);

// Closed - Loop control //
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need comments here on how you are creating these controllers, and what parameters you are passing in.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Comment thread src/main/java/frc/robot/drive/ModuleIOKraken.java Outdated
azimuth.setPosition(
Rotation2d.fromRotations(
absolutePosistionSignal.getValueAsDouble()).minus(angleOffset).getRotations(),
2.5);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 2.5, assuming it is "timeout in seconds" needs to be assigned to a named variable/constant so the code can be better understood.

Comment thread src/main/java/frc/robot/drive/Module.java Outdated
Comment thread src/main/java/frc/robot/drive/Module.java Outdated
Comment thread src/main/java/frc/robot/drive/Module.java
/**
* Stop swerve module
*/
public void stop(){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you also need to set your velocities and accelerations to null?

var desiredDeltaPose = new Pose2d(
speeds.vxMetersPerSecond * dt,
speeds.vyMetersPerSecond * dt,
new Rotation2d(speeds.omegaRadiansPerSecond * dt * kDriftRate.get()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain the purpose of drift rate. Its default value is 2, so you are actually setting your Chassis speed to twice what is being asked for, even after it has been discretized.

Comment thread src/main/java/frc/robot/drive/Drive.java Outdated
Comment thread src/main/java/frc/robot/drive/Drive.java
}

public boolean isSpeedOptimized(SwerveModuleState state, SwerveModuleState optimizedState) {
return state.speedMetersPerSecond != optimizedState.speedMetersPerSecond;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't directly compare floats. Use an epsilon comparison within a reasonable epsilon.

Comment thread src/main/java/frc/robot/drive/Drive.java
Comment thread src/main/java/frc/robot/drive/Drive.java
Comment thread src/main/java/frc/robot/drive/controllers/HeadingController.java Outdated
private double invert;

public HeadingController() {
invert = (RobotBase.isReal()) ? -1.0 : 1.0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this inverting based on robot mode?

Comment thread src/main/java/frc/robot/drive/controllers/HeadingController.java Outdated
Comment thread src/main/java/frc/robot/drive/controllers/HeadingController.java Outdated
public ChassisSpeeds computeChassisSpeeds(Rotation2d robotAngle, ChassisSpeeds currentRelativeSpeeds){

// Scales the filtered value if the person driving wanted a slower or faster robot //
double xChangedDemand = linearScalar.get() * applyDeadband(xSupplier.getAsDouble(), linearDeadband.get());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the linear scalar applied before exponent?

double omegaChangedDemand = omegaScalar.get() * applyDeadband(omegaSupplier.getAsDouble(), omegaDeadband.get());

// Makes sure that the exponenet is a whole number //
int linearExp = (int) Math.round(linearInputsExponent.get());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are exponents rounded to whole numbers?

int rotationExp = (int) Math.round(rotationInputsExponent.get());

// Converts the value to m/s for the chassis speeds //
double xVelocityMPS = DriveConstants.kMaxLinearSpeed * Math.pow(xChangedDemand, linearExp);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the linear and exponent calculations not clamped between 0 and 1 before applying to velocity? If the values are set incorrectly, you could request a faster-than-max speed from the drive system. I would suggest doing all of the control adjustments and storing them into variables, and only then after everything has been adjusted do you multiply by kMaxLinearSpeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants