updated dt constants, auto intaking, pathplanner

This commit is contained in:
Tyler-J42 2024-03-12 04:16:08 -04:00
parent 1119ce0e74
commit 1754ee43a4
11 changed files with 130 additions and 68 deletions

View File

@ -34,6 +34,12 @@
"data": { "data": {
"pathName": "L Sub to Center" "pathName": "L Sub to Center"
} }
},
{
"type": "path",
"data": {
"pathName": "Note 1 to Speaker"
}
} }
] ]
} }

View File

@ -3,34 +3,58 @@
"waypoints": [ "waypoints": [
{ {
"anchor": { "anchor": {
"x": 1.2888463383764373, "x": 1.1251281761822782,
"y": 6.642279723305886 "y": 6.560420642208806
}, },
"prevControl": null, "prevControl": null,
"nextControl": { "nextControl": {
"x": 2.2888463383764366, "x": 1.569506044994996,
"y": 6.642279723305886 "y": 7.098351746561042
}, },
"isLocked": false, "isLocked": false,
"linkedName": null "linkedName": null
}, },
{ {
"anchor": { "anchor": {
"x": 3.159911049166827, "x": 2.4114851648506717,
"y": 6.864468657712245 "y": 7.016492665463964
}, },
"prevControl": { "prevControl": {
"x": 2.159911049166827, "x": 1.943718987153074,
"y": 6.864468657712245 "y": 7.004798511021525
}, },
"nextControl": null, "nextControl": null,
"isLocked": false, "isLocked": false,
"linkedName": null "linkedName": null
} }
], ],
"rotationTargets": [], "rotationTargets": [
{
"waypointRelativePos": 0.45,
"rotationDegrees": 179.22679798216734,
"rotateFast": true
}
],
"constraintZones": [], "constraintZones": [],
"eventMarkers": [], "eventMarkers": [
{
"name": "New Event Marker",
"waypointRelativePos": 0.1,
"command": {
"type": "parallel",
"data": {
"commands": [
{
"type": "named",
"data": {
"name": "Auto Intake"
}
}
]
}
}
}
],
"globalConstraints": { "globalConstraints": {
"maxVelocity": 3.0, "maxVelocity": 3.0,
"maxAcceleration": 3.0, "maxAcceleration": 3.0,
@ -39,13 +63,13 @@
}, },
"goalEndState": { "goalEndState": {
"velocity": 0, "velocity": 0,
"rotation": 0, "rotation": 180.0,
"rotateFast": false "rotateFast": false
}, },
"reversed": false, "reversed": false,
"folder": null, "folder": null,
"previewStartingState": { "previewStartingState": {
"rotation": 21.801409486351982, "rotation": -145.66978280449663,
"velocity": 0 "velocity": 0
}, },
"useDefaultConstraints": true "useDefaultConstraints": true

View File

@ -39,7 +39,7 @@
}, },
"goalEndState": { "goalEndState": {
"velocity": 0, "velocity": 0,
"rotation": 149.21037688376774, "rotation": -128.39665211123375,
"rotateFast": false "rotateFast": false
}, },
"reversed": false, "reversed": false,

View File

@ -0,0 +1,31 @@
package frc.robot.Commands;
import java.util.function.BooleanSupplier;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.constants.IntakeConstants;
import frc.robot.subsystems.Intake;
public class autoIntaking extends Command{
private Intake m_intake;
private BooleanSupplier m_beamBreak;
public autoIntaking(Intake intake, BooleanSupplier beamBreak){
m_intake = intake;
m_beamBreak = beamBreak;
addRequirements(intake);
}
@Override
public void execute(){
m_intake.intakeControl(() -> IntakeConstants.kDownAngle, () -> 1.0);
}
@Override
public boolean isFinished(){
if(!m_beamBreak.getAsBoolean()){
return true;
}else {return false;}
}
}

View File

