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

Robot shooter #39

Merged
merged 9 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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"
id "com.diffplug.spotless" version "6.24.0"
}

Expand Down
83 changes: 83 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
{
"HALProvider": {
"Timing": {
"window": {
"visible": false
}
}
},
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo",
"/SmartDashboard/VisionSystemSim-/Sim Field": "Field2d"
}
},
"NetworkTables": {
"Retained Values": {
"open": false
},
"transitory": {
"AdvantageKit": {
"DriverStation": {
"Joystick0": {
"open": true
},
"Joystick1": {
"open": true
},
"Joystick5": {
"open": true
},
"open": true
},
"open": true
},
"CameraPublisher": {
"open": true
},
Expand All @@ -19,6 +44,64 @@
}
},
"NetworkTables Info": {
"Server": {
"Publishers": {
"open": true
},
"Subscribers": {
"open": true
}
},
"visible": true
},
"NetworkTables View": {
"visible": false
},
"Plot": {
"Plot <0>": {
"plots": [
{
"backgroundColor": [
0.0,
0.0,
0.0,
0.8500000238418579
],
"height": 151,
"series": [
{
"color": [
0.2980392277240753,
0.44705885648727417,
0.6901960968971252,
1.0
],
"id": "NT:/AdvantageKit/DriverStation/Joystick0/ButtonCount"
},
{
"color": [
0.8666667342185974,
0.5176470875740051,
0.32156863808631897,
1.0
],
"id": "NT:/AdvantageKit/Timestamp"
}
]
},
{
"backgroundColor": [
0.0,
0.0,
0.0,
0.8500000238418579
],
"height": 151
}
],
"window": {
"visible": false
}
}
}
}
18 changes: 18 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,10 @@

package frc.robot;

import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Transform2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import org.littletonrobotics.junction.LogFileUtil;
Expand All @@ -24,6 +28,11 @@ public class Robot extends LoggedRobot {

private RobotContainer robotContainer;

Pose2d pose2d = new Pose2d(0.0, 0.0, new Rotation2d(0.0, 0.0));
Transform2d transform2d =
new Transform2d(new Translation2d(0.02, 0.0), new Rotation2d(0.0, 0.0));
int count = 0;

jkleiber marked this conversation as resolved.
Show resolved Hide resolved
/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
Expand Down Expand Up @@ -52,6 +61,8 @@ public void robotInit() {
}

Logger.start();
Logger.recordOutput("randomTesting", new Pose2d(0.0, 0.0, new Rotation2d(0.0, 0.0)));
jkleiber marked this conversation as resolved.
Show resolved Hide resolved

robotContainer = new RobotContainer();
}

Expand All @@ -68,7 +79,14 @@ public void robotPeriodic() {
// commands, running already-scheduled commands, removing finished or interrupted commands,
// and running subsystem periodic() methods. This must be called from the robot's periodic
// block in order for anything in the Command-based framework to work.

CommandScheduler.getInstance().run();
Logger.recordOutput("randomCount", pose2d);
Transform2d modifier = transform2d.times(Math.sin(count / 100.0));
pose2d = pose2d.transformBy(modifier);
Logger.recordOutput("joystickExpected", Math.sin(count / 100.0));

count++;
jkleiber marked this conversation as resolved.
Show resolved Hide resolved
}

/** This function is called once each time the robot enters Disabled mode. */
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.Constants.OperatorConstants;
import frc.robot.subsystems.shooter_intake.ShooterIntakeIO;
import frc.robot.subsystems.shooter_intake.ShooterIntakeSubsystem;
import java.util.function.DoubleSupplier;
import java.util.function.Supplier;

Expand All @@ -19,6 +21,17 @@ public class RobotContainer {
private DoubleSupplier rightDistanceSupplier;
private Supplier<Rotation2d> gyroSupplier;
private Supplier<Pose2d> simulatedPoseSupplier;
private ShooterIntakeSubsystem intakeSubsystem =
new ShooterIntakeSubsystem(
new ShooterIntakeIO() {

@Override
public void setVoltage(double volts) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException(
"Unimplemented method 'setVoltage'");
}
});
jkleiber marked this conversation as resolved.
Show resolved Hide resolved

private final CommandXboxController driverController =
new CommandXboxController(OperatorConstants.kDriverControllerPort);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package frc.robot.subsystems.shooter_intake;

public interface ShooterIntakeIO {

public static class ShooterIntakeIOInputs {
public double intakeVoltage = 0.0;
}

public void setVoltage(double volts);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package frc.robot.subsystems.shooter_intake;

public class ShooterIntakeSubsystem {

protected State currentState = State.IDLE;
protected State targetState = State.IDLE;
ShooterIntakeIO io;

public ShooterIntakeSubsystem(ShooterIntakeIO io) {
this.io = io;
State.subsystem = this;
}

public void periodic() {

currentState.periodic();
}

public void setTargetState(State target) {
this.targetState = target;
}

// spotless:off
public enum State {
jkleiber marked this conversation as resolved.
Show resolved Hide resolved
IDLE {

@Override
void changeStates() {
this.changeState(subsystem.targetState);
}

@Override
void onStart() {
subsystem.io.setVoltage(0);
}
},

INTAKING {
@Override
void periodic() {
super.periodic();
subsystem.io.setVoltage(-1);
}
},

SHOOTING {
@Override
void periodic() {
super.periodic();
subsystem.io.setVoltage(1);
}
};

static ShooterIntakeSubsystem subsystem;

void periodic() {
this.changeStates();
}

void changeStates() {
if (this != subsystem.targetState) {
this.changeState(IDLE);
}
}

void onStart() {};

void onEnd() {};

protected void changeState(State newState){
this.onEnd();
subsystem.currentState = newState;
newState.onStart();
}
}
// spotless:on

}
10 changes: 5 additions & 5 deletions vendordeps/AdvantageKit.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fileName": "AdvantageKit.json",
"name": "AdvantageKit",
"version": "3.0.0",
"version": "3.2.1",
"uuid": "d820cc26-74e3-11ec-90d6-0242ac120003",
"frcYear": "2024",
"mavenUrls": [],
Expand All @@ -10,24 +10,24 @@
{
"groupId": "org.littletonrobotics.akit.junction",
"artifactId": "wpilib-shim",
"version": "3.0.0"
"version": "3.2.1"
},
{
"groupId": "org.littletonrobotics.akit.junction",
"artifactId": "junction-core",
"version": "3.0.0"
"version": "3.2.1"
},
{
"groupId": "org.littletonrobotics.akit.conduit",
"artifactId": "conduit-api",
"version": "3.0.0"
"version": "3.2.1"
}
],
"jniDependencies": [
{
"groupId": "org.littletonrobotics.akit.conduit",
"artifactId": "conduit-wpilibio",
"version": "3.0.0",
"version": "3.2.1",
"skipInvalidPlatforms": false,
"isJar": false,
"validPlatforms": [
Expand Down
Loading