Skip to content

Commit

Permalink
Rush completion of the NewbieBot
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettsummerfi3ld committed Oct 6, 2023
1 parent 26e4ef6 commit c8cc656
Show file tree
Hide file tree
Showing 13 changed files with 347 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .wpilib/wpilib_preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2023",
"teamNumber": 8719
"teamNumber": 9999
}
Empty file modified gradlew
100644 → 100755
Empty file.
35 changes: 33 additions & 2 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,38 @@
* constants are needed, to reduce verbosity.
*/
public final class Constants {
public static class OperatorConstants {
public static final int kDriverControllerPort = 0;
// Hardware CAN IDs
public class HardwareConstants {

Check warning on line 17 in src/main/java/frc/robot/Constants.java

View workflow job for this annotation

GitHub Actions / qodana

Inner class may be 'static'

Inner class `HardwareConstants` may be 'static'
public static final int powerDistribution = 2;
public static final int pneumaticControl = 7;
}

// Drivetrain CAN IDs
public class DrivetrainConstants {

Check warning on line 23 in src/main/java/frc/robot/Constants.java

View workflow job for this annotation

GitHub Actions / qodana

Inner class may be 'static'

Inner class `DrivetrainConstants` may be 'static'
public static final int rightMotor1 = 3;
public static final boolean rightMotor1Inverted = true;

public static final int rightMotor2 = 4;
public static final boolean rightMotor2Inverted = true;

public static final int leftMotor1 = 5;
public static final boolean leftMotor1Inverted = false;

public static final int leftMotor2 = 6;
public static final boolean leftMotor2Inverted = false;
}

// PCM Ports for Pneumatics
public class PneumaticsConstants {

Check warning on line 38 in src/main/java/frc/robot/Constants.java

View workflow job for this annotation

GitHub Actions / qodana

Inner class may be 'static'

Inner class `PneumaticsConstants` may be 'static'
public static final int openSolenoid = 0;
public static final int closeSolenoid = 1;
}

// Controllers
public class ControllersConstants {

Check warning on line 44 in src/main/java/frc/robot/Constants.java

View workflow job for this annotation

GitHub Actions / qodana

Inner class may be 'static'

Inner class `ControllersConstants` may be 'static'
public static final int driverControllerPort = 0;
public static final int operatorControllerPort = 1;
public static final int pistonButtonOpen = 1;
public static final int pistonButtonClose = 2;
}
}
19 changes: 2 additions & 17 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.Constants.OperatorConstants;
import frc.robot.commands.Autos;
import frc.robot.commands.ExampleCommand;
import frc.robot.subsystems.ExampleSubsystem;

/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
Expand All @@ -20,11 +16,8 @@
*/
public class RobotContainer {
// The robot's subsystems and commands are defined here...
private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem();

// Replace with CommandPS4Controller or CommandJoystick if needed
private final CommandXboxController m_driverController =
new CommandXboxController(OperatorConstants.kDriverControllerPort);

/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {
Expand All @@ -41,15 +34,7 @@ public RobotContainer() {
* PS4} controllers or {@link edu.wpi.first.wpilibj2.command.button.CommandJoystick Flight
* joysticks}.
*/
private void configureBindings() {
// Schedule `ExampleCommand` when `exampleCondition` changes to `true`
new Trigger(m_exampleSubsystem::exampleCondition)
.onTrue(new ExampleCommand(m_exampleSubsystem));

// Schedule `exampleMethodCommand` when the Xbox controller's B button is pressed,
// cancelling on release.
m_driverController.b().whileTrue(m_exampleSubsystem.exampleMethodCommand());
}
private void configureBindings() {}

/**
* Use this to pass the autonomous command to the main {@link Robot} class.
Expand All @@ -58,6 +43,6 @@ private void configureBindings() {
*/
public Command getAutonomousCommand() {
// An example command will be run in autonomous
return Autos.exampleAuto(m_exampleSubsystem);
return null;
}
}
20 changes: 0 additions & 20 deletions src/main/java/frc/robot/commands/Autos.java

This file was deleted.

58 changes: 58 additions & 0 deletions src/main/java/frc/robot/commands/Drive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// 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.

package frc.robot.commands;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.Constants;
import frc.robot.subsystems.Drivetrain;

public class Drive extends CommandBase {

// The subsystem the command runs on
private final Drivetrain m_subDrivetrain;

// The controller the command runs on
private final Joystick m_driverController =
new Joystick(Constants.ControllersConstants.driverControllerPort);

/**
* Creates a new Drive command.
*
* @param subsystem The subsystem used by this command.
*/
public Drive(Drivetrain subsystem) {
m_subDrivetrain = subsystem;
addRequirements(subsystem);

SmartDashboard.putData(subsystem);
}

/** Called when the command is initially scheduled. */
@Override
public void initialize() {
System.out.println("Drive initialized");
}

/** Called every time the scheduler runs while the command is scheduled. */
@Override
public void execute() {
m_subDrivetrain.arcadeDrive(m_driverController.getX(), m_driverController.getY());
}

/** Called once the command ends or is interrupted. */
@Override
public void end(boolean interrupted) {
m_subDrivetrain.arcadeDrive(0, 0);
System.out.println("Drive ended");
}

/** Returns true when the command should end. */
@Override
public boolean isFinished() {
return false;
}
}
43 changes: 0 additions & 43 deletions src/main/java/frc/robot/commands/ExampleCommand.java

This file was deleted.

55 changes: 55 additions & 0 deletions src/main/java/frc/robot/commands/PistonControl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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.

package frc.robot.commands;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.Constants;
import frc.robot.subsystems.Pneumatics;

public class PistonControl extends CommandBase {

private final Pneumatics m_subPneumatics;

private final Joystick m_operatorJoystick =
new Joystick(Constants.ControllersConstants.operatorControllerPort);

/** Creates a new PistonControl. */
public PistonControl(Pneumatics subsystem) {
m_subPneumatics = subsystem;
addRequirements(subsystem);

SmartDashboard.putData(subsystem);
}

/** Called when the command is initially scheduled. */
@Override
public void initialize() {
System.out.println("PistonControl initialized");
}

/** Called every time the scheduler runs while the command is scheduled. */
@Override
public void execute() {
if (m_operatorJoystick.getRawButton(Constants.ControllersConstants.pistonButtonOpen)) {
m_subPneumatics.open();
} else if (m_operatorJoystick.getRawButton(Constants.ControllersConstants.pistonButtonClose)) {
m_subPneumatics.close();
}
}

/** Called once the command ends or is interrupted. */
@Override
public void end(boolean interrupted) {
System.out.println("PistonControl ended");
}

/** Returns true when the command should end. */
@Override
public boolean isFinished() {
return false;
}
}
62 changes: 62 additions & 0 deletions src/main/java/frc/robot/subsystems/Drivetrain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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.

package frc.robot.subsystems;

import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;

public class Drivetrain extends SubsystemBase {

/** The motors on the right side of the drive. */
private CANSparkMax rightMotor1 =
new CANSparkMax(Constants.DrivetrainConstants.rightMotor1, MotorType.kBrushed);

private CANSparkMax rightMotor2 =
new CANSparkMax(Constants.DrivetrainConstants.rightMotor2, MotorType.kBrushed);

/** The motors on the left side of the drive. */
private CANSparkMax leftMotor1 =
new CANSparkMax(Constants.DrivetrainConstants.leftMotor1, MotorType.kBrushed);

private CANSparkMax leftMotor2 =
new CANSparkMax(Constants.DrivetrainConstants.leftMotor2, MotorType.kBrushed);

/** Configuration for the motor controllers to run together in a group. */
MotorControllerGroup rightMotors = new MotorControllerGroup(rightMotor1, rightMotor2);

MotorControllerGroup leftMotors = new MotorControllerGroup(leftMotor1, leftMotor2);

/** The robot's drive. */
private final DifferentialDrive drive = new DifferentialDrive(leftMotors, rightMotors);

/** Creates a new Drivetrain subsystem. */
public Drivetrain() {
System.out.println("Drivetrain initialized");
}

/**
* Arcade drive method for differential drive platform. The calculated values will be squared to
* decrease sensitivity at low speeds.
*
* @param speed The robot's speed along the X axis [-1.0..1.0]. Forward is positive.
* @param rotation The robot's rotation rate around the Z axis [-1.0..1.0]. Clockwise is positive.
*/
public void arcadeDrive(double speed, double rotation) {
drive.arcadeDrive(speed, rotation);
}

@Override
/**
* Periodic method for the drivetrain subsystem. This method will be called once per scheduler
* run.
*/
public void periodic() {
// This method will be called once per scheduler run
}
}
47 changes: 0 additions & 47 deletions src/main/java/frc/robot/subsystems/ExampleSubsystem.java

This file was deleted.

Loading

0 comments on commit c8cc656

Please sign in to comment.