mirror of
https://github.com/Team4388/RiseOfRidgebotics2020.git
synced 2026-06-09 08:48:01 -06:00
Add ShooterHood Subsystem
This commit is contained in:
@@ -13,19 +13,23 @@ import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc4388.robot.Constants.ShooterConstants;
|
||||
import frc4388.robot.subsystems.Shooter;
|
||||
import frc4388.robot.subsystems.ShooterAim;
|
||||
import frc4388.robot.subsystems.ShooterHood;
|
||||
|
||||
public class CalibrateShooter extends CommandBase {
|
||||
Shooter m_shooter;
|
||||
ShooterAim m_shooterAim;
|
||||
ShooterHood m_shooterHood;
|
||||
|
||||
/**
|
||||
* Calibrates the turret by moving the hood all the way down and moving the turret all the way right, then reseting the encoders
|
||||
* @param shootSub The Shooter subsystem
|
||||
* @param aimSub The ShooterAim subsystem
|
||||
*/
|
||||
public CalibrateShooter(Shooter shootSub, ShooterAim aimSub) {
|
||||
public CalibrateShooter(Shooter shootSub, ShooterAim aimSub, ShooterHood hoodSub) {
|
||||
m_shooter = shootSub;
|
||||
m_shooterAim = aimSub;
|
||||
addRequirements(m_shooter, m_shooterAim);
|
||||
m_shooterHood = hoodSub;
|
||||
addRequirements(m_shooter, m_shooterHood, m_shooterAim);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@@ -36,10 +40,10 @@ public class CalibrateShooter extends CommandBase {
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
m_shooter.m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kForward, false);
|
||||
m_shooter.m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kReverse, false);
|
||||
m_shooter.m_angleEncoder.setPosition(0);
|
||||
m_shooter.m_angleAdjustMotor.set(-ShooterConstants.HOOD_CALIBRATE_SPEED);
|
||||
m_shooterHood.m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kForward, false);
|
||||
m_shooterHood.m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kReverse, false);
|
||||
m_shooterHood.m_angleEncoder.setPosition(0);
|
||||
m_shooterHood.m_angleAdjustMotor.set(-ShooterConstants.HOOD_CALIBRATE_SPEED);
|
||||
|
||||
m_shooterAim.m_shooterRotateMotor.enableSoftLimit(SoftLimitDirection.kForward, false);
|
||||
m_shooterAim.m_shooterRotateMotor.enableSoftLimit(SoftLimitDirection.kReverse, false);
|
||||
@@ -50,8 +54,8 @@ public class CalibrateShooter extends CommandBase {
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
m_shooter.m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kForward, true);
|
||||
m_shooter.m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kReverse, true);
|
||||
m_shooterHood.m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kForward, true);
|
||||
m_shooterHood.m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kReverse, true);
|
||||
|
||||
m_shooterAim.m_shooterRotateMotor.enableSoftLimit(SoftLimitDirection.kForward, true);
|
||||
m_shooterAim.m_shooterRotateMotor.enableSoftLimit(SoftLimitDirection.kReverse, true);
|
||||
|
||||
@@ -14,15 +14,17 @@ import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc4388.robot.Constants.VisionConstants;
|
||||
import frc4388.robot.subsystems.Shooter;
|
||||
import frc4388.robot.subsystems.ShooterAim;
|
||||
import frc4388.robot.subsystems.ShooterHood;
|
||||
import frc4388.utility.controller.IHandController;
|
||||
|
||||
public class HoldTarget extends CommandBase {
|
||||
//Setup
|
||||
// Setup
|
||||
NetworkTableEntry xEntry;
|
||||
ShooterAim m_shooterAim;
|
||||
Shooter m_shooter;
|
||||
ShooterHood m_shooterHood;
|
||||
IHandController m_driverController;
|
||||
//Aiming
|
||||
// Aiming
|
||||
double turnAmount = 0;
|
||||
double xAngle = 0;
|
||||
double yAngle = 0;
|
||||
@@ -42,6 +44,7 @@ public class HoldTarget extends CommandBase {
|
||||
public HoldTarget(Shooter shooterSubsystem, ShooterAim aimSubsystem) {
|
||||
m_shooterAim = aimSubsystem;
|
||||
m_shooter = shooterSubsystem;
|
||||
m_shooterHood = m_shooter.m_shooterHoodSubsystem;
|
||||
addRequirements(m_shooterAim);
|
||||
NetworkTableInstance.getDefault().getTable("limelight").getEntry("camMode").setNumber(1);
|
||||
}
|
||||
@@ -99,7 +102,7 @@ public class HoldTarget extends CommandBase {
|
||||
|
||||
|
||||
m_shooter.m_fireVel = fireVel;
|
||||
m_shooter.m_fireAngle = fireAngle;// + m_shooter.shooterTrims.m_hoodTrim;
|
||||
m_shooterHood.m_fireAngle = fireAngle;// + m_shooter.shooterTrims.m_hoodTrim;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,16 +10,17 @@ package frc4388.robot.commands.shooter;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc4388.robot.subsystems.Shooter;
|
||||
import frc4388.robot.subsystems.ShooterHood;
|
||||
|
||||
public class HoodPositionPID extends CommandBase {
|
||||
Shooter m_shooter;
|
||||
double firingAngle;
|
||||
private ShooterHood m_shooterHood;
|
||||
/**
|
||||
* Creates a new HoodPositionPID.
|
||||
*/
|
||||
public HoodPositionPID(Shooter subSystem) {
|
||||
m_shooter = subSystem;
|
||||
//addRequirements(m_shooter);
|
||||
public HoodPositionPID(ShooterHood subSystem) {
|
||||
m_shooterHood = subSystem;
|
||||
addRequirements(m_shooterHood);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@@ -35,7 +36,7 @@ public class HoodPositionPID extends CommandBase {
|
||||
firingAngle = (-slope*m_shooter.addFireAngle())+b;*/
|
||||
//SmartDashboard.putNumber("Shoot Angle From Equation", m_shooter.addFireAngle());
|
||||
//SmartDashboard.putNumber("Fire Angle", firingAngle);
|
||||
m_shooter.runAngleAdjustPID(firingAngle);
|
||||
m_shooterHood.runAngleAdjustPID(firingAngle);
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@@ -46,7 +47,7 @@ public class HoodPositionPID extends CommandBase {
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
double encoderPos = m_shooter.m_angleAdjustMotor.getEncoder().getPosition();
|
||||
double encoderPos = m_shooterHood.m_angleAdjustMotor.getEncoder().getPosition();
|
||||
if(encoderPos < firingAngle + 1 || encoderPos < firingAngle - 1){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||
import frc4388.robot.commands.storage.StorageRun;
|
||||
import frc4388.robot.subsystems.Shooter;
|
||||
import frc4388.robot.subsystems.ShooterAim;
|
||||
import frc4388.robot.subsystems.ShooterHood;
|
||||
import frc4388.robot.subsystems.Storage;
|
||||
|
||||
// NOTE: Consider using this command inline, rather than writing a subclass. For more
|
||||
@@ -25,9 +26,11 @@ public class ShootFireGroup extends ParallelRaceGroup {
|
||||
* @param m_storage The Storage subsytem
|
||||
*/
|
||||
public ShootFireGroup(Shooter m_shooter, ShooterAim m_shooterAim, Storage m_storage) {
|
||||
ShooterHood m_shooterHood = m_shooter.m_shooterHoodSubsystem;
|
||||
|
||||
addCommands(
|
||||
new RunCommand(() -> m_shooter.runDrumShooterVelocityPID(m_shooter.addFireVel())),
|
||||
new RunCommand(() -> m_shooter.runAngleAdjustPID(m_shooter.addFireAngle())),
|
||||
new RunCommand(() -> m_shooterHood.runAngleAdjustPID(m_shooterHood.addFireAngle())),
|
||||
new HoldTarget(m_shooter, m_shooterAim),
|
||||
new StorageRun(m_storage)
|
||||
);
|
||||
|
||||
@@ -11,18 +11,22 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc4388.robot.Constants.ShooterConstants;
|
||||
import frc4388.robot.subsystems.Shooter;
|
||||
import frc4388.robot.subsystems.ShooterHood;
|
||||
|
||||
public class ShooterVelocityControlPID extends CommandBase {
|
||||
Shooter m_shooter;
|
||||
double m_targetVel;
|
||||
double m_actualVel;
|
||||
private ShooterHood m_shooterHood;
|
||||
|
||||
/**
|
||||
* Runs the drum at a velocity
|
||||
* @param subsystem The Shooter subsytem
|
||||
*/
|
||||
public ShooterVelocityControlPID(Shooter subsystem) {
|
||||
public ShooterVelocityControlPID(Shooter subsystem, ShooterHood subHood) {
|
||||
m_shooter = subsystem;
|
||||
addRequirements(m_shooter);
|
||||
m_shooterHood = subHood;
|
||||
addRequirements(m_shooter, m_shooterHood);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@@ -35,7 +39,7 @@ public class ShooterVelocityControlPID extends CommandBase {
|
||||
@Override
|
||||
public void execute() {
|
||||
m_shooter.runDrumShooterVelocityPID(/*m_shooter.addFireVel()*/13000);
|
||||
m_shooter.runAngleAdjustPID(m_shooter.addFireAngle());
|
||||
m_shooterHood.runAngleAdjustPID(m_shooterHood.addFireAngle());
|
||||
//SmartDashboard.putNumber("Fire Velocity", m_shooter.addFireVel());
|
||||
//SmartDashboard.putNumber("Fire Angle", m_shooter.addFireAngle());
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import frc4388.robot.Constants.VisionConstants;
|
||||
import frc4388.robot.subsystems.Shooter;
|
||||
import frc4388.robot.subsystems.ShooterAim;
|
||||
import frc4388.robot.subsystems.ShooterHood;
|
||||
import frc4388.utility.controller.IHandController;
|
||||
|
||||
public class TrackTarget extends CommandBase {
|
||||
@@ -33,6 +34,7 @@ public class TrackTarget extends CommandBase {
|
||||
|
||||
public double m_hoodTrim;
|
||||
public double m_turretTrim;
|
||||
private ShooterHood m_shooterHood;
|
||||
|
||||
/**
|
||||
* Uses the Limelight to track the target
|
||||
@@ -42,6 +44,7 @@ public class TrackTarget extends CommandBase {
|
||||
public TrackTarget(Shooter shooterSubsystem, ShooterAim aimSubsystem) {
|
||||
m_shooterAim = aimSubsystem;
|
||||
m_shooter = shooterSubsystem;
|
||||
m_shooterHood = m_shooter.m_shooterHoodSubsystem;
|
||||
addRequirements(m_shooterAim);
|
||||
NetworkTableInstance.getDefault().getTable("limelight").getEntry("camMode").setNumber(1);
|
||||
}
|
||||
@@ -97,7 +100,7 @@ public class TrackTarget extends CommandBase {
|
||||
|
||||
|
||||
m_shooter.m_fireVel = fireVel;
|
||||
m_shooter.m_fireAngle = fireAngle;// + m_shooter.shooterTrims.m_hoodTrim;
|
||||
m_shooterHood.m_fireAngle = fireAngle;// + m_shooter.shooterTrims.m_hoodTrim;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user