mirror of
https://github.com/Team4388/RiseOfRidgebotics2020.git
synced 2026-06-09 00:38:00 -06:00
3f11fbd979
& collect more data points
61 lines
1.8 KiB
Java
61 lines
1.8 KiB
Java
/*----------------------------------------------------------------------------*/
|
|
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
/* the project. */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
package frc4388.robot.commands.shooter;
|
|
|
|
import edu.wpi.first.wpilibj2.command.CommandBase;
|
|
import frc4388.robot.Constants.ShooterConstants;
|
|
import frc4388.robot.subsystems.Shooter;
|
|
|
|
public class ShooterVelocityControlPID extends CommandBase {
|
|
Shooter m_shooter;
|
|
double m_targetVel;
|
|
double m_actualVel;
|
|
|
|
/**
|
|
* Runs the drum at a velocity
|
|
* @param subsystem The Shooter subsytem
|
|
*/
|
|
public ShooterVelocityControlPID(Shooter subsystem) {
|
|
m_shooter = subsystem;
|
|
addRequirements(m_shooter);
|
|
}
|
|
|
|
// Called when the command is initially scheduled.
|
|
@Override
|
|
public void initialize() {
|
|
|
|
}
|
|
|
|
// Called every time the scheduler runs while the command is scheduled.
|
|
@Override
|
|
public void execute() {
|
|
m_shooter.runDrumShooterVelocityPID(m_shooter.addFireVel());
|
|
}
|
|
|
|
// Called once the command ends or is interrupted.
|
|
@Override
|
|
public void end(boolean interrupted) {
|
|
}
|
|
|
|
// Returns true when the command should end.
|
|
@Override
|
|
public boolean isFinished() {
|
|
//Tells whether the target velocity has been reached
|
|
double upperBound = m_targetVel + ShooterConstants.DRUM_VELOCITY_BOUND;
|
|
double lowerBound = m_targetVel - ShooterConstants.DRUM_VELOCITY_BOUND;
|
|
if (m_actualVel < upperBound && m_actualVel > lowerBound){
|
|
m_shooter.m_isDrumReady = true;
|
|
}
|
|
else{
|
|
m_shooter.m_isDrumReady = false;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|