Go to Post It's easy to get overwhelmed. Don't get overwhelmed, just keep working at things a little bit at a time. (Oh, and don't forget to have fun!) - DominickC [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-02-2014, 13:42
Abhi_4505 Abhi_4505 is offline
Registered User
FRC #4505
 
Join Date: Jan 2014
Location: Maryland
Posts: 6
Abhi_4505 is an unknown quantity at this point
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();
    }
    
}
Reply With Quote
  #2   Spotlight this post!  
Unread 08-02-2014, 13:55
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Scheduler Help

Quote:
Originally Posted by Abhi_4505 View Post
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?
Reply With Quote
  #3   Spotlight this post!  
Unread 08-02-2014, 13:59
Abhi_4505 Abhi_4505 is offline
Registered User
FRC #4505
 
Join Date: Jan 2014
Location: Maryland
Posts: 6
Abhi_4505 is an unknown quantity at this point
Re: Scheduler Help

Quote:
Originally Posted by Joe Ross View Post
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
Reply With Quote
  #4   Spotlight this post!  
Unread 08-02-2014, 14:18
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Scheduler Help

Make sure to set a default command in your subsystem.
Reply With Quote
  #5   Spotlight this post!  
Unread 08-02-2014, 15:07
JamesMcD_4505 JamesMcD_4505 is offline
Registered User
FRC #4505
 
Join Date: Jan 2014
Location: Maryland
Posts: 4
JamesMcD_4505 is an unknown quantity at this point
Re: Scheduler Help

Quote:
Originally Posted by Joe Ross View Post
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
Reply With Quote
Reply


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 11:06.

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