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

Autonupdate #30

Closed
wants to merge 18 commits into from
Closed
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 src/main/deploy/pathplanner/autos/2-Center-Stays.auto
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{
"type": "wait",
"data": {
"waitTime": 2.0
"waitTime": 1.0
}
},
{
Expand Down
12 changes: 12 additions & 0 deletions src/main/deploy/pathplanner/autos/2-Right-Leave.auto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
"type": "deadline",
"data": {
"commands": [
{
"type": "wait",
"data": {
"waitTime": 1.0
}
},
{
"type": "path",
"data": {
Expand All @@ -42,6 +48,12 @@
"name": "Shoot"
}
},
{
"type": "wait",
"data": {
"waitTime": 1.0
}
},
{
"type": "path",
"data": {
Expand Down
101 changes: 101 additions & 0 deletions src/main/deploy/pathplanner/autos/3-Center-Stays-copy.auto
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"version": 1.0,
"startingPose": {
"position": {
"x": 1.3470318873095533,
"y": 5.5216374597852385
},
"rotation": 0
},
"command": {
"type": "sequential",
"data": {
"commands": [
{
"type": "named",
"data": {
"name": "Shoot"
}
},
{
"type": "deadline",
"data": {
"commands": [
{
"type": "sequential",
"data": {
"commands": [
{
"type": "path",
"data": {
"pathName": "CenterNote-Center"
}
}
]
}
},
{
"type": "named",
"data": {
"name": "Intake"
}
}
]
}
},
{
"type": "named",
"data": {
"name": "Intake in"
}
},
{
"type": "named",
"data": {
"name": "Shoot"
}
},
{
"type": "deadline",
"data": {
"commands": [
{
"type": "sequential",
"data": {
"commands": [
{
"type": "path",
"data": {
"pathName": "LeftNote-Center"
}
}
]
}
},
{
"type": "named",
"data": {
"name": "Intake"
}
}
]
}
},
{
"type": "named",
"data": {
"name": "Intake in"
}
},
{
"type": "named",
"data": {
"name": "Shoot"
}
}
]
}
},
"folder": null,
"choreoAuto": false
}
24 changes: 21 additions & 3 deletions src/main/deploy/pathplanner/autos/4-Center-Stays.auto
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{
"type": "wait",
"data": {
"waitTime": 2.0
"waitTime": 1.0
}
},
{
Expand All @@ -49,6 +49,12 @@
]
}
},
{
"type": "named",
"data": {
"name": "Intake in"
}
},
{
"type": "named",
"data": {
Expand All @@ -66,7 +72,7 @@
{
"type": "wait",
"data": {
"waitTime": 2.0
"waitTime": 1.0
}
},
{
Expand All @@ -87,6 +93,12 @@
]
}
},
{
"type": "named",
"data": {
"name": "Intake in"
}
},
{
"type": "named",
"data": {
Expand All @@ -104,7 +116,7 @@
{
"type": "wait",
"data": {
"waitTime": 2.0
"waitTime": 1.0
}
},
{
Expand All @@ -125,6 +137,12 @@
]
}
},
{
"type": "named",
"data": {
"name": "Intake in"
}
},
{
"type": "named",
"data": {
Expand Down
4 changes: 2 additions & 2 deletions src/main/deploy/pathplanner/paths/CenterNote-Center.path
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"eventMarkers": [],
"globalConstraints": {
"maxVelocity": 3.0,
"maxAcceleration": 3.0,
"maxAcceleration": 3.25,
"maxAngularVelocity": 540.0,
"maxAngularAcceleration": 720.0
},
Expand All @@ -64,5 +64,5 @@
"rotation": 0,
"velocity": 0
},
"useDefaultConstraints": true
"useDefaultConstraints": false
}
4 changes: 2 additions & 2 deletions src/main/deploy/pathplanner/paths/LeftNote-Center.path
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"eventMarkers": [],
"globalConstraints": {
"maxVelocity": 3.0,
"maxAcceleration": 3.0,
"maxAcceleration": 3.25,
"maxAngularVelocity": 540.0,
"maxAngularAcceleration": 720.0
},
Expand All @@ -70,5 +70,5 @@
"rotation": 0,
"velocity": 0
},
"useDefaultConstraints": true
"useDefaultConstraints": false
}
8 changes: 6 additions & 2 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ public static final class ShooterConstants {
public static final int kBottomShooterMotorPort = 35;
public static final double kShooterSpeedTop = 0.8;
public static final double kShooterSpeedBottom = 0.9;
public static final double kPreShooterSpeed = 0.4;
public static final double kShooterOff = 0;

public static final double kShooterOffTime = 0.04;
public static final double kShooterOnTime = 1.9;
}

public static class ClimberConstants {
Expand All @@ -128,8 +132,8 @@ public static class ClimberConstants {
public final static int leftReverseChannel = 2;
public final static int rightReverseChannel = 3;

public final static double minPressure = 100.0;
public final static double maxPressure = 110.0;
public final static double minPressure = 95.0;
public final static double maxPressure = 105.0;
}

public static final class VisionConstants {
Expand Down
43 changes: 31 additions & 12 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.pathplanner.lib.util.ReplanningConfig;

import edu.wpi.first.math.MathUtil;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.XboxController.Button;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
Expand All @@ -25,6 +26,7 @@
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.Constants.DriveConstants;
import frc.robot.Constants.IOConstants;
import frc.robot.Constants.ShooterConstants;
import frc.robot.commands.IntakeArmPositionCommand;
import frc.robot.commands.NoteIntakeCommand;
import frc.robot.commands.NoteOuttakeCommand;
Expand Down Expand Up @@ -62,16 +64,19 @@ public class RobotContainer {
public RobotContainer() {
NamedCommands.registerCommand("Shoot",
new SequentialCommandGroup(
new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Shooting),
new ParallelDeadlineGroup(new WaitCommand(2), new NoteOuttakeCommand(m_intakeSubsystem)),
new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Off)));
new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Shooting, ShooterConstants.kShooterOnTime),
new ParallelDeadlineGroup(new WaitCommand(0.8), new NoteOuttakeCommand(m_intakeSubsystem)),
new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Off, ShooterConstants.kShooterOffTime)));

