-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Belt Subsystem with sensors #3
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,34 +4,45 @@ | |
|
||
package frc.robot; | ||
|
||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
import edu.wpi.first.wpilibj2.command.RunCommand; | ||
import edu.wpi.first.wpilibj2.command.button.CommandPS4Controller; | ||
import edu.wpi.first.wpilibj2.command.button.Trigger; | ||
import frc.robot.commands.Autos; | ||
import frc.robot.commands.ExampleCommand; | ||
import frc.robot.subsystems.TankSubsystem; | ||
import frc.robot.subsystems.BeltSubsystem; | ||
|
||
public class RobotContainer { | ||
|
||
// Subsystems defined | ||
private final TankSubsystem tankSubsystem; | ||
private final BeltSubsystem beltSubsystem; | ||
|
||
// Controls defined | ||
private final CommandPS4Controller mechController; | ||
public double joyConLeft; | ||
public double joyConRight; | ||
|
||
// sensors defined | ||
private final DigitalInput beltSwitch; | ||
|
||
public RobotContainer() { | ||
|
||
// Subsystem created | ||
tankSubsystem = new TankSubsystem(); | ||
beltSubsystem = new BeltSubsystem(); | ||
|
||
// Configure Bindings | ||
mechController = new CommandPS4Controller(0); // Use PS4 controller | ||
joyConLeft = 0; | ||
joyConRight = 0; | ||
|
||
// Configure switch | ||
beltSwitch = new DigitalInput(1); // enter belt switch number | ||
|
||
configureBindings(); | ||
} | ||
|
||
|
@@ -53,6 +64,21 @@ private void configureBindings() { | |
this.joyConRight = mechController.getRightY(); // Right Y-axis for PS5 controller | ||
tankSubsystem.setMotors(joyConLeft, joyConRight); | ||
}, tankSubsystem)); | ||
|
||
mechController.square().onTrue(new InstantCommand(() -> { | ||
if (beltSwitch.get()) { | ||
beltSubsystem.breakRoller(true); | ||
; | ||
} else { | ||
beltSubsystem.setBelt(0.2); | ||
} | ||
})); | ||
mechController.circle().onTrue(new InstantCommand(() -> { | ||
beltSubsystem.breakRoller(false); | ||
beltSubsystem.setBelt(0.2); | ||
|
||
})); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you will want an option to run the belt backwards in case of unforseen circumstances. |
||
} | ||
|
||
// /** | ||
|
This file was deleted.
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.subsystems; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.ctre.phoenix.motorcontrol.NeutralMode; | ||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class BeltSubsystem extends SubsystemBase { | ||
|
||
// declaring each motor | ||
private final WPI_TalonSRX mainBeltMotor; | ||
|
||
/** Creates a new ExampleSubsystem. */ | ||
public BeltSubsystem() { | ||
|
||
mainBeltMotor = new WPI_TalonSRX(3); | ||
mainBeltMotor.setNeutralMode(NeutralMode.Coast); // turning braking to Coast | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably want the roller to be perma on brake. Otherwise the gamepiece might slip out. |
||
|
||
} | ||
|
||
/** | ||
* Sets the leftMotors and rightMotors speed and direction. | ||
* | ||
* @param speed The raw motor speed to set the rollers to (typically | ||
* between -1.0 and 1.0). | ||
*/ | ||
public void setBelt(double speed) { | ||
mainBeltMotor.set(speed); | ||
|
||
} | ||
|
||
/** | ||
* Sets the leftMotors and rightMotors brakes. | ||
* | ||
* @param motorBreak boolean for if break | ||
*/ | ||
public void breakRoller(boolean motorBreak) { | ||
if (motorBreak) { | ||
mainBeltMotor.setNeutralMode(NeutralMode.Brake); | ||
} else if (!motorBreak) { | ||
mainBeltMotor.setNeutralMode(NeutralMode.Coast); | ||
} | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"fileName": "NavX.json", | ||
"name": "NavX", | ||
"version": "2024.1.0", | ||
"uuid": "cb311d09-36e9-4143-a032-55bb2b94443b", | ||
"frcYear": "2024", | ||
"mavenUrls": [ | ||
"https://dev.studica.com/maven/release/2024/" | ||
], | ||
"jsonUrl": "https://dev.studica.com/releases/2024/NavX.json", | ||
"javaDependencies": [ | ||
{ | ||
"groupId": "com.kauailabs.navx.frc", | ||
"artifactId": "navx-frc-java", | ||
"version": "2024.1.0" | ||
} | ||
], | ||
"jniDependencies": [], | ||
"cppDependencies": [ | ||
{ | ||
"groupId": "com.kauailabs.navx.frc", | ||
"artifactId": "navx-frc-cpp", | ||
"version": "2024.1.0", | ||
"headerClassifier": "headers", | ||
"sourcesClassifier": "sources", | ||
"sharedLibrary": false, | ||
"libName": "navx_frc", | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"linuxathena", | ||
"linuxraspbian", | ||
"linuxarm32", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"osxuniversal", | ||
"windowsx86-64" | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"fileName": "REVLib.json", | ||
"name": "REVLib", | ||
"version": "2024.2.4", | ||
"frcYear": "2024", | ||
"uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", | ||
"mavenUrls": [ | ||
"https://maven.revrobotics.com/" | ||
], | ||
"jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2024.json", | ||
"javaDependencies": [ | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-java", | ||
"version": "2024.2.4" | ||
} | ||
], | ||
"jniDependencies": [ | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-driver", | ||
"version": "2024.2.4", | ||
"skipInvalidPlatforms": true, | ||
"isJar": false, | ||
"validPlatforms": [ | ||
"windowsx86-64", | ||
"windowsx86", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"linuxathena", | ||
"linuxarm32", | ||
"osxuniversal" | ||
] | ||
} | ||
], | ||
"cppDependencies": [ | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-cpp", | ||
"version": "2024.2.4", | ||
"libName": "REVLib", | ||
"headerClassifier": "headers", | ||
"sharedLibrary": false, | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"windowsx86", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"linuxathena", | ||
"linuxarm32", | ||
"osxuniversal" | ||
] | ||
}, | ||
{ | ||
"groupId": "com.revrobotics.frc", | ||
"artifactId": "REVLib-driver", | ||
"version": "2024.2.4", | ||
"libName": "REVLibDriver", | ||
"headerClassifier": "headers", | ||
"sharedLibrary": false, | ||
"skipInvalidPlatforms": true, | ||
"binaryPlatforms": [ | ||
"windowsx86-64", | ||
"windowsx86", | ||
"linuxarm64", | ||
"linuxx86-64", | ||
"linuxathena", | ||
"linuxarm32", | ||
"osxuniversal" | ||
] | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this semicolon supposed to be here