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

LEDs, Button Bindings, Arm + Elevator routines, bug fixes, and cleanup code #7

Merged
merged 21 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
aebb773
Add button bindings for driver controls (no alignment or swerve)
k4limul Feb 5, 2025
9ce1272
Change comments
k4limul Feb 5, 2025
c2aa013
Added LEDController
Material-Energy Feb 6, 2025
0d2009c
Merged LEDS and Button Binding
Material-Energy Feb 6, 2025
e040622
Added Leds for
Material-Energy Feb 7, 2025
1b3adff
Added semi broken version of arm + elevator + funnel visualizer, fixe…
Baiulus Feb 8, 2025
66c3b1a
Merge branch 'se/leds' of https://github.com/StuyPulse/Aunt-Mary into…
Baiulus Feb 8, 2025
8c98009
created arm-elevator commands, updated ArmImpl, and fixed naming of c…
Zixi52 Feb 8, 2025
e1a85fb
Fix imports in RobotContainer
k4limul Feb 8, 2025
dfd5492
added arm-elevator move to algae l2 and l3 commands, updated button b…
Zixi52 Feb 8, 2025
9d497a2
Merge branch 'se/leds' into arm-elevator
k4limul Feb 8, 2025
2f1f24b
Clean up merge for se/leds into arm-elevator
k4limul Feb 8, 2025
467ea7f
Made all elevator-arm sequential commands into score routines and upd…
bzheng60 Feb 8, 2025
8ccf7e9
led color constants created
bzheng60 Feb 8, 2025
efcf6e9
organized constants
bzheng60 Feb 8, 2025
5ecf5b1
Made some arm and elevator constants actually make sense
bzheng60 Feb 8, 2025
d963246
Add class in Motors.java for easier configing, minorfixes for some su…
IanShiii Feb 9, 2025
3b881e4
Fix and rename climb methods and commands
k4limul Feb 9, 2025
ccfa9e4
Run Spotless Apply, clean up formatting and logging in classes, add r…
k4limul Feb 10, 2025
b7e2875
remoevd abs fromm stall and cchanged names
Owen-Zeng Feb 10, 2025
ba46c84
removed a negative sign
Owen-Zeng Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ctre_sim/CANCoder vers. H - 05 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/CANCoder vers. H - 09 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 012 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 017 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 03 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 04 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 06 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 08 - 0 - ext.dat
Binary file not shown.
23 changes: 22 additions & 1 deletion simgui.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"types": {
"/FMSInfo": "FMSInfo",
"/SmartDashboard/Autonomous": "String Chooser",
"/SmartDashboard/Visualizers/Arm": "Mechanism2d",
"/SmartDashboard/Visualizers/Elevator": "Mechanism2d"
},
"windows": {
"/SmartDashboard/Visualizers/Elevator": {
"/SmartDashboard/Visualizers/Arm": {
"window": {
"visible": true
}
Expand All @@ -19,11 +20,31 @@
"Elevator": {
"open": true
},
"Froggy": {
"open": true
},
"Funnel": {
"open": true
},
"Shooter": {
"open": true
},
"Visualizers": {
"Arm": {
"open": true
},
"Elevator": {
"open": true
}
},
"open": true
}
}
},
"NetworkTables Info": {
"Server": {
"open": true
},
"visible": true
}
}
4 changes: 3 additions & 1 deletion src/main/java/com/stuypulse/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public void robotPeriodic() {
public void disabledInit() {}

@Override
public void disabledPeriodic() {}
public void disabledPeriodic() {
// put your pregame LED check in here
}

/***********************/
/*** AUTONOMOUS MODE ***/
Expand Down
95 changes: 88 additions & 7 deletions src/main/java/com/stuypulse/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,29 @@
import com.stuypulse.stuylib.input.gamepads.AutoGamepad;

import com.stuypulse.robot.commands.auton.DoNothingAuton;
import com.stuypulse.robot.commands.climb.*;
import com.stuypulse.robot.commands.froggy.*;
import com.stuypulse.robot.commands.funnel.FunnelDefaultCommand;
import com.stuypulse.robot.commands.led.LedRainbow;
import com.stuypulse.robot.commands.led.LedSolidColor;
import com.stuypulse.robot.commands.routines.*;
import com.stuypulse.robot.commands.routines.algae.*;
import com.stuypulse.robot.commands.routines.front_side.*;
import com.stuypulse.robot.constants.Ports;
import com.stuypulse.robot.constants.Settings;
import com.stuypulse.robot.constants.Settings.LED;
import com.stuypulse.robot.subsystems.arm.Arm;
import com.stuypulse.robot.subsystems.climb.Climb;
import com.stuypulse.robot.subsystems.elevator.Elevator;
import com.stuypulse.robot.subsystems.funnel.CoralFunnel;
import com.stuypulse.robot.subsystems.froggy.Froggy;
import com.stuypulse.robot.subsystems.funnel.Funnel;
import com.stuypulse.robot.subsystems.led.LEDController;
import com.stuypulse.robot.subsystems.lokishooter.LokiShooter;

import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.button.Trigger;

public class RobotContainer {

Expand All @@ -27,35 +41,102 @@ public class RobotContainer {
public final Gamepad operator = new AutoGamepad(Ports.Gamepad.OPERATOR);

// Subsystem

private final CoralFunnel funnel = CoralFunnel.getInstance();
private final Funnel funnel = Funnel.getInstance();
private final LokiShooter shooter = LokiShooter.getInstance();
private final Arm arm = Arm.getInstance();
private final Elevator elevator = Elevator.getInstance();
private final Climb climb = Climb.getInstance();
private final Froggy froggy = Froggy.getInstance();
private final LEDController ledController = LEDController.getInstance();

// Autons
private static SendableChooser<Command> autonChooser = new SendableChooser<>();

// Robot container

public RobotContainer() {
configureDefaultCommands();
configureButtonBindings();
configureAutons();

new Trigger(() -> froggy.isCoralStalling() || shooter.hasCoral())
.onTrue(new LedSolidColor(LED.HAS_CORAL_COLOR));

new Trigger(((FunnelDefaultCommand) funnel.getDefaultCommand())::isUnjamming)
.onTrue(new LedSolidColor(LED.UNJAM_COLOR));

new Trigger(
() ->
(Math.abs(
climb.getAngle().getDegrees()
- Settings.Climb.OPEN_ANGLE.getDegrees())
<= Settings.Climb.ANGLE_TOLERANCE.getDegrees()))
.onTrue(new LedRainbow());

new Trigger(
() ->
(Math.abs(
climb.getAngle().getDegrees()
- Settings.Climb.CLIMBED_ANGLE.getDegrees())
<= Settings.Climb.ANGLE_TOLERANCE.getDegrees()))
.onTrue(new LedSolidColor(LED.CLIMB_COLOR));
}

/****************/
/*** DEFAULTS ***/
/*** DEFAULT ***/
/****************/

private void configureDefaultCommands() {
funnel.setDefaultCommand(new FunnelDefaultCommand());
}

/***************/
/*** BUTTONS ***/
/*** BUTTON ***/
/***************/

private void configureButtonBindings() {}
private void configureButtonBindings() {

/* RIGHT SIDE BUTTONS */
// ADD ALIGNMENT TO ALL SCORING ROUTINES

// BOTTOM BUTTON -> LVL 2 FRONT
driver.getBottomButton().whileTrue(new ScoreL2Front()).onFalse(new MoveToFeed());

// RIGHT BUTTON -> LVL 3 FRONT
driver.getRightButton().whileTrue(new ScoreL3Front()).onFalse(new MoveToFeed());

// TOP BUTTON -> LVL 4 FRONT
driver.getTopButton().whileTrue(new ScoreL4Front()).onFalse(new MoveToFeedReverse());

// LEFT BUTTON -> BARGE SCORE
driver.getLeftButton().whileTrue(new ScoreBarge()).onFalse(new MoveToFeed());

// TOP RIGHT PADDLE -> CLIMB CLOSE
driver.getLeftMenuButton().onTrue(new ClimbStow());

// BOTTOM RIGHT PADDLE -> CLIMB OPEN
driver.getDPadRight().onTrue(new ClimbOpen());

// RIGHT MENU BUTTON -> CLIMB DRIVE
driver.getRightMenuButton().onTrue(new ClimbClimb());

// TOP LEFT PADDLE -> L3 REEF ALGAE INTAKE
driver.getDPadLeft().whileTrue(new AcquireAlgaeL3()).onFalse(new MoveToStow());

// BOTTOM LEFT PADDLE -> L2 REEF ALGAE INTAKE
driver.getDPadDown().whileTrue(new AcquireAlgaeL2()).onFalse(new MoveToStow());

// RIGHT BUMPER -> L1 SCORE
driver.getRightBumper().whileTrue(new FroggyScoreL1());

// RIGHT TRIGGER -> GROUND CORAL INTAKE
driver.getRightTriggerButton().whileTrue(new FroggyCoralGroundIntake());

// LEFT BUMPER -> PROCESSOR SCORE
driver.getLeftBumper().whileTrue(new FroggyProcessorScore());

// LEFT TRIGGER -> GROUND ALGAE INTAKE
driver.getLeftTriggerButton().whileTrue(new FroggyAlgaeGroundIntake());
}

/**************/
/*** AUTONS ***/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@

package com.stuypulse.robot.commands.arm;

import com.stuypulse.robot.commands.led.LedSolidColor;
import com.stuypulse.robot.constants.Settings.LED;
import com.stuypulse.robot.subsystems.arm.Arm;

import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.wpilibj2.command.InstantCommand;

public class ArmMoveToAngle extends InstantCommand {
private final Arm arm;
private final Rotation2d angle;
public class ArmToAngle extends InstantCommand {
protected final Arm arm;
protected final Rotation2d angle;

public ArmMoveToAngle(Rotation2d angle) {
public ArmToAngle(Rotation2d angle) {
arm = Arm.getInstance();
this.angle = angle;
}
Expand All @@ -24,4 +26,14 @@ public ArmMoveToAngle(Rotation2d angle) {
public void initialize() {
arm.setTargetAngle(angle);
}

@Override
public boolean isFinished() {
return arm.atTargetAngle();
}

@Override
public void end(boolean interrupted) {
if (interrupted) new LedSolidColor(LED.ABORT_COLOR).schedule();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

import com.stuypulse.robot.constants.Settings;

public class ArmMoveToFunnel extends ArmMoveToAngle {
public ArmMoveToFunnel() {
public class ArmToFeed extends ArmToAngle {
public ArmToFeed() {
super(Settings.Arm.FUNNEL_ANGLE);
}

@Override
public void initialize() {
arm.setRotateBoolean(false);
super.initialize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

import com.stuypulse.robot.constants.Settings;

public class ArmMoveToL2Back extends ArmMoveToAngle {
public ArmMoveToL2Back() {
super(Settings.Arm.L2_ANGLE_BACK);
public class ArmToFeedReverse extends ArmToAngle {
public ArmToFeedReverse() {
super(Settings.Arm.FUNNEL_ANGLE);
}

@Override
public void initialize() {
arm.setRotateBoolean(true);
super.initialize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

import com.stuypulse.robot.constants.Settings;

public class ArmMoveToL3Back extends ArmMoveToAngle {
public ArmMoveToL3Back() {
super(Settings.Arm.L3_ANGLE_BACK);
public class ArmToVertical extends ArmToAngle {
public ArmToVertical() {
super(Settings.Arm.VERTICAL_ANGLE);
}

@Override
public void initialize() {
arm.setRotateBoolean(false);
super.initialize();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/************************ PROJECT MARY *************************/
/* Copyright (c) 2025 StuyPulse Robotics. All rights reserved. */
/* Use of this source code is governed by an MIT-style license */
/* that can be found in the repository LICENSE file. */
/***************************************************************/

package com.stuypulse.robot.commands.arm.algae;

import com.stuypulse.robot.commands.arm.ArmToAngle;
import com.stuypulse.robot.constants.Settings;

public class ArmToAlgaeL2 extends ArmToAngle {
public ArmToAlgaeL2() {
super(Settings.Arm.ALGAE_L2_ANGLE);
}

@Override
public void initialize() {
arm.setRotateBoolean(false);
super.initialize();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/************************ PROJECT MARY *************************/
/* Copyright (c) 2025 StuyPulse Robotics. All rights reserved. */
/* Use of this source code is governed by an MIT-style license */
/* that can be found in the repository LICENSE file. */
/***************************************************************/

package com.stuypulse.robot.commands.arm.algae;

import com.stuypulse.robot.commands.arm.ArmToAngle;
import com.stuypulse.robot.constants.Settings;

public class ArmToAlgaeL3 extends ArmToAngle {
public ArmToAlgaeL3() {
super(Settings.Arm.ALGAE_L3_ANGLE);
}

@Override
public void initialize() {
arm.setRotateBoolean(false);
super.initialize();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/************************ PROJECT MARY *************************/
/* Copyright (c) 2025 StuyPulse Robotics. All rights reserved. */
/* Use of this source code is governed by an MIT-style license */
/* that can be found in the repository LICENSE file. */
/***************************************************************/

package com.stuypulse.robot.commands.arm.algae;

import com.stuypulse.robot.commands.arm.ArmToAngle;
import com.stuypulse.robot.constants.Settings;

public class ArmToBarge extends ArmToAngle {
public ArmToBarge() {
super(Settings.Arm.BARGE_ANGLE);
}

@Override
public void initialize() {
arm.setRotateBoolean(false);
super.initialize();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/************************ PROJECT MARY *************************/
/* Copyright (c) 2025 StuyPulse Robotics. All rights reserved. */
/* Use of this source code is governed by an MIT-style license */
/* that can be found in the repository LICENSE file. */
/***************************************************************/

package com.stuypulse.robot.commands.arm.algae;

import com.stuypulse.robot.commands.arm.ArmToAngle;
import com.stuypulse.robot.constants.Settings;

public class ArmToStow extends ArmToAngle {
public ArmToStow() {
super(Settings.Arm.STOW_ANGLE);
}

@Override
public void initialize() {
arm.setRotateBoolean(false);
super.initialize();
}
}
Loading