Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swerve Auto + Sim + Commands #10

Merged
merged 15 commits into from
Sep 4, 2024
Merged

Swerve Auto + Sim + Commands #10

merged 15 commits into from
Sep 4, 2024

Conversation

linglejack06
Copy link
Member

  • add configure path planner
  • add sim setup
  • add DriveWithJoysticks (skeleton of what it was right now)
  • add default command to RobotContainer.java

Resolves Issue #9

@linglejack06 linglejack06 self-assigned this Aug 27, 2024
@linglejack06
Copy link
Member Author

@jkleiber sim works now. I changed the apply drive request to the set control used in 2024 robot code and everything works liek, it should. Command scheduler must not like that one command is returning another command maybe. driving works in sim just need to iron out details now for example:

  • robot still shaky (tune gains)
  • i dont think its flipping origins for controlling like it should when i flip alliances

Copy link
Member

@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.

@linglejack06 Just some first pass comments / suggstions. Also would be a good idea to resolve the merge conflicts in this branch

return Commands.print("No autonomous command configured");
}
private void configureBindings() {
System.out.println("add binding");
Copy link
Member

Choose a reason for hiding this comment

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

we can remove the prints since everything is working now with the setControl update

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines 69 to 73
private static final double kSteerInertia = 0.00001;
private static final double kDriveInertia = 0.001;
// Simulated voltage necessary to overcome friction
private static final double kSteerFrictionVoltage = 0.25;
private static final double kDriveFrictionVoltage = 0.25;
Copy link
Member

Choose a reason for hiding this comment

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

If you want to make the robot less jittery in sim, you could try increasing these values. In any case it would be interesting to see what they do so we can better match the real bot to the sim

Copy link
Member Author

Choose a reason for hiding this comment

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

ill work on that

import frc.robot.constants.PhoenixDriveConstants;

public class PhoenixDrive extends SwerveDrivetrain implements Subsystem {
private static final double kSimLoopPeriod = 0.005; // 5 ms
Copy link
Member

Choose a reason for hiding this comment

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

Let's make this a constant in a separate constants file even though I recognize it will probably only be used here

Copy link
Member Author

Choose a reason for hiding this comment

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

done

SwerveDrivetrainConstants driveConstants, SwerveModuleConstants... modules) {
super(driveConstants, modules);

System.out.println("create drive");
Copy link
Member

Choose a reason for hiding this comment

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

see comment about removing prints

Comment on lines +155 to +165
if (!hasAppliedOperatorPerspective || DriverStation.isDisabled()) {
DriverStation.getAlliance()
.ifPresent(
(color) -> {
this.setOperatorPerspectiveForward(
color == Alliance.Red
? RedAlliancePerspectiveRotation
: BlueAlliancePerspectiveRotation);
});
hasAppliedOperatorPerspective = true;
}
Copy link
Member

Choose a reason for hiding this comment

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

how did we do this in 2024-Robot-Code?

Copy link
Member Author

Choose a reason for hiding this comment

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

honzik used a conditional to flip values of joystick, i figured i would try out there way of doing it though to see if it led to performances in odometry and field positioning?

@linglejack06 linglejack06 marked this pull request as ready for review September 4, 2024 22:59
@linglejack06 linglejack06 merged commit fc1ced9 into main Sep 4, 2024
3 checks passed
@linglejack06 linglejack06 deleted the swerve-sim branch September 4, 2024 23:22
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.

2 participants