mirror of
https://github.com/Team4388/To-Shoot-TShirt.git
synced 2026-06-09 00:38:05 -06:00
USB edition
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* Dumb Command Version, Smart Subsytem Version */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
@@ -15,6 +16,7 @@ import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
||||
import frc4388.robot.Constants.*;
|
||||
import frc4388.robot.subsystems.Drive;
|
||||
import frc4388.robot.subsystems.Horn;
|
||||
import frc4388.robot.subsystems.ShootTube;
|
||||
import frc4388.robot.subsystems.LED;
|
||||
import frc4388.utility.LEDPatterns;
|
||||
import frc4388.utility.controller.IHandController;
|
||||
@@ -39,11 +41,7 @@ public class RobotContainer {
|
||||
|
||||
private final Horn m_robotHorn = new Horn(m_robotMap.HornSolenoid);
|
||||
|
||||
/* Controllers */
|
||||
private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID);
|
||||
private final XboxController m_operatorXbox = new XboxController(OIConstants.XBOX_OPERATOR_ID);
|
||||
|
||||
private final Solenoid[] tubes = {
|
||||
private final Solenoid[] SolenoidArray = {
|
||||
m_robotMap.ShooterSolenoid0,
|
||||
m_robotMap.ShooterSolenoid1,
|
||||
m_robotMap.ShooterSolenoid2,
|
||||
@@ -51,7 +49,15 @@ public class RobotContainer {
|
||||
m_robotMap.ShooterSolenoid4,
|
||||
m_robotMap.ShooterSolenoid5,
|
||||
m_robotMap.ShooterSolenoid6,
|
||||
m_robotMap.ShooterSolenoid7};
|
||||
m_robotMap.ShooterSolenoid7
|
||||
};
|
||||
|
||||
private final ShootTube m_robotShooter = new ShootTube(SolenoidArray);
|
||||
|
||||
/* Controllers */
|
||||
private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID);
|
||||
private final XboxController m_operatorXbox = new XboxController(OIConstants.XBOX_OPERATOR_ID);
|
||||
|
||||
|
||||
/**
|
||||
* The container for the robot. Contains subsystems, OI devices, and commands.
|
||||
@@ -87,15 +93,29 @@ public class RobotContainer {
|
||||
.whenPressed(() -> m_robotLED.setPattern(LEDPatterns.LAVA_RAINBOW))
|
||||
.whenReleased(() -> m_robotLED.setPattern(LEDConstants.DEFAULT_PATTERN));
|
||||
*/
|
||||
// Fire horn
|
||||
/* Fire horn */
|
||||
new JoystickButton(getOperatorJoystick(), XboxController.LEFT_TRIGGER_AXIS)
|
||||
.whenPressed(() -> m_robotHorn.hornSet(true))
|
||||
.whenReleased(() -> m_robotHorn.hornSet(false));
|
||||
|
||||
/* Shoot T-Shirt */
|
||||
new JoystickButton(getOperatorJoystick(), XboxController.RIGHT_TRIGGER_AXIS)
|
||||
.whenPressed(() -> new ShootYourShot(true)) /*Fire one per once triger*/
|
||||
.whenReleased(() -> new ShootYourShot(false));
|
||||
.whenPressed(() -> m_robotShooter.ShootTubeSet(true))
|
||||
.whenReleased(() -> m_robotShooter.ShootTubeSet(false));
|
||||
|
||||
/* TODO: Check if these binds work */
|
||||
/* Cycle Between Solenoids */
|
||||
new JoystickButton(getOperatorJoystick(), XboxController.DPAD_LEFT)
|
||||
.whenPressed(() -> m_robotShooter.CycleDown());
|
||||
|
||||
new JoystickButton(getOperatorJoystick(), XboxController.DPAD_RIGHT)
|
||||
.whenPressed(() -> m_robotShooter.CycleUp());
|
||||
|
||||
/* Fire All of the Solenoids In the Shooter Array */
|
||||
/* Extra power. this will be truly worth "I Survived the T Shirt Cannon" T-shirt */
|
||||
new JoystickButton(getOperatorJoystick(), XboxController.DPAD_DOWN)
|
||||
.whenPressed(() -> m_robotShooter.ShootTubeALL(true))
|
||||
.whenReleased(() -> m_robotShooter.ShootTubeALL(false));
|
||||
|
||||
|
||||
}
|
||||
@@ -137,4 +157,4 @@ public class RobotContainer {
|
||||
public Joystick getDriverJoystick() {
|
||||
return m_driverXbox.getJoyStick();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
/* Dumb Command Version, Smart Subsytem Version */
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
@@ -7,14 +8,10 @@ package frc4388.robot.commands;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
|
||||
public class ShootYourShot extends CommandBase {
|
||||
private Solenoid[] m_solenoids = {};
|
||||
private int counter;
|
||||
|
||||
/** Creates a new ShootYourShot
|
||||
*. */
|
||||
public ShootYourShot(Solenoid[] solenoids) {
|
||||
m_solenoids = solenoids;
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@@ -24,13 +21,12 @@ public class ShootYourShot extends CommandBase {
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
ShootTube.ShootTubeSet(m_solenoids[counter]);
|
||||
ShootTube.ShootTubeSet(true);
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
counter += 1;
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@@ -38,4 +34,4 @@ public class ShootYourShot extends CommandBase {
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
/* Dumb Command Version, Smart Subsytem Version */
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
@@ -9,18 +10,57 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import edu.wpi.first.wbilib.Solnoid;
|
||||
|
||||
public class ShootTube extends SubsystemBase {
|
||||
/** Creates a new ShootTube. */
|
||||
Solenoid m_solenoids;
|
||||
public ShootTube(Solenoid[] solenoids) {
|
||||
m_solenoids = solenoids;
|
||||
}
|
||||
|
||||
public void ShootTubeSet(boolean arg, Solenoid tube) {
|
||||
tube.set(arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void periodic() {
|
||||
// This method will be called once per scheduler run
|
||||
}
|
||||
}
|
||||
/** Creates a new ShootTube. */
|
||||
Solenoid[] m_solenoids;
|
||||
int m_cycleCount = 0;
|
||||
int m_maxCount;
|
||||
public ShootTube(Solenoid[] solenoids) {
|
||||
m_solenoids = solenoidArray;
|
||||
m_maxCount = m_solenoids.length;
|
||||
}
|
||||
/*
|
||||
Functions designed for the DPAD left and right buttions to
|
||||
Cycle the tube to be shooting out of
|
||||
*/
|
||||
public void CycleUp() {
|
||||
m_cycleCount++;
|
||||
if (m_cycleCount >= m_maxCount || m_cycleCount < 0) {
|
||||
m_cycleCount = 0;
|
||||
}
|
||||
}
|
||||
public void CycleDown() {
|
||||
m_cycleCount--;
|
||||
if (m_cycleCount >= m_maxCount || m_cycleCount < 0) {
|
||||
m_cycleCount = 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
Normal Shoot Tube and Normal Shoot Tube Index Functions
|
||||
*/
|
||||
public void ShootTubeSet(Boolean arg) {
|
||||
m_solenoids[CycleCount].set(arg);
|
||||
if (arg == false) {
|
||||
CycleCount++;
|
||||
if (m_cycleCount >= m_maxCount || m_cycleCount < 0) {
|
||||
m_cycleCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void ShootTubeIndex(Boolean arg, int i) {
|
||||
m_solenoids[i].set(arg);
|
||||
}
|
||||
/*
|
||||
Just Normal Shoot Tube But it Shoots all of the tubes
|
||||
Designed for DPAD Down
|
||||
*/
|
||||
public void ShootTubeALL(Boolean arg) {
|
||||
for (Solenoid x : m_solenoids) {
|
||||
x.set(arg);
|
||||
}
|
||||
m_cycleCount = 0;
|
||||
}
|
||||
@Override
|
||||
public void periodic() {
|
||||
// This method will be called once per scheduler run
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user