Skip to content

Commit

Permalink
Merge pull request #5 from frc6506/BSI-2022-12-03-commans
Browse files Browse the repository at this point in the history
Bsi 2022 12 03 commans
  • Loading branch information
BobSaidHi authored Mar 18, 2022
2 parents f8d1058 + f03a787 commit 66bf04b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public final class Constants {
public static final int JOYSTICK_DRIVE_SPEED_ID = 1; // Y-axis
public static final int JOYSTICK_DRIVE_ROTATION_ID = 0; // X-axis

// Buttons
public static final int JOYSTICK_BUTTON_SHOOT_ID = 1; // Xbox controller button for shooting

// Drivetrain
public static final int MOTOR_RIGHT_FRONT_ID = 10;
public static final int MOTOR_RIGHT_BACK_ID = 11;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package frc.robot;

import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.cscore.UsbCamera;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
Expand All @@ -29,6 +31,12 @@ public void robotInit() {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.
m_robotContainer = new RobotContainer();

// Setup USB camera
// UsbCamera cam = CameraServer.getInstance().startAutomaticCapture();
UsbCamera cam = CameraServer.startAutomaticCapture();
cam.setResolution(160, 120);
cam.setFPS(30);
}

/**
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.wpi.first.wpilibj.XboxController;
// import frc.robot.subsystems.ExampleSubsystem;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import frc.robot.commands.ArcadeDrive;
import frc.robot.commands.BringInOutAndIn;
import frc.robot.commands.ExtendInAndOut;
Expand All @@ -17,7 +18,6 @@
import frc.robot.commands.SpinFlywheel;
import frc.robot.commands.SpinIntakeWheel;
import frc.robot.subsystems.ClimbRaiser;
// import edu.wpi.first.wpilibj.XboxController;
// import frc.robot.commands.ExampleCommand;
import frc.robot.subsystems.Drivetrain;
import frc.robot.subsystems.InAndOut2;
Expand All @@ -39,6 +39,11 @@ public class RobotContainer {

// Controls
public static final XboxController controller = new XboxController(Constants.CONTROLLER_PORT_ID);
// It's recomend ot use the provided enum to look button ids - see
// https://docs.wpilib.org/en/stable/docs/software/commandbased/binding-commands-to-triggers.html,
// https://first.wpi.edu/wpilib/allwpilib/docs/release/java/edu/wpi/first/wpilibj/XboxController.Button.html,and https://first.wpi.edu/wpilib/allwpilib/docs/release/java/src-html/edu/wpi/first/wpilibj/XboxController.Button.html#line.24
public static final JoystickButton shootButton =
new JoystickButton(controller, Constants.JOYSTICK_BUTTON_SHOOT_ID);

// Subystems
public static Drivetrain drivetrain = new Drivetrain(); // Drivetrain
Expand Down Expand Up @@ -78,6 +83,8 @@ public class RobotContainer {
public RobotContainer() {
// setting default commands
drivetrain.setDefaultCommand(arcadeDrive);
intake.setDefaultCommand(spinIntakeWheel);

// Configure the button bindings
configureButtonBindings();
}
Expand All @@ -88,7 +95,9 @@ public RobotContainer() {
* edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then passing it to a {@link
* edu.wpi.first.wpilibj2.command.button.JoystickButton}.
*/
private void configureButtonBindings() {}
private void configureButtonBindings() {
shootButton.whileHeld(spinFeedWheel);
}

/**
* Use this to pass the autonomous command to the main {@link Robot} class.
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/frc/robot/subsystems/Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

package frc.robot.subsystems;

import com.kauailabs.navx.frc.AHRS;
import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
import edu.wpi.first.wpilibj.SPI;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
Expand All @@ -32,8 +34,16 @@ public class Drivetrain extends SubsystemBase {

DifferentialDrive dualDrive = new DifferentialDrive(leftMotors, rightMotors);

// NavX gyroscope
AHRS gyro = new AHRS(SPI.Port.kMXP);

public Drivetrain() {}

@Override
public void periodic() {
// This method will be called once per scheduler run
}

// Wrapper Methods
/**
* @param speed decimal percent [-1.0, 1.0]
Expand All @@ -50,9 +60,4 @@ public void aDrive(double speed, double rotation) {
public void dDrive(double leftSpeed, double rightSpeed) {
dualDrive.tankDrive(leftSpeed, rightSpeed);
}

@Override
public void periodic() {
// This method will be called once per scheduler run
}
}
35 changes: 35 additions & 0 deletions vendordeps/navx_frc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"fileName": "navx_frc.json",
"name": "KauaiLabs_navX_FRC",
"version": "4.0.442",
"uuid": "cb311d09-36e9-4143-a032-55bb2b94443b",
"mavenUrls": [
"https://repo1.maven.org/maven2/"
],
"jsonUrl": "https://www.kauailabs.com/dist/frc/2022/navx_frc.json",
"javaDependencies": [
{
"groupId": "com.kauailabs.navx.frc",
"artifactId": "navx-java",
"version": "4.0.442"
}
],
"jniDependencies": [],
"cppDependencies": [
{
"groupId": "com.kauailabs.navx.frc",
"artifactId": "navx-cpp",
"version": "4.0.442",
"headerClassifier": "headers",
"sourcesClassifier": "sources",
"sharedLibrary": false,
"libName": "navx_frc",
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"linuxathena",
"linuxraspbian",
"windowsx86-64"
]
}
]
}

0 comments on commit 66bf04b

Please sign in to comment.