USB edition Digital Deluxe

This commit is contained in:
‮Zach Wilke
2021-10-28 16:20:00 -06:00
parent 2e24b95793
commit d348a100b1
7 changed files with 72 additions and 14 deletions
+2 -2
View File
@@ -1,2 +1,2 @@
# Robot-Essentials
Basic code for any Ridgebotics robot project
# To-Shoot-TShirt
Code to shoot any small and light object out of a barrel on the T-shirt cannon robot.
@@ -54,4 +54,8 @@ public final class Constants {
public static final int SHOOTER_SOLENOID_6_ID = 7;
public static final int SHOOTER_SOLENOID_7_ID = 8;
}
public static final class DebugConstants {
public static final boolean SHOW_INFO = true;
public static final Str TYPE_INFO = "INFO";
}
}
@@ -1,4 +1,3 @@
/* 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 */
@@ -54,6 +53,7 @@ public class RobotContainer {
private final ShootTube m_robotShooter = new ShootTube(SolenoidArray);
private final DPrinter m_debugLogger = m_robotMap.DPrinter
/* Controllers */
private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID);
private final XboxController m_operatorXbox = new XboxController(OIConstants.XBOX_OPERATOR_ID);
@@ -117,6 +117,10 @@ public class RobotContainer {
.whenPressed(() -> m_robotShooter.ShootTubeALL(true))
.whenReleased(() -> m_robotShooter.ShootTubeALL(false));
/* Just A test of the DPrint object */
new JoystickButton(getOperatorJoystick(), XboxController.B_BUTTON)
.whenPressed(() -> m_debugLogger.println("This is a Debug Message"));
}
+5 -1
View File
@@ -19,6 +19,7 @@ import frc4388.robot.Constants.DriveConstants;
import frc4388.robot.Constants.HornConstants;
import frc4388.robot.Constants.LEDConstants;
import frc4388.utility.RobotGyro;
import frc4388.utility.DPrint;
/**
* Defines and holds all I/O objects on the Roborio. This is useful for unit
@@ -81,5 +82,8 @@ public class RobotMap {
public final Solenoid ShooterSolenoid4 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_4_ID);
public final Solenoid ShooterSolenoid5 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_5_ID);
public final Solenoid ShooterSolenoid6 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_6_ID);
public final Solenoid ShooterSolenoid7 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_7_ID);
public final Solenoid ShooterSolenoid7 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_7_ID);
/* DPrint Utility */
public final DPrint DPrinter = new DPrint(DebugConstants.TYPE_INFO);
}
@@ -1,8 +1,8 @@
/* 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.
/* This Command has been gutted. Like a fish */
package frc4388.robot.commands;
import edu.wpi.first.wpilibj2.command.CommandBase;
@@ -1,4 +1,3 @@
/* 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.
@@ -6,11 +5,12 @@
package frc4388.robot.subsystems;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc4388.utility.DPrint;
import frc4388.robot.Constants.DebugConstants;
import edu.wpi.first.wbilib.Solnoid;
DPrint DPrinter = new DPrint(DebugConstants.TYPE_INFO)
public class ShootTube extends SubsystemBase {
/** Creates a new ShootTube. */
Solenoid[] m_solenoids;
int m_cycleCount = 0;
int m_maxCount;
@@ -19,39 +19,52 @@ public class ShootTube extends SubsystemBase {
m_maxCount = m_solenoids.length;
}
/*
Functions designed for the DPAD left and right buttions to
Cycle the tube to be shooting out of
Functions designed for the Left and Right Bumpers to
Cycle the tube slected manualy.
*/
public void CycleUp() {
m_cycleCount++;
if (m_cycleCount >= m_maxCount || m_cycleCount < 0) {
m_cycleCount = 0;
}
}
DPrinter.println("Current CycleCount: "+m_cycleCount)
}
public void CycleDown() {
m_cycleCount--;
if (m_cycleCount >= m_maxCount || m_cycleCount < 0) {
m_cycleCount = 0;
}
}
DPrinter.println("Current CycleCount: "+m_cycleCount)
}
/*
Normal Shoot Tube and Normal Shoot Tube Index Functions
*/
/* Function "ShootTubeSet" cycles up automaticly */
public void ShootTubeSet(Boolean arg) {
m_solenoids[CycleCount].set(arg);
/* If closing valve:
Increse the CycleCount by one,
if the CycleCount >= the length of the array OR CycleCount < 0:
set CycleCount to 0 */
if (arg == false) {
CycleCount++;
m_cycleCount++;
if (m_cycleCount >= m_maxCount || m_cycleCount < 0) {
m_cycleCount = 0;
}
}
DPrinter.println("Current CycleCount: "+m_cycleCount)
}
/* Function "ShootTubeIndex" won't cycle up automaticly */
/* Not used, yet Useful */
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
in the array in enumeration
can't do m_solenoids[1].set(true), m_solenoids[2].set(true) due to
the fact that the object needs to be variable in the length of the array
Designed for the X buttion
*/
public void ShootTubeALL(Boolean arg) {
for (Solenoid x : m_solenoids) {
+33
View File
@@ -0,0 +1,33 @@
/* Simple Debug Log To Console Utility. */
package frc4388.utility;
import frc4388.robot.Constants.DebugConstants;
public class DPrint {
str m_debugMsgType = DebugConstants.TYPE_INFO;
public DPrint(str type) {
m_debugMsgType = type;
}
public println(str[] mesage) {
switch (m_debugMsgType) {
case DebugConstants.TYPE_INFO:
if (DebugConstants.SHOW_INFO) {
system.out.println("Debug_INFO: "+mesage);
}
;
default:
;
}
}
public print(str[] mesage) {
switch (m_debugMsgType) {
case DebugConstants.TYPE_INFO:
if (DebugConstants.SHOW_INFO) {
system.out.print("Debug_INFO: "+mesage);
}
;
default:
;
}
}
}