Changes between Version 9 and Version 10 of ControlSystems/SoftwareTeam/Training/WPILib/CommandBasedProgramming
- Timestamp:
- Dec 17, 2019, 10:11:19 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/Training/WPILib/CommandBasedProgramming
v9 v10 67 67 }}} 68 68 69 Add !OpenCommand.java and !CloseCommand.java under commands: 69 Add new commands in commands folder: 70 70 71 !OpenCommand.java: 71 72 {{{ … … 77 78 public class OpenCommand extends Command { 78 79 public OpenCommand() { 79 requires(Robot.m_servo); 80 requires(Robot.m_servo); // servo must be available 80 81 } 81 82 … … 84 85 System.out.println("Open Pressed."); 85 86 Robot.m_servo.setAngle(30); // set servo to open position 86 return true; 87 return true; // and then finish 87 88 } 88 89 } … … 98 99 public class CloseCommand extends Command { 99 100 public CloseCommand() { 100 requires(Robot.m_servo); 101 requires(Robot.m_servo); // servo must be available 101 102 } 102 103 … … 105 106 System.out.println("Close Pressed."); 106 107 Robot.m_servo.setAngle(120); // set servo to closed position 107 return true; 108 return true; // and then finish 108 109 } 109 110 } … … 142 143 public class Robot extends TimedRobot { 143 144 public static ServoSubsystem m_servo = ServoSubsystem.getInstance(); 144 public static OI m_oi; 145 public static OI m_oi; // operator interface 145 146 146 147 @Override … … 151 152 @Override 152 153 public void disabledPeriodic() { 153 Scheduler.getInstance().run(); 154 Scheduler.getInstance().run(); // run enabled commands 154 155 } 155 156 156 /**157 * This function is called periodically during autonomous.158 */159 157 @Override 160 158 public void autonomousPeriodic() { 161 Scheduler.getInstance().run(); 159 Scheduler.getInstance().run(); // run enabled commands 162 160 } 163 161 164 162 @Override 165 163 public void teleopPeriodic() { 166 Scheduler.getInstance().run(); 164 Scheduler.getInstance().run(); // run enabled commands 167 165 } 168 166 }