For some reason, I am unable to change the power to our ball shooter which uses a neo with a spark max, code is below.
Right now I have it set to 45, but changing it does not seem to change the rpm
public class Thrower extends Subsystem {
private CANSparkMax throwermotor;
private CANSparkMax feedmotor;
private CANSparkMax stackmotor;
private NetworkTable table;
private double a1;
private double a2;
private double h1;
private double h2;
private double d;
private double power;
private CANEncoder m_encoder;
public void thrown(){
throwermotor = new CANSparkMax(RobotMap.THROWER_MOTOR_ID, MotorType.kBrushless);
table = NetworkTableInstance.getDefault().getTable("limelight");
final NetworkTableEntry ty = table.getEntry("ty");
a1 = 12; // Angle of camera from the horizontal in degrees
a2 = ty.getDouble(0.0); // Angle of tower to camera found with limelight
h1 = 27; // Height of limelight to ground in inches
h2 = 82; // Height of tower's tape to ground in inches
d = 55 / Math.tan(Math.toRadians(a1+a2)); // Calculates the distance between camera and target
m_encoder = throwermotor.getEncoder();
// Set motor power for shooting the turret.
// Over time, the turret occasionally gets less accurate
// use the power nerf to adjust for that.
int power_nerf = 4;
int nerf_test = 20;
//power = 4.06 + 0.346*d + -0.000475*(d*d) - power_nerf;
// power = 25.9*Math.pow(Math.E, 0.00368*d);
power = 45;
throwermotor.set(-(int)power);
//System.out.println(-(int)power);
SmartDashboard.putNumber("Ball Shooter Speed (RPM)", -m_encoder.getVelocity());
SmartDashboard.putNumber("Distance to Tower", d);
SmartDashboard.putNumber("Power", power);
}
}