Named Commands and calculated feedforwards

This commit is contained in:
Tyler-J42 2024-02-27 10:47:44 -05:00
parent 3fec792691
commit cd28d8211f
15 changed files with 120 additions and 23 deletions

View File

@ -20,7 +20,7 @@
{
"type": "path",
"data": {
"pathName": "Preloaded+Pickup"
"pathName": "Left Preloaded+Pickup"
}
},
{

View File

@ -14,7 +14,7 @@
{
"type": "path",
"data": {
"pathName": "Preloaded+Pickup"
"pathName": "Left Preloaded+Pickup"
}
},
{

View File

@ -14,7 +14,7 @@
{
"type": "path",
"data": {
"pathName": "Preloaded+Pickup"
"pathName": "Left Preloaded+Pickup"
}
},
{

View File

@ -0,0 +1,43 @@
{
"version": 1.0,
"startingPose": {
"position": {
"x": 1.0578032584636603,
"y": 4.485794114445372
},
"rotation": 141.84277341263092
},
"command": {
"type": "sequential",
"data": {
"commands": [
{
"type": "named",
"data": {
"name": "Charge Shooter"
}
},
{
"type": "wait",
"data": {
"waitTime": 2.0
}
},
{
"type": "named",
"data": {
"name": "Speaker Note Shot"
}
},
{
"type": "path",
"data": {
"pathName": "Right Subwoofer to Center"
}
}
]
}
},
"folder": null,
"choreoAuto": false
}

View File

@ -0,0 +1,52 @@
{
"version": 1.0,
"waypoints": [
{
"anchor": {
"x": 1.0578032584636603,
"y": 4.485794114445372
},
"prevControl": null,
"nextControl": {
"x": 1.5708842846257125,
"y": 2.6240429623716395
},
"isLocked": false,
"linkedName": null
},
{
"anchor": {
"x": 7.0095431619434665,
"y": 0.8355890997496291
},
"prevControl": {
"x": 6.0095431619434665,
"y": 0.8355890997496291
},
"nextControl": null,
"isLocked": false,
"linkedName": null
}
],
"rotationTargets": [],
"constraintZones": [],
"eventMarkers": [],
"globalConstraints": {
"maxVelocity": 3.0,
"maxAcceleration": 3.0,
"maxAngularVelocity": 540.0,
"maxAngularAcceleration": 720.0
},
"goalEndState": {
"velocity": 0,
"rotation": 0,
"rotateFast": false
},
"reversed": false,
"folder": null,
"previewStartingState": {
"rotation": 144.68878656036674,
"velocity": 0
},
"useDefaultConstraints": true
}

View File

@ -7,7 +7,7 @@ import frc.robot.subsystems.Shooter;
public class AmpHandoff extends ParallelCommandGroup{
AmpHandoff(Indexer indexer, Shooter shooter){
addCommands(indexer.shootNote(null), shooter.ampHandoff());
addCommands(indexer.shootNote(1), shooter.ampHandoff());
}
}

View File

@ -8,6 +8,6 @@ import frc.robot.subsystems.Shooter;
public class SpeakerShot extends ParallelCommandGroup{
SpeakerShot(Indexer indexer, Shooter shooter){
addCommands(shooter.angleSpeedsSetpoints(ShooterConstants.kShooterLoadAngle, 0, 0), indexer.shootNote(() -> 1.0));
addCommands(shooter.angleSpeedsSetpoints(ShooterConstants.kShooterLoadAngle, 0, 0), indexer.shootNote( 1.0));
}
}

View File

@ -21,6 +21,7 @@ import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.Trigger;
@ -87,7 +88,8 @@ public class RobotContainer {
climber = new Climber(shooter.getShooterAngle());
NamedCommands.registerCommand("Charge Shooter", shooter.angleSpeedsSetpoints(ShooterConstants.kShooterLoadAngle, 1.0, 1.0));
NamedCommands.registerCommand("Speake Note Shot", Commands.parallel(shooter.angleSpeedsSetpoints(ShooterConstants.kShooterLoadAngle, 1.0, 1.0), indexer.shootNote(1.0)));
// An example Named Command, doesn't need to remain once we start actually adding real things
// ALL Named Commands need to be defined AFTER subsystem initialization and BEFORE auto/controller configuration
@ -143,7 +145,7 @@ public class RobotContainer {
climber.setDefaultCommand(climber.stop());
indexer.setDefaultCommand(indexer.shootNote(operator::getRightTriggerAxis));
indexer.setDefaultCommand(indexer.shootNote(operator.getRightTriggerAxis()));
driver.povCenter().onFalse(
drivetrain.driveCardinal(
@ -210,7 +212,7 @@ public class RobotContainer {
driver.leftBumper().toggleOnTrue(intake.intakeDownCommand());
operator.y().onTrue(climber.setSpeedWithSupplier(operator::getRightTriggerAxis));
operator.y().whileTrue(Commands.parallel(climber.setSpeedWithSupplier(operator::getRightTriggerAxis), shooter.climbState()));
}

View File

@ -47,5 +47,5 @@ public final class DrivetrainConstants {
public static final boolean kGyroReversed = true;
public static final double kRobotStartOffset = 90;
public static final double kRobotStartOffset = 0;
}

View File

@ -13,8 +13,8 @@ public class IntakeConstants {
public static final double kDIntake = 0;
public static final double kSFeedForward = 0;
public static final double kGFeedForward = 0;
public static final double kVFeedForward = 0;
public static final double kGFeedForward = 1.11;
public static final double kVFeedForward = 0.73;
public static final double kStartingAngle = Math.toRadians(105.0);
public static final double kUpAngle = Math.toRadians(90.0);

View File

@ -22,8 +22,8 @@ public class ShooterConstants {
public static final double kPivotConversion = 1/(40.0*(28.0/15.0));
public static final double kSShooterPivotFF = 0.0;
public static final double kGShooterPivotFF = 0.0;
public static final double kVShooterPivotFF = 0.0;
public static final double kGShooterPivotFF = 0.33;
public static final double kVShooterPivotFF = 1.44;
public static final double kMaxPivotSpeed = 0.0;
public static final double kMaxPivotAcceleration = 0.0;

View File

@ -49,9 +49,9 @@ public class Indexer extends SubsystemBase{
});
}
public Command shootNote(DoubleSupplier indexerSpeed){
public Command shootNote(double indexerSpeed){
return run(() -> {
indexerMotor.set(indexerSpeed.getAsDouble());
indexerMotor.set(indexerSpeed);
});
}

View File

@ -1,7 +1,7 @@
{
"fileName": "PathplannerLib.json",
"name": "PathplannerLib",
"version": "2024.2.3",
"version": "2024.2.4",
"uuid": "1b42324f-17c6-4875-8e77-1c312bc8c786",
"frcYear": "2024",
"mavenUrls": [
@ -12,7 +12,7 @@
{
"groupId": "com.pathplanner.lib",
"artifactId": "PathplannerLib-java",
"version": "2024.2.3"
"version": "2024.2.4"
}
],
"jniDependencies": [],
@ -20,7 +20,7 @@
{
"groupId": "com.pathplanner.lib",
"artifactId": "PathplannerLib-cpp",
"version": "2024.2.3",
"version": "2024.2.4",
"libName": "PathplannerLib",
"headerClassifier": "headers",
"sharedLibrary": false,

View File

@ -1,7 +1,7 @@
{
"fileName": "REVLib.json",
"name": "REVLib",
"version": "2024.2.1",
"version": "2024.2.2",
"frcYear": "2024",
"uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb",
"mavenUrls": [
@ -12,14 +12,14 @@
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-java",
"version": "2024.2.1"
"version": "2024.2.2"
}
],
"jniDependencies": [
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-driver",
"version": "2024.2.1",
"version": "2024.2.2",
"skipInvalidPlatforms": true,
"isJar": false,
"validPlatforms": [
@ -37,7 +37,7 @@
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-cpp",
"version": "2024.2.1",
"version": "2024.2.2",
"libName": "REVLib",
"headerClassifier": "headers",
"sharedLibrary": false,
@ -55,7 +55,7 @@
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-driver",
"version": "2024.2.1",
"version": "2024.2.2",
"libName": "REVLibDriver",
"headerClassifier": "headers",
"sharedLibrary": false,