@ -30,6 +30,7 @@ import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.Trigger; import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.Commands.autoIntaking;
import frc.robot.constants.IntakeConstants; import frc.robot.constants.IntakeConstants;
import frc.robot.constants.OIConstants; import frc.robot.constants.OIConstants;
import frc.robot.constants.PhotonConstants; import frc.robot.constants.PhotonConstants;
@ -102,6 +103,7 @@ public class RobotContainer {
NamedCommands.registerCommand("Charge Shooter 2 Sec", shooter.angleSpeedsSetpoints(() -> ShooterConstants.kShooterLoadAngle, 1.0, 1.0).withTimeout(2.0)); NamedCommands.registerCommand("Charge Shooter 2 Sec", shooter.angleSpeedsSetpoints(() -> ShooterConstants.kShooterLoadAngle, 1.0, 1.0).withTimeout(2.0));
NamedCommands.registerCommand("Speaker Note Shot", Commands.parallel(shooter.angleSpeedsSetpoints(() -> ShooterConstants.kShooterLoadAngle, 1.0, 1.0), indexer.shootNote(() -> 1.0)).withTimeout(2.0)); NamedCommands.registerCommand("Speaker Note Shot", Commands.parallel(shooter.angleSpeedsSetpoints(() -> ShooterConstants.kShooterLoadAngle, 1.0, 1.0), indexer.shootNote(() -> 1.0)).withTimeout(2.0));
NamedCommands.registerCommand("Auto Intake", new autoIntaking(intake, indexer::getBeamBreak).andThen(intake.intakeUpCommand()));
// An example Named Command, doesn't need to remain once we start actually adding real things // 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 // ALL Named Commands need to be defined AFTER subsystem initialization and BEFORE auto/controller configuration
@ -168,17 +170,23 @@ public class RobotContainer {
intake.setDefaultCommand( intake.setDefaultCommand(
intake.intakeControl( intake.intakeControl(
() -> { () -> {
if (intakeDown) { if (intakeDown && indexer.getBeamBreak()) {
return IntakeConstants.kDownAngle; return IntakeConstants.kDownAngle;
} else { } else {
return IntakeConstants.kUpAngle; return IntakeConstants.kUpAngle;
} }
}, },
operator::getRightY () -> {
if(intakeDown && indexer.getBeamBreak()){
return 1.0;
}else{
return 0.0;
}
}
) )
); );
operator.povUp().onTrue( driver.leftTrigger().onFalse(
new InstantCommand( new InstantCommand(
() -> { () -> {
intakeDown = false; intakeDown = false;
@ -186,7 +194,7 @@ public class RobotContainer {
) )
); );
operator.povDown().onTrue( driver.leftTrigger().onTrue(
new InstantCommand( new InstantCommand(
() -> { () -> {
intakeDown = true; intakeDown = true;

View File

@ -7,7 +7,7 @@ import edu.wpi.first.math.util.Units;
public final class DrivetrainConstants { public final class DrivetrainConstants {
// Driving Parameters - Note that these are not the maximum capable speeds of // Driving Parameters - Note that these are not the maximum capable speeds of
// the robot, rather the allowed maximum speeds // the robot, rather the allowed maximum speeds
public static final double kMaxSpeedMetersPerSecond = 4.1; public static final double kMaxSpeedMetersPerSecond = 5.2;
public static final double kMaxAngularSpeed = 2 * Math.PI; // radians per second public static final double kMaxAngularSpeed = 2 * Math.PI; // radians per second
public static final double kDirectionSlewRate = 4.8; // radians per second public static final double kDirectionSlewRate = 4.8; // radians per second

View File

@ -49,6 +49,6 @@ public class SwerveModuleConstants {
public static final IdleMode kDrivingMotorIdleMode = IdleMode.kBrake; public static final IdleMode kDrivingMotorIdleMode = IdleMode.kBrake;
public static final IdleMode kTurningMotorIdleMode = IdleMode.kBrake; public static final IdleMode kTurningMotorIdleMode = IdleMode.kBrake;
public static final int kDrivingMotorCurrentLimit = 65; // amps public static final int kDrivingMotorCurrentLimit = 70; // amps
public static final int kTurningMotorCurrentLimit = 30; // amps public static final int kTurningMotorCurrentLimit = 30; // amps
} }

View File

@ -1,6 +1,5 @@
package frc.robot.subsystems; package frc.robot.subsystems;
import java.util.function.BooleanSupplier;
import java.util.function.DoubleSupplier; import java.util.function.DoubleSupplier;
import com.revrobotics.CANSparkMax; import com.revrobotics.CANSparkMax;
@ -61,6 +60,29 @@ public class Intake extends SubsystemBase{
armOffset = getIntakeAngle()-IntakeConstants.kStartingAngle; armOffset = getIntakeAngle()-IntakeConstants.kStartingAngle;
} }
/*
public Command autoIntaking(BooleanSupplier beamBreak){
return run(() -> {
intakeRoller.set(1.0);
intakePivot.setVoltage(
intakeAnglePID.calculate(
getIntakeAngle(),
IntakeConstants.kDownAngle
) + intakeFeedForward.calculate(
IntakeConstants.kDownAngle,
0.0
)
);
return isFinished(() -> {
if(!beamBreak.getAsBoolean()){
return true
}
});
});
}
*/
public Command intakeControl(DoubleSupplier pivotAngle, DoubleSupplier intakeSpeed) { public Command intakeControl(DoubleSupplier pivotAngle, DoubleSupplier intakeSpeed) {
return run(() -> { return run(() -> {
intakeRoller.set(intakeSpeed.getAsDouble()); intakeRoller.set(intakeSpeed.getAsDouble());
@ -93,35 +115,6 @@ public class Intake extends SubsystemBase{
}); });
} }
public Command autoIntaking(BooleanSupplier beamBreak){
return run(() -> {
if(beamBreak.getAsBoolean()){
intakeRoller.set(1.0);
intakePivot.setVoltage(
intakeAnglePID.calculate(
getIntakeAngle(),
IntakeConstants.kUpAngle
) + intakeFeedForward.calculate(
IntakeConstants.kUpAngle,
0.0
)
);
}else{
intakeRoller.set(0);
intakePivot.setVoltage(
intakeAnglePID.calculate(
getIntakeAngle(),
IntakeConstants.kDownAngle
) + intakeFeedForward.calculate(
IntakeConstants.kDownAngle,
0.0
)
);
}
});
}
public Command manualPivot(DoubleSupplier pivotPower, DoubleSupplier rollerSpinny){ public Command manualPivot(DoubleSupplier pivotPower, DoubleSupplier rollerSpinny){
return run(() ->{ return run(() ->{
intakePivot.set(pivotPower.getAsDouble()); intakePivot.set(pivotPower.getAsDouble());

View File

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

View File

@ -1,7 +1,7 @@
{ {
"fileName": "Phoenix5.json", "fileName": "Phoenix5.json",
"name": "CTRE-Phoenix (v5)", "name": "CTRE-Phoenix (v5)",
"version": "5.33.0", "version": "5.33.1",
"frcYear": 2024, "frcYear": 2024,
"uuid": "ab676553-b602-441f-a38d-f1296eff6537", "uuid": "ab676553-b602-441f-a38d-f1296eff6537",
"mavenUrls": [ "mavenUrls": [
@ -20,19 +20,19 @@
{ {
"groupId": "com.ctre.phoenix", "groupId": "com.ctre.phoenix",
"artifactId": "api-java", "artifactId": "api-java",
"version": "5.33.0" "version": "5.33.1"
}, },
{ {
"groupId": "com.ctre.phoenix", "groupId": "com.ctre.phoenix",
"artifactId": "wpiapi-java", "artifactId": "wpiapi-java",
"version": "5.33.0" "version": "5.33.1"
} }
], ],
"jniDependencies": [ "jniDependencies": [
{ {
"groupId": "com.ctre.phoenix", "groupId": "com.ctre.phoenix",
"artifactId": "cci", "artifactId": "cci",
"version": "5.33.0", "version": "5.33.1",
"isJar": false, "isJar": false,
"skipInvalidPlatforms": true, "skipInvalidPlatforms": true,
"validPlatforms": [ "validPlatforms": [
@ -45,7 +45,7 @@
{ {
"groupId": "com.ctre.phoenix.sim", "groupId": "com.ctre.phoenix.sim",
"artifactId": "cci-sim", "artifactId": "cci-sim",
"version": "5.33.0", "version": "5.33.1",
"isJar": false, "isJar": false,
"skipInvalidPlatforms": true, "skipInvalidPlatforms": true,
"validPlatforms": [ "validPlatforms": [
@ -60,7 +60,7 @@
{ {
"groupId": "com.ctre.phoenix", "groupId": "com.ctre.phoenix",
"artifactId": "wpiapi-cpp", "artifactId": "wpiapi-cpp",
"version": "5.33.0", "version": "5.33.1",
"libName": "CTRE_Phoenix_WPI", "libName": "CTRE_Phoenix_WPI",
"headerClassifier": "headers", "headerClassifier": "headers",
"sharedLibrary": true, "sharedLibrary": true,
@ -75,7 +75,7 @@
{ {
"groupId": "com.ctre.phoenix", "groupId": "com.ctre.phoenix",
"artifactId": "api-cpp", "artifactId": "api-cpp",
"version": "5.33.0", "version": "5.33.1",
"libName": "CTRE_Phoenix", "libName": "CTRE_Phoenix",
"headerClassifier": "headers", "headerClassifier": "headers",
"sharedLibrary": true, "sharedLibrary": true,
@ -90,7 +90,7 @@
{ {
"groupId": "com.ctre.phoenix", "groupId": "com.ctre.phoenix",
"artifactId": "cci", "artifactId": "cci",
"version": "5.33.0", "version": "5.33.1",
"libName": "CTRE_PhoenixCCI", "libName": "CTRE_PhoenixCCI",
"headerClassifier": "headers", "headerClassifier": "headers",
"sharedLibrary": true, "sharedLibrary": true,
@ -105,7 +105,7 @@
{ {
"groupId": "com.ctre.phoenix.sim", "groupId": "com.ctre.phoenix.sim",
"artifactId": "wpiapi-cpp-sim", "artifactId": "wpiapi-cpp-sim",
"version": "5.33.0", "version": "5.33.1",
"libName": "CTRE_Phoenix_WPISim", "libName": "CTRE_Phoenix_WPISim",
"headerClassifier": "headers", "headerClassifier": "headers",
"sharedLibrary": true, "sharedLibrary": true,
@ -120,7 +120,7 @@
{ {
"groupId": "com.ctre.phoenix.sim", "groupId": "com.ctre.phoenix.sim",
"artifactId": "api-cpp-sim", "artifactId": "api-cpp-sim",
"version": "5.33.0", "version": "5.33.1",
"libName": "CTRE_PhoenixSim", "libName": "CTRE_PhoenixSim",
"headerClassifier": "headers", "headerClassifier": "headers",
"sharedLibrary": true, "sharedLibrary": true,
@ -135,7 +135,7 @@
{ {
"groupId": "com.ctre.phoenix.sim", "groupId": "com.ctre.phoenix.sim",
"artifactId": "cci-sim", "artifactId": "cci-sim",
"version": "5.33.0", "version": "5.33.1",
"libName": "CTRE_PhoenixCCISim", "libName": "CTRE_PhoenixCCISim",
"headerClassifier": "headers", "headerClassifier": "headers",
"sharedLibrary": true, "sharedLibrary": true,

View File

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