{"action":"created","comment":{"url":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/comments/84620165","pull_request_review_id":5385734,"id":84620165,"diff_hunk":"@@ -1,25 +1,62 @@\n-# Command-based Programming\n-\n-Spartronics team uses command-based design pattern to organize\n-robot code. For an introduction to command-based programming, see [What is Command Based Programming?](https://wpilib.screenstepslive.com/s/4485/m/13810/l/241892-what-is-command-based-programming)\n-\n-## Commands vs. Subsystems\n-@TODO explain difference of the two and relationship\n-\n-- [Scheduler: Know your master...](./scheduler/README.md)\n-- [Commands](./commands/README.md)\n-    - [x] Constructors\n-    - [x] initialize\n-    - [x] execute\n-    - [x] isFinished\n-    - [x] end\n-    - [x] interrupted\n-- [Subsystems](./subsystems/README.md)\n-    - [ ] Constructor\n-    - [ ] Methods\n-    - [ ] Variables\n-    - [ ] Constants\n-    - [ ] initDefaultCommand\n-    - [ ] One system vs. two: intake and intake wheels example\n-- Diving into Subsystems\n-    - @TODO Drivetrain and template code\n+# Command-based Programming: Overview\n+\n+Spartronics team uses WPI's command-based design pattern to organize robot code. For an introduction to command-based programming, also see [What is Command Based Programming?](https://wpilib.screenstepslive.com/s/4485/m/13810/l/241892-what-is-command-based-programming)\n+\n+When we model our robot, we are identifying the things our robot does, and data and state it needs to manage. These roughly translate to Commands and Subsystems.\n+\n+## Subsystems\n+Subsystems model the physical components on the robot: drivetrain, elevator, launcher, ... In short, subsystems define the capabilities for each major part of the robot.\n+\n+Each of these subsystems have methods that allows reading and manipulating the state of that subsystem: drive, isStopped, getDistance, ...\n+\n+Each subsystem class is a subclass of the WPILib Subsystem class.\n+\n+```java\n+import edu.wpi.first.wpilibj.command.Subsystem;\n+import edu.wpi.first.wpilibj.command.PIDSubsystem\n+import edu.wpi.first.wpilibj.command.Scheduler;\n+\n+public class IntakeLauncher extends Subsystem {\n+  ...\n+}\n+```\n+\n+For subsystems with PID, you can use ```edu.wpi.first.wpilibj.command.Subsystem``` for access to convenience methods.\n+\n+### Subsystem design steps\n+1. Describe your subsystem's behavior and how it transitions. Behaviors are activities that we can observe externally: _move forward_, _turn_, _stop_... Think about what behaviors can run concurrently and what requires a sole attention: _can you chew gum and brush teeth at the same time?_\n+2. Brainstorm things your subsystem needs to do: _move forward some distance_, _turn some degrees_, _adjust speed_...\n+3. Identify internal and/or external data it needs to do its job accurately and correctly: _sensor info on distance moved_, _current speed_, _current heading_...\n+\n+\n+## Commands\n+Commands enable us to operate our robot as a system. Commands are small chunks of tasks from different subsystems that we can chain together to perform more complex operations. As such, Commands can be tested individually. Each subsystem can also have a default command, which will run when no other running commands require that subsystem.\n+- Move foreward 15 ft while lowering the arm and shoot\n+- Grab the garbage can and move to 4th elevator position while driving\n+- Lower arms, put intake to neutral and drive forward\n+\n+```java\n+import edu.wpi.first.wpilibj.command.Command;\n+import edu.wpi.first.wpilibj.command.CommandGroup\n+import edu.wpi.first.wpilibj.command.Scheduler;\n+\n+public class IntakeLauncher extends Subsystem {\n+  ...\n+}\n+```\n+\n+Commands are executed sequentially, and needs to be scheduled. They can be tied to autonomous modes, operator interface buttons, or SmartDashboard virtual buttons for scheduling.\n+\n+Commands can also be grouped together allowing the ability to run commands concurrently. Once the group is created, similar to Commands, it can be tied to a single entry to executing all the commands in this group. A command group finishes when all the commands started in that group finish.\n+\n+> Important: Commands require subsystem(s) to be present.  Command groups automatically require all the subsystems for each of the commands in the group. This puts additional constraints on your subsystem design: _should you combine two similarly related subsystems as one?_ Make sure you think through the operational needs of the system as that dependency may complicate future commands.\n+\n+\n+## Scheduler\n+Scheduler is responsible for scheduling Commands. Although many commands maybe running virtually at the same time, robot code is single threaded, i.e. there is only a single main robot thread. As a note, PID loops are self-contained threads that does not require scheduler.\n+\n+Every 20ms (when driver station update takes place), Scheduler walks through its table of Commands to determine what commands need to be scheduled or marked as completed. For this, Scheduler calls each command's _execute()_ followed by _isFinished()_ methods. If _isFinished()_ is true, command is removed from the scheduling queue.\n+\n+![Inside Scheduler's run method](images/scheduler-run.png)\n+\n+If a command is interruptable, scheduler will interrupt the running command to schedule the new one: pushing elevator down button will interrupt the elevator move up command.","path":"commands_subsystems/README.md","position":87,"original_position":87,"commit_id":"3ae99839c660bd71e02a925fd342692c0b660df7","original_commit_id":"3ae99839c660bd71e02a925fd342692c0b660df7","user":{"login":"riyadth","id":302320,"avatar_url":"https://avatars.githubusercontent.com/u/302320?v=3","gravatar_id":"","url":"https://api.github.com/users/riyadth","html_url":"https://github.com/riyadth","followers_url":"https://api.github.com/users/riyadth/followers","following_url":"https://api.github.com/users/riyadth/following{/other_user}","gists_url":"https://api.github.com/users/riyadth/gists{/gist_id}","starred_url":"https://api.github.com/users/riyadth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riyadth/subscriptions","organizations_url":"https://api.github.com/users/riyadth/orgs","repos_url":"https://api.github.com/users/riyadth/repos","events_url":"https://api.github.com/users/riyadth/events{/privacy}","received_events_url":"https://api.github.com/users/riyadth/received_events","type":"User","site_admin":false},"body":"'the scheduler'","created_at":"2016-10-24T04:37:09Z","updated_at":"2016-10-24T04:38:04Z","html_url":"https://github.com/Spartronics4915/developers_handbook/pull/12#discussion_r84620165","pull_request_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/comments/84620165"},"html":{"href":"https://github.com/Spartronics4915/developers_handbook/pull/12#discussion_r84620165"},"pull_request":{"href":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/12","id":90548083,"html_url":"https://github.com/Spartronics4915/developers_handbook/pull/12","diff_url":"https://github.com/Spartronics4915/developers_handbook/pull/12.diff","patch_url":"https://github.com/Spartronics4915/developers_handbook/pull/12.patch","issue_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/issues/12","number":12,"state":"open","locked":false,"title":"Introduction section on commands and subsystems","user":{"login":"binnur","id":6155331,"avatar_url":"https://avatars.githubusercontent.com/u/6155331?v=3","gravatar_id":"","url":"https://api.github.com/users/binnur","html_url":"https://github.com/binnur","followers_url":"https://api.github.com/users/binnur/followers","following_url":"https://api.github.com/users/binnur/following{/other_user}","gists_url":"https://api.github.com/users/binnur/gists{/gist_id}","starred_url":"https://api.github.com/users/binnur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/binnur/subscriptions","organizations_url":"https://api.github.com/users/binnur/orgs","repos_url":"https://api.github.com/users/binnur/repos","events_url":"https://api.github.com/users/binnur/events{/privacy}","received_events_url":"https://api.github.com/users/binnur/received_events","type":"User","site_admin":false},"body":"@riyadth take a read and delete branch after merging. thanks!","created_at":"2016-10-24T04:29:11Z","updated_at":"2016-10-24T04:38:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4be42d16b9bc1bb3bd41c9fe971e1aec0b816fc9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/12/commits","review_comments_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/12/comments","review_comment_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/issues/12/comments","statuses_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/statuses/3ae99839c660bd71e02a925fd342692c0b660df7","head":{"label":"Spartronics4915:robot-code","ref":"robot-code","sha":"3ae99839c660bd71e02a925fd342692c0b660df7","user":{"login":"Spartronics4915","id":7199283,"avatar_url":"https://avatars.githubusercontent.com/u/7199283?v=3","gravatar_id":"","url":"https://api.github.com/users/Spartronics4915","html_url":"https://github.com/Spartronics4915","followers_url":"https://api.github.com/users/Spartronics4915/followers","following_url":"https://api.github.com/users/Spartronics4915/following{/other_user}","gists_url":"https://api.github.com/users/Spartronics4915/gists{/gist_id}","starred_url":"https://api.github.com/users/Spartronics4915/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Spartronics4915/subscriptions","organizations_url":"https://api.github.com/users/Spartronics4915/orgs","repos_url":"https://api.github.com/users/Spartronics4915/repos","events_url":"https://api.github.com/users/Spartronics4915/events{/privacy}","received_events_url":"https://api.github.com/users/Spartronics4915/received_events","type":"Organization","site_admin":false},"repo":{"id":65632234,"name":"developers_handbook","full_name":"Spartronics4915/developers_handbook","owner":{"login":"Spartronics4915","id":7199283,"avatar_url":"https://avatars.githubusercontent.com/u/7199283?v=3","gravatar_id":"","url":"https://api.github.com/users/Spartronics4915","html_url":"https://github.com/Spartronics4915","followers_url":"https://api.github.com/users/Spartronics4915/followers","following_url":"https://api.github.com/users/Spartronics4915/following{/other_user}","gists_url":"https://api.github.com/users/Spartronics4915/gists{/gist_id}","starred_url":"https://api.github.com/users/Spartronics4915/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Spartronics4915/subscriptions","organizations_url":"https://api.github.com/users/Spartronics4915/orgs","repos_url":"https://api.github.com/users/Spartronics4915/repos","events_url":"https://api.github.com/users/Spartronics4915/events{/privacy}","received_events_url":"https://api.github.com/users/Spartronics4915/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Spartronics4915/developers_handbook","description":"A guide for FIRST Robotics development, specifically targeted for FRC use.","fork":false,"url":"https://api.github.com/repos/Spartronics4915/developers_handbook","forks_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/forks","keys_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/teams","hooks_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/hooks","issue_events_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/issues/events{/number}","events_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/events","assignees_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/assignees{/user}","branches_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/branches{/branch}","tags_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/tags","blobs_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/git/refs{/sha}","trees_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/statuses/{sha}","languages_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/languages","stargazers_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/stargazers","contributors_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/contributors","subscribers_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/subscribers","subscription_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/subscription","commits_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/commits{/sha}","git_commits_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/git/commits{/sha}","comments_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/comments{/number}","issue_comment_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/issues/comments{/number}","contents_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/contents/{+path}","compare_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/merges","archive_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/downloads","issues_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/issues{/number}","pulls_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls{/number}","milestones_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/milestones{/number}","notifications_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/labels{/name}","releases_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/releases{/id}","deployments_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/deployments","created_at":"2016-08-13T18:53:46Z","updated_at":"2016-10-24T04:22:38Z","pushed_at":"2016-10-24T04:29:11Z","git_url":"git://github.com/Spartronics4915/developers_handbook.git","ssh_url":"git@github.com:Spartronics4915/developers_handbook.git","clone_url":"https://github.com/Spartronics4915/developers_handbook.git","svn_url":"https://github.com/Spartronics4915/developers_handbook","homepage":null,"size":1449,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"Spartronics4915:master","ref":"master","sha":"587ef7b5489765c4c2b391f14d1f46aaa658f4e8","user":{"login":"Spartronics4915","id":7199283,"avatar_url":"https://avatars.githubusercontent.com/u/7199283?v=3","gravatar_id":"","url":"https://api.github.com/users/Spartronics4915","html_url":"https://github.com/Spartronics4915","followers_url":"https://api.github.com/users/Spartronics4915/followers","following_url":"https://api.github.com/users/Spartronics4915/following{/other_user}","gists_url":"https://api.github.com/users/Spartronics4915/gists{/gist_id}","starred_url":"https://api.github.com/users/Spartronics4915/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Spartronics4915/subscriptions","organizations_url":"https://api.github.com/users/Spartronics4915/orgs","repos_url":"https://api.github.com/users/Spartronics4915/repos","events_url":"https://api.github.com/users/Spartronics4915/events{/privacy}","received_events_url":"https://api.github.com/users/Spartronics4915/received_events","type":"Organization","site_admin":false},"repo":{"id":65632234,"name":"developers_handbook","full_name":"Spartronics4915/developers_handbook","owner":{"login":"Spartronics4915","id":7199283,"avatar_url":"https://avatars.githubusercontent.com/u/7199283?v=3","gravatar_id":"","url":"https://api.github.com/users/Spartronics4915","html_url":"https://github.com/Spartronics4915","followers_url":"https://api.github.com/users/Spartronics4915/followers","following_url":"https://api.github.com/users/Spartronics4915/following{/other_user}","gists_url":"https://api.github.com/users/Spartronics4915/gists{/gist_id}","starred_url":"https://api.github.com/users/Spartronics4915/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Spartronics4915/subscriptions","organizations_url":"https://api.github.com/users/Spartronics4915/orgs","repos_url":"https://api.github.com/users/Spartronics4915/repos","events_url":"https://api.github.com/users/Spartronics4915/events{/privacy}","received_events_url":"https://api.github.com/users/Spartronics4915/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Spartronics4915/developers_handbook","description":"A guide for FIRST Robotics development, specifically targeted for FRC use.","fork":false,"url":"https://api.github.com/repos/Spartronics4915/developers_handbook","forks_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/forks","keys_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/teams","hooks_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/hooks","issue_events_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/issues/events{/number}","events_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/events","assignees_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/assignees{/user}","branches_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/branches{/branch}","tags_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/tags","blobs_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/git/refs{/sha}","trees_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/statuses/{sha}","languages_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/languages","stargazers_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/stargazers","contributors_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/contributors","subscribers_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/subscribers","subscription_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/subscription","commits_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/commits{/sha}","git_commits_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/git/commits{/sha}","comments_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/comments{/number}","issue_comment_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/issues/comments{/number}","contents_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/contents/{+path}","compare_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/merges","archive_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/downloads","issues_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/issues{/number}","pulls_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls{/number}","milestones_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/milestones{/number}","notifications_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/labels{/name}","releases_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/releases{/id}","deployments_url":"https://api.github.com/repos/Spartronics4915/developers_handbook/deployments","created_at":"2016-08-13T18:53:46Z","updated_at":"2016-10-24T04:22:38Z","pushed_at":"2016-10-24T04:29:11Z","git_url":"git://github.com/Spartronics4915/developers_handbook.git","ssh_url":"git@github.com:Spartronics4915/developers_handbook.git","clone_url":"https://github.com/Spartronics4915/developers_handbook.git","svn_url":"https://github.com/Spartronics4915/developers_handbook","homepage":null,"size":1449,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/12"},"html":{"href":"https://github.com/Spartronics4915/developers_handbook/pull/12"},"issue":{"href":"https://api.github.com/repos/Spartronics4915/developers_handbook/issues/12"},"comments":{"href":"https://api.github.com/repos/Spartronics4915/developers_handbook/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Spartronics4915/developers_handbook/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/Spartronics4915/developers_handbook/statuses/3ae99839c660bd71e02a925fd342692c0b660df7"}}}}
{"actor":{"display_login":"riyadth"}}