-
Notifications
You must be signed in to change notification settings - Fork 0
Aishah/sysid #25
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
Aishah/sysid #25
Changes from all commits
b9f4d81
6b4d6b8
037ec4b
7b66ef3
bb6d9d8
8f3274b
b7e0706
fb57173
d8fc972
6adc9ed
7adf950
72463d4
b646d08
b6ea85f
069bf17
d1d14c8
eec626e
5aabf95
05c4468
1ea4d64
cb8c76b
2b0d0bb
58c89fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| public class Controls { | ||
|
|
||
| public static JoystickVals adjustInputs(double x, double y, boolean slowmode) { | ||
| return adjustSlowmode(inputShape(x, y), slowmode); | ||
| return adjustSlowmode(inputShape(x, y), slowmode); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: remove whitespace at the end of this line :3 |
||
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,25 +43,29 @@ | |
| import frc.robot.Constants.OperatorConstants; | ||
| import frc.robot.commands.Autos; | ||
| import frc.robot.commands.RotateToFaceReefCommand; | ||
| import frc.robot.generated.TunerConstants; | ||
| import frc.robot.generated.TunerConstantsDynamene; | ||
| import frc.robot.subsystems.CommandSwerveDrivetrain; | ||
| import frc.robot.subsystems.IntakeSubsystem; | ||
| import frc.robot.subsystems.LEDSubsystem; | ||
| import frc.robot.subsystems.VisionSubsystem; | ||
| import frc.robot.subsystems.collar.CollarSubsystem; | ||
| import frc.robot.subsystems.lifter.ArmSubsystem; | ||
| import frc.robot.subsystems.lifter.ElevatorIOHardware; | ||
| import frc.robot.subsystems.lifter.ElevatorSubsystem; | ||
| import frc.robot.subsystems.lifter.LifterCommandFactory; | ||
| import frc.robot.subsystems.ramp.RampSubsystem; | ||
| import frc.robot.commands.AutoAlignCommand; | ||
|
|
||
|
|
||
|
|
||
| public class RobotContainer { | ||
|
|
||
| record JoystickVals(double x, double y) { } | ||
|
|
||
| private RobotState currentState = RobotState.INTAKE; | ||
| private RobotState nextState = RobotState.INTAKE; | ||
|
|
||
| private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12VoltsMps desired top speed *0.3 for pid tuning 9/15 | ||
| private double MaxSpeed = TunerConstantsDynamene.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12VoltsMps desired top speed *0.3 for pid tuning 9/15 | ||
| private double MaxAngularRate = 1.5 * Math.PI; // 3/4 of a rotation per second max angular velocity | ||
|
|
||
| /* Setting up bindings for necessary control of the swerve drive platform */ | ||
|
|
@@ -70,14 +74,17 @@ record JoystickVals(double x, double y) { } | |
| private final CommandXboxController testJoystick = new CommandXboxController(OperatorConstants.kTestControllerPort); // test joystick | ||
|
|
||
|
|
||
| private final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain(); // My drivetrain | ||
| private final CommandSwerveDrivetrain drivetrain = TunerConstantsDynamene.createDrivetrain(); // My drivetrain | ||
| private final LEDSubsystem m_ledSubsystem = new LEDSubsystem(); | ||
| private final VisionSubsystem m_vision = new VisionSubsystem(); | ||
| private final IntakeSubsystem m_intakeSubsystem = new IntakeSubsystem(); | ||
| private final CollarSubsystem m_collar = new CollarSubsystem(); | ||
| private final RampSubsystem m_ramp = new RampSubsystem(); | ||
|
|
||
| private final LifterCommandFactory m_lifter = new LifterCommandFactory(); | ||
| private final ElevatorSubsystem m_elevator = new ElevatorSubsystem(); | ||
|
|
||
| private final ArmSubsystem m_arm = new ArmSubsystem(); | ||
|
|
||
| private final SwerveRequest.FieldCentric drive = new SwerveRequest.FieldCentric() | ||
| .withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1) // Add a 10% deadband | ||
|
|
@@ -153,31 +160,61 @@ private void configureBindings() { | |
|
|
||
|
|
||
| // set next state, change LED colors accordingly | ||
| copilotJoystick.leftTrigger().onTrue( | ||
| new ParallelCommandGroup( | ||
| new InstantCommand(() -> {nextState = RobotState.L4_CORAL;}), | ||
| m_ledSubsystem.runSolidRed())); | ||
| copilotJoystick.rightTrigger().onTrue( | ||
| new ParallelCommandGroup( | ||
| new InstantCommand(() -> {nextState = RobotState.L3_CORAL;}), | ||
| m_ledSubsystem.runSolidOrange())); | ||
| copilotJoystick.leftBumper().onTrue( | ||
| new ParallelCommandGroup( | ||
| new InstantCommand(() -> {nextState = RobotState.L2_CORAL;}), | ||
| m_ledSubsystem.runSolidYellow())); | ||
| copilotJoystick.rightBumper().onTrue( | ||
| new ParallelCommandGroup( | ||
| new InstantCommand(() -> {nextState = RobotState.L1_CORAL;}), | ||
| m_ledSubsystem.runSolidWhite())); | ||
| copilotJoystick.a().onTrue( | ||
| new ParallelCommandGroup( | ||
| new InstantCommand(() -> {nextState = RobotState.L3_ALGAE;}), | ||
| m_ledSubsystem.runSolidPurple())); | ||
| copilotJoystick.y().onTrue( | ||
| new ParallelCommandGroup( | ||
| new InstantCommand(() -> {nextState = RobotState.L2_ALGAE;}), | ||
| m_ledSubsystem.runSolidPink())); | ||
| //copilotJoystick.leftTrigger().onTrue( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: We're probably going to have a lot of merge conflicts with these lines, they change frequently across all of our MRs 😬 |
||
| //new ParallelCommandGroup( | ||
| //new InstantCommand(() -> {nextState = RobotState.L4_CORAL;}), | ||
| //m_ledSubsystem.runSolidRed())); | ||
|
|
||
| //copilotJoystick.rightTrigger().onTrue( | ||
| //new ParallelCommandGroup( | ||
| //new InstantCommand(() -> {nextState = RobotState.L3_CORAL;}), | ||
| //m_ledSubsystem.runSolidOrange())); | ||
|
|
||
| // copilotJoystick.leftBumper().onTrue( | ||
| // new ParallelCommandGroup( | ||
| // new InstantCommand(() -> {nextState = RobotState.L2_CORAL;}), | ||
| // m_ledSubsystem.runSolidYellow())); | ||
|
|
||
| // copilotJoystick.rightBumper().onTrue( | ||
| // new ParallelCommandGroup( | ||
| // new InstantCommand(() -> {nextState = RobotState.L1_CORAL;}), | ||
| // m_ledSubsystem.runSolidWhite())); | ||
|
|
||
| // copilotJoystick.a().onTrue( | ||
| // new ParallelCommandGroup( | ||
| // new InstantCommand(() -> {nextState = RobotState.L3_ALGAE;}), | ||
| // m_ledSubsystem.runSolidPurple())); | ||
|
|
||
| // copilotJoystick.y().onTrue( | ||
| // new ParallelCommandGroup( | ||
| // new InstantCommand(() -> {nextState = RobotState.L2_ALGAE;}), | ||
| // m_ledSubsystem.runSolidPink())); | ||
|
|
||
| //open loop control testing: | ||
| copilotJoystick.leftTrigger().whileTrue( | ||
| m_elevator.manualMoveCommand()); | ||
|
|
||
| copilotJoystick.rightTrigger().whileTrue( | ||
| m_arm.manualMoveCommand()); | ||
|
|
||
| copilotJoystick.leftBumper().whileTrue( | ||
| m_elevator.manualMoveBackwardCommand()); | ||
|
|
||
| copilotJoystick.rightBumper().whileTrue( | ||
| m_arm.manualMoveBackwardCommand()); | ||
|
|
||
| copilotJoystick.a().whileTrue( | ||
| m_collar.runCollar()); | ||
|
|
||
| copilotJoystick.y().whileTrue( | ||
| m_collar.runCollarBackward()); | ||
|
|
||
| m_elevator.setDefaultCommand(m_elevator.keepInPlaceCommand()); | ||
| m_arm.setDefaultCommand(m_arm.keepInPlaceCommand()); | ||
| m_collar.setDefaultCommand(m_collar.runCollarOff()); | ||
|
|
||
|
|
||
|
|
||
| // run command runSolidGreen continuously if robot isWithinTarget() | ||
| m_vision.isWithinTargetTrigger().whileTrue(m_ledSubsystem.runSolidGreen()); | ||
|
|
||
|
|
@@ -194,6 +231,19 @@ private void configureBindings() { | |
| testJoystick.leftBumper().and(testJoystick.x()).whileTrue(drivetrain.sysIdDynamic(Direction.kReverse)); | ||
| testJoystick.rightBumper().and(testJoystick.y()).whileTrue(drivetrain.sysIdQuasistatic(Direction.kForward)); | ||
| testJoystick.rightBumper().and(testJoystick.x()).whileTrue(drivetrain.sysIdQuasistatic(Direction.kReverse)); | ||
|
|
||
| //sysID routines for mechanisms | ||
| //(comment out other mechanisms while running one of them since they are all bound | ||
| //to the same buttons ) | ||
| //or change the bindings buttons haha | ||
| //run sysID routines for collar | ||
|
|
||
| //run sysID routines for elevator | ||
| testJoystick.a().whileTrue(m_elevator.sysIdDynamic(Direction.kForward)); | ||
| testJoystick.b().whileTrue(m_elevator.sysIdDynamic(Direction.kReverse)); | ||
| testJoystick.x().whileTrue(m_elevator.sysIdQuasistatic(Direction.kForward)); | ||
| testJoystick.y().whileTrue(m_elevator.sysIdQuasistatic(Direction.kReverse)); | ||
|
|
||
| if (Utils.isSimulation()) { | ||
| drivetrain.resetPose(new Pose2d(new Translation2d(), Rotation2d.fromDegrees(90))); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this temp? 👀