Skip to content

Commit

Permalink
chore: merge pull request #23 from frc6941/feat/stream-deck
Browse files Browse the repository at this point in the history
feat: add stream deck as a controller
  • Loading branch information
RealAllenDa authored Feb 8, 2025
2 parents d06f4a2 + 294b410 commit b371a6a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 29 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
### FRC 10541 IronPulse 2025 Competition Robot
# FRC 10541 IronPulse 2025 Competition Robot

## Troubleshooting

- If Stream Deck doesn't work properly
- the profile of stream deck is in **profiles/FRC10541.streamDeckProfile**
- see https://github.com/ashupp/Streamdeck-vJoy
- If simulation failed with **MSVC error**, set the project JDK to wpilib2025 and add simulate to gradle run/debug
config in IDEA, see https://www.chiefdelphi.com/t/error-when-running-simulation-wpilib-2025-2-1/481435

## Stream Deck

Configure it in *Configure vJoy*, monitor it in *vJoy Monitor*

### Keyboard layout

- ID 1-12: Start from the left branch of the two nearest branch(ID1), then go counter-clockwise.
- ID 13-16: L1-4
Binary file added profiles/FRC10541.streamDeckProfile
Binary file not shown.
21 changes: 11 additions & 10 deletions src/main/java/frc/robot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
* call.
*/
public final class Main {
private Main() {}
private Main() {
}

/**
* Main initialization function. Do not perform any initialization here.
*
* <p>If you change your main robot class, change the parameter type.
*/
public static void main(String... args) {
RobotBase.startRobot(Robot::new);
}
}
/**
* Main initialization function. Do not perform any initialization here.
*
* <p>If you change your main robot class, change the parameter type.
*/
public static void main(String... args) {
RobotBase.startRobot(Robot::new);
}
}
39 changes: 22 additions & 17 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
package frc.robot;

import com.pathplanner.lib.util.FileVersionException;

import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.button.*;

import frc.robot.auto.basics.AutoActions;
import frc.robot.commands.*;
import frc.robot.commands.ElevatorZeroingCommand;
import frc.robot.commands.RumbleCommand;
import frc.robot.display.Display;
import frc.robot.subsystems.Superstructure;
import frc.robot.subsystems.apriltagvision.AprilTagVision;
Expand All @@ -28,30 +27,30 @@
import frc.robot.subsystems.swerve.Swerve;
import frc.robot.utils.AllianceFlipUtil;
import lombok.Getter;

import org.frcteam6941.looper.UpdateManager;
import org.json.simple.parser.ParseException;

import java.io.IOException;
import java.util.function.BooleanSupplier;

import static edu.wpi.first.units.Units.Seconds;
import static frc.robot.RobotConstants.BeamBreakConstants.*;
import static frc.robot.RobotConstants.BeamBreakConstants.ENDEFFECTOR_EDGE_BEAMBREAK_ID;
import static frc.robot.RobotConstants.BeamBreakConstants.ENDEFFECTOR_MIDDLE_BEAMBREAK_ID;
import static frc.robot.RobotConstants.ElevatorConstants.*;

import java.io.IOException;
import java.util.function.*;

