Changes between Version 9 and Version 10 of ControlSystems/SoftwareTeam/Training/WPILib/CommandBasedProgramming


Ignore:
Timestamp:
Dec 17, 2019, 10:11:19 AM (6 years ago)
Author:
David Albert
Comment:

--

Legend:

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

    v9 v10  
    6767}}}
    6868
    69 Add !OpenCommand.java and !CloseCommand.java under commands:
     69Add new commands in commands folder:
     70
    7071!OpenCommand.java:
    7172{{{
     
    7778public class OpenCommand extends Command {
    7879  public OpenCommand() {
    79     requires(Robot.m_servo);
     80    requires(Robot.m_servo); // servo must be available
    8081  }
    8182
     
    8485    System.out.println("Open Pressed.");
    8586    Robot.m_servo.setAngle(30); // set servo to open position
    86     return true;
     87    return true;                // and then finish
    8788  }
    8889}
     
    9899public class CloseCommand extends Command {
    99100  public CloseCommand() {
    100     requires(Robot.m_servo);
     101    requires(Robot.m_servo); // servo must be available
    101102  }
    102103
     
    105106    System.out.println("Close Pressed.");
    106107    Robot.m_servo.setAngle(120); // set servo to closed position
    107     return true;
     108    return true;                 // and then finish
    108109  }
    109110}
     
    142143public class Robot extends TimedRobot {
    143144  public static ServoSubsystem m_servo = ServoSubsystem.getInstance();
    144   public static OI m_oi;
     145  public static OI m_oi; // operator interface
    145146
    146147  @Override
     
    151152  @Override
    152153  public void disabledPeriodic() {
    153     Scheduler.getInstance().run();
     154    Scheduler.getInstance().run(); // run enabled commands
    154155  }
    155156
    156   /**
    157    * This function is called periodically during autonomous.
    158    */
    159157  @Override
    160158  public void autonomousPeriodic() {
    161     Scheduler.getInstance().run();
     159    Scheduler.getInstance().run(); // run enabled commands
    162160  }
    163161
    164162  @Override
    165163  public void teleopPeriodic() {
    166     Scheduler.getInstance().run();
     164    Scheduler.getInstance().run(); // run enabled commands
    167165  }
    168166}