NamedCommands.registerCommand("Intake",
new SequentialCommandGroup(
new IntakeArmPositionCommand(m_intakeSubsystem, ArmPosition.Extended),
new NoteIntakeCommand(m_intakeSubsystem),
new IntakeArmPositionCommand(m_intakeSubsystem, ArmPosition.Retracted)));

NamedCommands.registerCommand("Pre-Speed - 30%",
new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Halfway, 0.01));

NamedCommands.registerCommand("Intake in",
new IntakeArmPositionCommand(m_intakeSubsystem, ArmPosition.Retracted));

Expand All @@ -87,7 +92,18 @@ public RobotContainer() {
// from robot center to
// furthest module.
new ReplanningConfig(false, false)),
() -> false, m_robotDrive);
() -> {
// Boolean supplier that controls when the path will be mirrored for the red
// alliance
// This will flip the path being followed to the red side of the field.
// THE ORIGIN WILL REMAIN ON THE BLUE SIDE

var alliance = DriverStation.getAlliance();
if (alliance.isPresent()) {
return alliance.get() == DriverStation.Alliance.Red;
}
return false;
}, m_robotDrive);

// new SequentialCommandGroup(new ShooterSetSpeedCommand(m_shooterSubsystem,
// ShootSpeed.Shooting),
Expand Down Expand Up @@ -147,9 +163,9 @@ private void configureBindings() {
// DriveConstants.kMaxAngularSpeedRadiansPerSecond - 1, 5)));

new JoystickButton(m_driverController, Button.kX.value)
.onTrue(new SequentialCommandGroup(new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Shooting),
.onTrue(new SequentialCommandGroup(new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Shooting, ShooterConstants.kShooterOnTime),
new NoteOuttakeCommand(m_intakeSubsystem)))
.onFalse(new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Off));
.onFalse(new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Off, ShooterConstants.kShooterOffTime));

new JoystickButton(m_driverController, Button.kRightBumper.value)
.onTrue(new IntakeArmPositionCommand(m_intakeSubsystem, ArmPosition.Amp))
Expand All @@ -172,8 +188,8 @@ private void configureBindings() {

new Trigger(() -> {
return m_operatorController.getLeftTriggerAxis() > 0.5;
}).onTrue(new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Shooting))
.onFalse(new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Off));
}).onTrue(new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Shooting, ShooterConstants.kShooterOnTime))
.onFalse(new ShooterSetSpeedCommand(m_shooterSubsystem, ShootSpeed.Off, ShooterConstants.kShooterOffTime));

// Climber Up, Operator Controller Right Bumper + A Button
new Trigger(() -> {
Expand Down Expand Up @@ -206,17 +222,20 @@ public void resetAllSubsystems() {
* @return the command to run in autonomous
*/
public Command getAutonomousCommand() {
// PathPlannerPath path = PathPlannerPath.fromPathFile("Center4Note");

/// List<PathPlannerPath> pathGroup =
/// PathPlannerAuto.getPathGroupFromAutoFile(autoChooser.getSelected().getName());
// PathPlannerAuto path = PathPlannerAuto.getPathGroupFromAutoFile(pathGroup);

// var alliance = DriverStation.getAlliance();
// PathPlannerPath autonPath = path;
// PathPlannerPath pathGroup = path;
// if (alliance.isPresent() && alliance.get() == DriverStation.Alliance.Red) {
// autonPath = autonPath.flipPath();
// }
// m_robotDrive.resetOdometry(autonPath.getPreviewStartingHolonomicPose());

// return AutoBuilder.followPath(autonPath);
// return null;
// return new PathPlannerAuto(autoChooser.getSelected().getName());
return autoChooser.getSelected();

}
}
8 changes: 6 additions & 2 deletions src/main/java/frc/robot/commands/ShooterSetSpeedCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ public class ShooterSetSpeedCommand extends Command {
ShooterSubsystem m_ShooterSubsystem;
double m_shooterSpeed = 0;


double set_time = 1.5;
Timer m_timer = new Timer();

ShootSpeed m_shootSpeed;

/** Creates a new ShootCommand. */
public ShooterSetSpeedCommand(ShooterSubsystem shooterSubsystem, ShootSpeed shootSpeed) {
public ShooterSetSpeedCommand(ShooterSubsystem shooterSubsystem, ShootSpeed shootSpeed, double time) {
m_ShooterSubsystem = shooterSubsystem;
addRequirements(m_ShooterSubsystem);

set_time = time;

m_shootSpeed = shootSpeed;
}

Expand All @@ -47,6 +51,6 @@ public void end(boolean interrupted) {
// Returns true when the command should end.
@Override
public boolean isFinished() {
return m_timer.get() > 1.5;
return m_timer.get() > set_time;
}
}
Loading
Loading