Go to Post The robot was spinning, I dont have the energy to spin like that. - Joe Menassa [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:27.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi