Skip to content

Updates robot to 2024#35

Merged
honzikschenk merged 5 commits intomainfrom
2024-Phoenix-Swerve
Dec 13, 2023
Merged

Updates robot to 2024#35
honzikschenk merged 5 commits intomainfrom
2024-Phoenix-Swerve

Conversation

@honzikschenk
Copy link
Contributor

@honzikschenk honzikschenk commented Dec 7, 2023

Summary
We are now using the Phoenix 6 beta, which has faster refresh capabilities (makes the drive smoother and more accurate). We also have to migrate the robot and drive to AdvantageKit and 2024 WPILib.

Project Scope

  • Switch drive to Phoenix 6
  • Migrate to AdvantageKit
  • Update to 2024
  • Implement new arm code

@honzikschenk honzikschenk self-assigned this Dec 7, 2023
@honzikschenk honzikschenk linked an issue Dec 7, 2023 that may be closed by this pull request
@honzikschenk honzikschenk changed the title Adds Phoenix6 swerve drive Updates robot to 2024 Dec 7, 2023
@honzikschenk honzikschenk added the enhancement New feature or request label Dec 7, 2023
Copy link
Contributor

@jkleiber jkleiber left a comment

Choose a reason for hiding this comment

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

First pass. Also - is there any advantage to removing the vision/camera stuff? It seems like that doesn't really have anything to do with this change.

Comment on lines +54 to +75
rightJoystick.trigger()
.whileTrue(
drivetrain.applyRequest(() -> driveRobot.withVelocityX(-leftJoystick.getY() * MaxSpeedMetPerSec)
.withVelocityY(-leftJoystick.getX() * MaxSpeedMetPerSec)
.withRotationalRate(-rightJoystick.getX() * MaxAngularRateRadiansPerSec)));

masher.rightStickUp()
.onTrue(new InstantCommand(wrist::jogSetpointForward, wrist)); // jog wrist right
masher.rightStickDown()
.onTrue(new InstantCommand(wrist::jogSetpointBack, wrist)); // jog wrist left
leftJoystick.trigger()
.whileTrue(drivetrain
.applyRequest(() -> drive.withVelocityX(-leftJoystick.getY() * MaxSpeedMetPerSec * 0.5)
.withVelocityY(-leftJoystick.getX() * MaxSpeedMetPerSec * 0.5)
.withRotationalRate(-rightJoystick.getX() * MaxAngularRateRadiansPerSec * 0.5)));

// Intake
masher.leftTrigger()
.onTrue(new InstantCommand(intake::toggleIntake)); // toggle intake
rightJoystick.button(2)
.whileTrue(new InstantCommand(() -> drivetrain.seedFieldRelative()));

masher.rightTrigger()
.onTrue(new InstantCommand(intake::place)) // start place
.onFalse(new InstantCommand(intake::stop)); // stop place
controller.a().whileTrue(drivetrain.applyRequest(() -> brake));
controller.b().whileTrue(drivetrain
.applyRequest(
() -> point
.withModuleDirection(new Rotation2d(-controller.getLeftY(), -controller.getLeftX()))));

masher.back()
.onTrue(new HomeWrist(wrist));
controller.x().whileTrue(drivetrain.applyRequest(() -> drive.withIsOpenLoop(false)));
Copy link
Contributor

Choose a reason for hiding this comment

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

My preference would be to put this into a new drive command (or multiple commands if needed). Also we can make our own deadband utility function and put it in a separate class so that can be used by the command

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could this be a separate PR?

Comment on lines +25 to +27
public Command applyRequest(Supplier<SwerveRequest> requestSupplier) {
return run(() -> this.setControl(requestSupplier.get()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to put this.setControl(...) in periodic()? Then if we have multiple commands for controlling the drivetrain they can command a SwerveRequest that would get run periodically

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could this be done in a separate PR?

@jkleiber jkleiber mentioned this pull request Dec 13, 2023
3 tasks
@jkleiber
Copy link
Contributor

once we get my relatively minor comments resolved, I think we should merge this branch ASAP. Since this and #34 are both upgrading the project to 2024, it looks like it's easier to get this one merged in and rebase the Arm refactor on top of it.

@honzikschenk
Copy link
Contributor Author

Thanks for the feedback, my commits did not sync with the server because of the school's DNS. Once I get home, I'll make those changes and then we could merge tonight..?

@jkleiber
Copy link
Contributor

sounds like a plan 👍

@honzikschenk
Copy link
Contributor Author

All comments are fixed/resolved

@honzikschenk honzikschenk marked this pull request as ready for review December 13, 2023 23:48
Copy link
Contributor

@jkleiber jkleiber left a comment

Choose a reason for hiding this comment

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

Ship it

@honzikschenk honzikschenk removed the request for review from charlesmackenzie December 13, 2023 23:53
@honzikschenk honzikschenk merged commit 77d4cda into main Dec 13, 2023
@honzikschenk honzikschenk deleted the 2024-Phoenix-Swerve branch December 13, 2023 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transfer to 2024 WPILib

2 participants