Changes between Version 6 and Version 7 of ControlSystems/SoftwareTeam/Training/WPILib/CommandBasedProgramming
- Timestamp:
- Dec 17, 2019, 12:49:16 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/Training/WPILib/CommandBasedProgramming
v6 v7 20 20 !ScreenStepsLive has a very good example of how a program might look if programmed for !TimedRobot and then the same program converted to !CommandRobot; you should review it [https://wpilib.screenstepslive.com/s/currentCS/m/cpp/l/241906-converting-a-simple-autonomous-program-to-a-command-based-autonomous-program here] 21 21 22 The following is an example of a very simple Command Based Robot that has a single subsystem consisting of a servo motor with two positions: Open, Closed and they are selected using the A and B buttons on a gamepad. Replace the template files with:22 The following is an example of a very simple Command Based Robot that has a single subsystem consisting of a servo motor with two positions: Open, Closed and they are selected using the A and B buttons on a gamepad. The servo motor should be connected to PWM port 0 and the code uses a Logitech F310 for the operator interface. Replace the template files with: 23 23 24 RobotMap.java:24 !RobotMap.java: 25 25 {{{ 26 26 package frc.robot; … … 32 32 }}} 33 33 34 Add ServoSubsystem.java under subsystems:34 Add !ServoSubsystem.java under subsystems: 35 35 {{{ 36 36 package frc.robot.subsystems; … … 68 68 }}} 69 69 70 Add OpenCommand.java andCloseCommand.java under commands:71 OpenCommand.java:70 Add !OpenCommand.java and !CloseCommand.java under commands: 71 !OpenCommand.java: 72 72 {{{ 73 73 package frc.robot.commands; … … 90 90 }}} 91 91 92 CloseCommand.java:92 !CloseCommand.java: 93 93 {{{ 94 94 package frc.robot.commands; … … 105 105 protected boolean isFinished() { 106 106 System.out.println("Close Pressed."); 107 Robot.m_servo.setAngle(120); 107 Robot.m_servo.setAngle(120); // set servo to closed position 108 108 return true; 109 109 }