Skip to content
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

Intake #2

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.1.1"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
}

java {
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
9 changes: 9 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,14 @@
public final class Constants {
public static class OperatorConstants {
public static final int kDriverControllerPort = 0;
public static final int kDriverMechPort = 1;

public static final int leftFrontMotor = 0;
public static final int leftBackMotor = 1;
public static final int rightFrontMotor = 2;
public static final int rightBackMotor = 3;

public static final int dustpanMotor = 4;

}
}
20 changes: 20 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

import frc.robot.Constants.OperatorConstants;
import frc.robot.subsystems.DriveSubsystem;
import frc.robot.subsystems.IntakeSubsystem;
import edu.wpi.first.wpilibj.XboxController;
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.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import edu.wpi.first.wpilibj2.command.button.Trigger;

/**
Expand All @@ -20,14 +24,23 @@
public class RobotContainer {
// The robot's subsystems and commands are defined here...
private final DriveSubsystem driveSubsystem;
private final IntakeSubsystem intakeSubsystem;


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


private final CommandXboxController mechController =
new CommandXboxController(OperatorConstants.kDriverMechPort);



/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {
driveSubsystem = new DriveSubsystem();
intakeSubsystem = new IntakeSubsystem();
// Configure the trigger bindings
configureBindings();
}
Expand All @@ -46,6 +59,13 @@ private void configureBindings() {
driveSubsystem.setDrivePowers(driverController.getLeftY(), driverController.getRightY());
Copy link
Contributor

@CrolineCrois CrolineCrois Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap subsystem bindings in a .setDefaultCommand(new InstantCommand( () -> )) so the setters are called continuously and not just once.

}, driveSubsystem));

intakeSubsystem.setDefaultCommand(new InstantCommand(()-> {
intakeSubsystem.SetIntakeSpeed(mechController.getLeftTriggerAxis()-mechController.getRightTriggerAxis());
}, intakeSubsystem));




}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/frc/robot/subsystems/DriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.ctre.phoenix6.hardware.TalonFX;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.OperatorConstants;

public class DriveSubsystem extends SubsystemBase {

Expand All @@ -21,10 +22,10 @@ public class DriveSubsystem extends SubsystemBase {
private double leftPower, rightPower;

public DriveSubsystem() {
leftFrontMotor = new WPI_TalonSRX(0);
leftBackMotor = new WPI_TalonSRX(1);
rightFrontMotor = new WPI_TalonSRX(2);
rightBackMotor = new WPI_TalonSRX(3);
leftFrontMotor = new WPI_TalonSRX(OperatorConstants.leftFrontMotor);
leftBackMotor = new WPI_TalonSRX(OperatorConstants.rightBackMotor);
rightFrontMotor = new WPI_TalonSRX(OperatorConstants.rightFrontMotor);
rightBackMotor = new WPI_TalonSRX(OperatorConstants.rightBackMotor);

leftPower = 0;
rightPower = 0;
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/frc/robot/subsystems/IntakeSubsystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package frc.robot.subsystems;
import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkLowLevel.MotorType;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;



import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.OperatorConstants;

public class IntakeSubsystem extends SubsystemBase{

// private final CANSparkMax intakeMotor;
private final WPI_TalonSRX dustpanMotor;
private double speed;



public IntakeSubsystem() {
dustpanMotor = new WPI_TalonSRX(OperatorConstants.dustpanMotor);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep these motor IDs as constants. Also use different values.

}

public void SetIntakeSpeed(double speed){
this.speed = speed;
}

@Override
public void periodic() {
dustpanMotor.set(speed);
}


}
74 changes: 74 additions & 0 deletions vendordeps/REVLib.json
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"
]
}
]
}