Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Scheduler Help (http://www.chiefdelphi.com/forums/showthread.php?t=126057)

Abhi_4505 08-02-2014 13:42

Scheduler Help
 
We've been using Scheduler for our robot to run our Command Groups. We've created an instance of scheduler and added our commands in robotInit. We then ran the scheduler instance in autonomousPeriodic and teleopPeriodic, but when we enable our robot we have to click the button on SmartDashboard for some of the commands to enable.

Here's our code. Any help would be appreciated.
Code:

// RobotBuilder Version: 1.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.
package org.usfirst.frc4505.MecanumBot14;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.networktables.NetworkTable;
import org.usfirst.frc4505.MecanumBot14.commands.*;
import org.usfirst.frc4505.MecanumBot14.subsystems.*;
/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the IterativeRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class Robot extends IterativeRobot {
    Command autonomousCommand;
    public static OI oi;
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
    public static DriveTrain driveTrain;
    public static Grabber grabber;
    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
   
    /**
    * This function is run when the robot is first started up and should be
    * used for any initialization code.
    */
    public void robotInit() {
        RobotMap.init();
        // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
        driveTrain = new DriveTrain();
        grabber = new Grabber();
    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
        NetworkTable.getTable("table");
        Scheduler.getInstance().add(new DriveGroup());
        Scheduler.getInstance().add(new DistanceGroup());
//        Scheduler.getInstance().run();
        // This MUST be here. If the OI creates Commands (which it very likely
        // will), constructing it during the construction of CommandBase (from
        // which commands extend), subsystems are not guaranteed to be
        // yet. Thus, their requires() statements may grab null pointers. Bad
        // news. Don't move it.
        oi = new OI();
        // instantiate the command used for the autonomous period
        // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
        autonomousCommand = new AutonomousCommand();
    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
    }
    public void autonomousInit() {
        // schedule the autonomous command (example)
        if (autonomousCommand != null) autonomousCommand.start();
    }
    /**
    * This function is called periodically during autonomous
    */
    public void autonomousPeriodic() {
        Scheduler.getInstance().run();
    }
    public void teleopInit() {
        // This makes sure that the autonomous stops running when
        // teleop starts running. If you want the autonomous to
        // continue until interrupted by another command, remove
        // this line or comment it out.
        if (autonomousCommand != null) autonomousCommand.cancel();
    }
    /**
    * This function is called periodically during operator control
    */
    public void teleopPeriodic() {
        Scheduler.getInstance().run();
    }
    /**
    * This function called periodically during test mode
    */
    public void testPeriodic() {
        LiveWindow.run();
    }
   
}


Joe Ross 08-02-2014 13:55

Re: Scheduler Help
 
Quote:

Originally Posted by Abhi_4505 (Post 1339664)
but when we enable our robot we have to click the button on SmartDashboard for some of the commands to enable.

What button on the SmartDashboard? How do you want to enable the commands?

Abhi_4505 08-02-2014 13:59

Re: Scheduler Help
 
Quote:

Originally Posted by Joe Ross (Post 1339673)
What button on the SmartDashboard? How do you want to enable the commands?

Thanks for the response, Mr Ross.
I was talking about the button on SmartDashboard for enabling our Drive and other commands. We want commands like Drive to automatically enable when we enter teleop.

Your help is very much appreciated.
Abhi

Joe Ross 08-02-2014 14:18

Re: Scheduler Help
 
Make sure to set a default command in your subsystem.

JamesMcD_4505 08-02-2014 15:07

Re: Scheduler Help
 
Quote:

Originally Posted by Joe Ross (Post 1339681)
Make sure to set a default command in your subsystem.

That seemed to fix it. Thank you once again for your patience while helping us through this.

-James 4505


All times are GMT -5. The time now is 09:30.

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