Files
RiseOfRidgebotics2020/src/main/java/frc4388/robot/commands/ShooterVelocityControlPID.java
T

59 lines
1.8 KiB
Java
Raw Normal View History

2020-01-20 08:59:20 -08:00
/*----------------------------------------------------------------------------*/
/* 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;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc4388.robot.subsystems.Shooter;
public class ShooterVelocityControlPID extends CommandBase {
Shooter m_shooter;
double m_targetVel;
2020-02-22 13:01:50 -07:00
double m_actualVel;
2020-01-20 08:59:20 -08:00
/**
* Creates a new ShooterVelocityControlPID.
2020-02-22 13:16:27 -07:00
* @param subsystem The Shooter subsytem
* @param targetVel The target velocity
2020-01-20 08:59:20 -08:00
*/
2020-02-25 17:44:59 -07:00
public ShooterVelocityControlPID(Shooter subsystem) {
2020-01-20 08:59:20 -08:00
m_shooter = subsystem;
addRequirements(m_shooter);
}
// Called when the command is initially scheduled.
@Override
public void initialize() {
2020-02-25 17:44:59 -07:00
2020-01-20 08:59:20 -08:00
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
2020-02-26 17:31:57 -07:00
m_shooter.runDrumShooterVelocityPID(m_shooter.addFireVel(), m_shooter.m_shooterFalcon.getSelectedSensorVelocity());
2020-02-22 15:03:10 -07:00
m_shooter.runAngleAdjustPID(m_shooter.addFireAngle());
2020-01-20 08:59:20 -08:00
}
// 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() {
2020-02-22 13:01:50 -07:00
//Tells wether the target velocity has been reached
double upperBound = m_targetVel + 300;
double lowerBound = m_targetVel - 300;
if (m_actualVel < upperBound && m_actualVel > lowerBound){
return true;
}
else{
return false;
}
2020-01-20 08:59:20 -08:00
}
}