Changes between Version 3 and Version 4 of ControlSystems/SoftwareTeam/Training/WPILib/CommandGroupProgramming


Ignore:
Timestamp:
Feb 27, 2020, 11:08:46 PM (5 years ago)
Author:
David Albert
Comment:

--

Legend:

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

    v3 v4  
    11The last example showed two simple commands and how to connect them with the user interface, but the commands were simple: they set a servo position and immediately finished.  In practice, robot commands often need to run continuously until something happens; for example, a command to raise an arm might start a motor moving and continue until some time has passed or an encoder indicates that the arm has moved a certain distance or a limit switch is pressed.  WPILib commands make this easy.  Even better, you can string several such commands together in a !CommandGroup to effect complex behaviors.
    22
    3 Commands can be grouped together to run in sequence for example, when the X button is pressed, the following code will run the servo open command, allow time for it to finish, and then run the servo close command:
     3Commands can be grouped together to run in sequence for example, when the X button is pressed, the following code will run the servo open command, allow time for it to finish, and then run the servo close command.  The !OpenCommand adds a Timer to allow the servo motor time to complete moving to the open position before the !CloseCommand is run :
    44
    55Constants.java