View Single Post
  #1   Spotlight this post!  
Unread 06-02-2013, 20:48
r0306 r0306 is offline
Registered User
AKA: Robert Lu
FRC #0253 (MRT)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2010
Location: California
Posts: 13
r0306 is an unknown quantity at this point
Can't set victor speed from class instance.

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:

Code:
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.

Code:
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.

Code:
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?
__________________
Scrambled Eggs for the children
Reply With Quote