Changes between Version 11 and Version 12 of ControlSystems/SoftwareTeam/Training/WPILib/CommandBasedProgramming


Ignore:
Timestamp:
Feb 23, 2020, 3:31:41 PM (5 years ago)
Author:
David Albert
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/Training/WPILib/CommandBasedProgramming

    v11 v12  
    1111=== Creating a Command-Based Program ===
    1212Create a new project in VSCode (WPILib Icon->Create a new project->Template->Java->Command Robot).  Notice that in the project src folder, addition to the Main.java and Robot.java we're used to seeing, the project also has: [[Image(CommandBasedFiles.jpg,align=right,margin=10)]]
    13    * RobotContainer.java - where the subsystems, commands, and button bindings are defined
     13   * !RobotContainer.java - where the subsystems, commands, and button bindings are defined
    1414   * Constants.java - where global constants are defined (e.g. motor controller addresses) - may be called !RobotMap
    1515   * commands folder - where your Commands will be stored
     
    110110}}}
    111111
    112 RobotContainer.java:
     112!RobotContainer.java:
    113113{{{
    114114package frc.robot;
     
    170170
    171171=== How it works ===
    172 Command-based programming is built on top of the !TimedRobot template. In each of the template's periodic() methods, !CommandScheduler.getInstance().run() is called. This takes all currently running Commands -- which behave like threads, but can't include waits like typical threads because it's a type of threading known as "cooperative" multitasking -- and runs them, first initializing any new ones and checking whether each one has completed yet. It's useful because these Commands can be easily joined together in CommandGroups to make autonomous modes, or can be mapped to buttons to easily allow complex teleop actions, etc.
     172Command-based programming is built on top of the !TimedRobot template. In each of the template's periodic() methods, !CommandScheduler.getInstance().run() is called. This takes all currently running Commands -- which behave like threads, but can't include waits like typical threads because it's a type of threading known as "cooperative" multitasking -- and runs them, first initializing any new ones and checking whether each one has completed yet. It's useful because these Commands can be easily joined together in !CommandGroups to make autonomous modes, or can be mapped to buttons to easily allow complex teleop actions, etc.
    173173
    174174* [https://docs.google.com/document/d/1JHHRGrhe96rJXw6lIM-X3WJKoD14_8PwqjjP45UI0tg/ Intro to Command Based Programming]