View Single Post
  #9   Spotlight this post!  
Unread 01-31-2016, 09:05 AM
ckirschner ckirschner is offline
Registered User
FRC #0869
 
Join Date: Jan 2016
Location: New Jersey
Posts: 9
ckirschner is an unknown quantity at this point
Re: Using joystick buttons with Command based programming

Quote:
Originally Posted by Guy997 View Post
You might want to have Commandbase.init() in your robotInit.

Like so:
Code:
 public void robotInit() {
		oi = new OI();
        // instantiate the command used for the autonomous period
        CommandBase.init();
That's a snippet from our code.

I'm not positive that's the issue, but it might be a problem.


Quote:
Originally Posted by MaGiC_PiKaChU View Post
in robotInit, you have to initialise your subsystems before your OI. Else you will try to build commands that use methods from non-existing subsystems

Okay that makes sense then. I will check that out today. However one question I have about that (I apologize I'm not actually a programmer, just appointed to this position as the best candidate to figure out programming the robot )

If you look in my code I created the driveTrain class in the Robot class but not in robotInit and the drive train works. So is that sufficient? And if so, or if not, what exactly is robotInit doing that the declaration inside the Robot class isn't?

Code:
public class Robot extends IterativeRobot {

	public static final ExampleSubsystem exampleSubsystem = new ExampleSubsystem();
	public static final driveTrain DriveTrain = new driveTrain();
	public static final driveWithJoysticks driveWithJoysticks = new driveWithJoysticks();
	public static final camera cameraSystem = new camera();
	
	
	public static OI oi;

    Command autonomousCommand;
    SendableChooser chooser;

    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
		oi = new OI();
        //chooser = new SendableChooser();
        //chooser.addDefault("Default Auto", new ExampleCommand());
//        chooser.addObject("My Auto", new MyAutoCommand());
        //SmartDashboard.putData("Auto mode", chooser);
    }
Reply With Quote