This is our current code:
package org.usfirst.frc.team4528.robot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.Timer;
public class Robot15 extends SampleRobot {
Victor frontLeft;
Victor rearLeft;
Victor frontRight;
Victor rearRight;
Victor motor; //add-on
RobotDrive myRobot; // class that handles basic drive operations
XBoxJoystick gamepad; // declare gamepad as a Joystick object to get Joystick functionality, but with different buttons
public void Robot()
{
frontLeft = new Victor(1); //change port to appropriate PWM port on roboRIO
rearLeft = new Victor(2); //change port to appropriate PWM port on roboRIO
frontRight = new Victor(3); //change port to appropriate PWM port on roboRIO
rearRight = new Victor(4); //change port to appropriate PWM port on roboRIO
motor = new Victor(5); //add-on
myRobot = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight); // robot drivetrain functionality; takes in front left motor, rear left motor, front right motor, rear right motor ports
gamepad = new XBoxJoystick(0); // port gamepad is plugged into
}
//add-on
public void runMotor()
{
if(gamepad.getLeftZ() > 0)
{
motor.set(gamepad.getLeftZ());
}
else if(gamepad.getRightZ() > 0)
{
motor.set(-gamepad.getRightZ());
}
else
{
motor.set(0.0);
}
}
//end of...
/**
* Runs the motors with tank steering.
*/
public void operatorControl()
{
myRobot.setSafetyEnabled(false);
while (isOperatorControl() && isEnabled())
{
myRobot.tankDrive(gamepad.getRightY(), gamepad.getLeftY());
Timer.delay(0.005); // wait for a motor update time
runMotor();
}
}
}
No matter what victor we connect to the RoboRIO in port 1, it works. None of the other ports work. The victors blink even when robot is enabled.
Any Victor we put in port 0 or 1 will turn solid when enabled, but any other will not. The PWM cable is not the issue either. We replaced the battery in case it was low voltage.
This code was working 5 days ago. Now it is not. We’ve re-imaged the RoboRio and uploaded the code again. Still same issue.
We don’t even call port 0 in our code but it runs the victor connected to port 1.