In our code, we have a separate class for robot shooter which controls motors attached to a victor. In testing the motor, we’ve noticed that the motor only runs when the victor is instantiated in the main robot class and not the separate shooter class. Here is our main class:
public class RobotMain extends IterativeRobot
{
private static Joystick leftStick;
private static LoaderController loader;
public void robotInit()
{
loader = new LoaderController();
leftStick = new Joystick(LEFT_STICK);
}
public void teleopPeriodic()
{
getLoader().testPiston();
}
public static LoaderController getLoader()
{
return loader;
}
Here is the class for our LoaderController.
public class LoaderController implements RobotPorts
{
private Victor piston;
public LoaderController()
{
piston = new Victor(10);
}
public void testPiston()
{
piston.set(0.2);
}
}
Using the above code, the piston does not run at all. However, when I instantiate the victor variable in the main class like below, the setup works fine.
public class RobotMain extends IterativeRobot
{
private static Joystick leftStick;
private static LoaderController loader;
private static Victor piston;
public void robotInit()
{
loader = new LoaderController();
piston = new Victor(10);
leftStick = new Joystick(LEFT_STICK);
}
public void teleopPeriodic()
{
testPiston();
}
public static LoaderController testPiston()
{
piston.set(0.2);
}
Why does this happen?