/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
* "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot}
* periodic methods (other than the scheduler calls). Instead, the structure of the robot (including
* subsystems, commands, and trigger mappings) should be declared here.
*/
public class RobotContainer {
@Getter
private final UpdateManager updateManager;
CommandXboxController driverController = new CommandXboxController(0);
CommandXboxController operatorController = new CommandXboxController(1);
CommandXboxController testerController = new CommandXboxController(2);

@Getter
private final UpdateManager updateManager;
CommandGenericHID streamDeckController = new CommandGenericHID(3);
double lastResetTime = 0.0;

// The robot's subsystems and commands are defined here...
Expand All @@ -64,7 +63,7 @@ public class RobotContainer {
ElevatorSubsystem elevatorSubsystem = new ElevatorSubsystem(new ElevatorIOReal());
EndEffectorSubsystem endEffectorSubsystem = new EndEffectorSubsystem(new EndEffectorIOReal(), new BeambreakIOReal(ENDEFFECTOR_MIDDLE_BEAMBREAK_ID), new BeambreakIOReal(ENDEFFECTOR_EDGE_BEAMBREAK_ID));

Superstructure superstructure = new Superstructure(endEffectorSubsystem);
Superstructure superstructure = new Superstructure(endEffectorSubsystem);

/**
* The container for the robot. Contains subsystems, OI devices, and commands.
Expand All @@ -77,6 +76,7 @@ public RobotContainer() {
configureDriverBindings(driverController);
configureOperatorBindings(operatorController);
configureTesterBindings(testerController);
configureStreamDeckBindings(streamDeckController);
}

/**
Expand Down Expand Up @@ -138,13 +138,18 @@ private void configureTesterBindings(CommandXboxController controller) {
new Trigger(controller.start())
.onTrue(superstructure.setWantedSuperStateCommand(Superstructure.WantedSuperState.STOPPED));
//test of elevator heights
controller.a().onTrue(Commands.runOnce(() -> elevatorSubsystem.setPosition(L1_EXTENSION_METERS.get()),elevatorSubsystem).until(() ->elevatorSubsystem.isAtSetpoint(L1_EXTENSION_METERS.get())));
controller.b().onTrue(Commands.runOnce(() -> elevatorSubsystem.setPosition(L2_EXTENSION_METERS.get()),elevatorSubsystem).until(() ->elevatorSubsystem.isAtSetpoint(L2_EXTENSION_METERS.get())));
controller.x().onTrue(Commands.runOnce(() -> elevatorSubsystem.setPosition(L3_EXTENSION_METERS.get()),elevatorSubsystem).until(() ->elevatorSubsystem.isAtSetpoint(L3_EXTENSION_METERS.get())));
controller.y().onTrue(Commands.runOnce(() -> elevatorSubsystem.setPosition(L4_EXTENSION_METERS.get()),elevatorSubsystem).until(() ->elevatorSubsystem.isAtSetpoint(L4_EXTENSION_METERS.get())));
controller.a().onTrue(Commands.runOnce(() -> elevatorSubsystem.setPosition(L1_EXTENSION_METERS.get()), elevatorSubsystem).until(() -> elevatorSubsystem.isAtSetpoint(L1_EXTENSION_METERS.get())));
controller.b().onTrue(Commands.runOnce(() -> elevatorSubsystem.setPosition(L2_EXTENSION_METERS.get()), elevatorSubsystem).until(() -> elevatorSubsystem.isAtSetpoint(L2_EXTENSION_METERS.get())));
controller.x().onTrue(Commands.runOnce(() -> elevatorSubsystem.setPosition(L3_EXTENSION_METERS.get()), elevatorSubsystem).until(() -> elevatorSubsystem.isAtSetpoint(L3_EXTENSION_METERS.get())));
controller.y().onTrue(Commands.runOnce(() -> elevatorSubsystem.setPosition(L4_EXTENSION_METERS.get()), elevatorSubsystem).until(() -> elevatorSubsystem.isAtSetpoint(L4_EXTENSION_METERS.get())));
controller.povDown().onTrue(new ElevatorZeroingCommand(elevatorSubsystem));
}

//Configure all commands for Stream Deck
private void configureStreamDeckBindings(CommandGenericHID controller) {
controller.button(1).onTrue(Commands.runOnce(() -> System.out.println("Stream Deck Controller Test Successful!")));
}

/**
* Use this to pass the autonomous command to the main {@link Robot} class.
*
Expand All @@ -162,7 +167,7 @@ public Command getAutonomousCommand() throws FileVersionException, IOException,
}

private Command rumbleDriver(double seconds) {
return new RumbleCommand(Seconds.of(seconds), driverController.getHID());
return new RumbleCommand(Seconds.of(seconds), driverController.getHID());
}

public FieldConstants.AprilTagLayoutType getAprilTagLayoutType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public void periodic() {

serial.writeString("OK");
serial.flush();
System.out.println("Test");

// Loop over instances to process all frames and poses
List<Pose2d> allRobotPoses = new ArrayList<>();
Expand Down

0 comments on commit b371a6a

Please # to comment.