Updated Writing an Op Mode with FTC Blocks (markdown)
@ -81,19 +81,19 @@ If you did not [create and activate a configuration file yet](https://github.com
|
||||
|
||||
| Modifying Your Op Mode to Control a DC Motor |
|
||||
| ---- |
|
||||
| 1. On the left-hand side of the screen click on the category called “Variables” to display the list of block commands that are used to create and modify variables within your op mode.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep1.jpg" width="200"></p>Click on “Create variable…” to create a new variable that will represent the target motor power for our op mode. |
|
||||
| 2. When prompted, type in a name (“tgtPower”) for your new variable.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep2.jpg" width="350"></p> |
|
||||
| 3. Once you have created your new variable, some additional programming blocks should appear under the “Variables” block category.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep3.jpg" width="300"></p> |
|
||||
| 4. Click on the “set tgtPower to” programming block and then use the mouse to drag the block to the spot just after the “Put loop blocks here” comment block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep4.jpg" width="300"></p>The “set tgtPower to” block should snap right into position. |
|
||||
| 5. Click on the “Gamepad” category of the programming blocks and select the “gamepad1.LeftStickY” block from the list of available blocks.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep5.jpg" width="300"></p>Note that the control system lets you have up to two gamepads controlling a robot. By selecting “gamepad1” you are telling the op mode to use the control input from the gamepad that is designated as driver #1. |
|
||||
| 6. Drag the “gamepad1.LeftStickY” block so it snaps in place onto the right side of the “set tgtPower to” block. This set of blocks will continually loop and read the value of gamepad #1’s left joystick (the y position) and set the variable tgtPower to the Y value of the left joystick.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep6a.jpg" width="300"></p>Note that for the F310 gamepads, the Y value of a joystick ranges from -1, when a joystick is in its topmost position, to +1, when a joystick is in its bottommost position.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep6b.jpg" width="250"></p>This means that for the blocks shown in our example, if the left joystick is pushed to the top, the variable tgtPower will have a value of -1. |
|
||||
| 7. Click on the “Math” category for the programming blocks and select the negative symbol (“-“).<p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep7.jpg" width="300"></p> |
|
||||
| 8. Drag the negative symbol (also known as a “negation operator”) to the left of the “gamepad1.LeftStickY” block. It should click in place after the “set tgtPower to” block and before the “gamepad1.LeftStickY” block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep8.jpg" width="300"></p> With this change, the variable tgtPower will be set to +1 if the left joystick is in its topmost position and will be set to -1 if the joystick is in its bottommost position. |
|
||||
| 9. Click on the “Actuators” category of blocks.<p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep9.jpg" width="200"></p> |
|
||||
| 10. Select the “set motorTest.Power to 1” programming block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep10.jpg" width="400"></p> |
|
||||
| 11. Drag and place the “set motorTest.Power to 1” block so that it snaps in place right below the “set tgtPower to” block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep11.jpg" width="400"></p> |
|
||||
| 12. Click on the “Variables” block category and select the “tgtPower” block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep12.jpg" width="300"></p> |
|
||||
| 13. Drag the “tgtPower” block so it snaps in place just to the right of the “set motor1.Power to” block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep13.jpg" width="400"></p>The “tgtPower” block should automatically replace the default value of “1” block. |
|
||||
| 1. On the left-hand side of the screen click on the category called “Variables” to display the list of block commands that are used to create and modify variables within your op mode.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep1ControlHub.jpg" width="200"></p>Click on “Create variable…” to create a new variable that will represent the target motor power for our op mode. |
|
||||
| 2. When prompted, type in a name (“tgtPower”) for your new variable.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep2ControlHub.jpg" width="350"></p> |
|
||||
| 3. Once you have created your new variable, some additional programming blocks should appear under the “Variables” block category.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep3ControlHub.jpg" width="300"></p> |
|
||||
| 4. Click on the “set tgtPower to” programming block and then use the mouse to drag the block to the spot just after the “Put loop blocks here” comment block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep4ControlHub.jpg" width="300"></p>The “set tgtPower to” block should snap right into position. |
|
||||
| 5. Click on the “Gamepad” category of the programming blocks and select the “gamepad1.LeftStickY” block from the list of available blocks.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep5ControlHub.jpg" width="300"></p>Note that the control system lets you have up to two gamepads controlling a robot. By selecting “gamepad1” you are telling the op mode to use the control input from the gamepad that is designated as driver #1. |
|
||||
| 6. Drag the “gamepad1.LeftStickY” block so it snaps in place onto the right side of the “set tgtPower to” block. This set of blocks will continually loop and read the value of gamepad #1’s left joystick (the y position) and set the variable tgtPower to the Y value of the left joystick.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep6a.jpg" width="300"></p>Note that for the F310 gamepads, the Y value of a joystick ranges from -1, when a joystick is in its topmost position, to +1, when a joystick is in its bottommost position.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep6bControlHub.jpg" width="250"></p>This means that for the blocks shown in our example, if the left joystick is pushed to the top, the variable tgtPower will have a value of -1. |
|
||||
| 7. Click on the “Math” category for the programming blocks and select the negative symbol (“-“).<p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep7ControlHub.jpg" width="300"></p> |
|
||||
| 8. Drag the negative symbol (also known as a “negation operator”) to the left of the “gamepad1.LeftStickY” block. It should click in place after the “set tgtPower to” block and before the “gamepad1.LeftStickY” block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep8ControlHub.jpg" width="300"></p> With this change, the variable tgtPower will be set to +1 if the left joystick is in its topmost position and will be set to -1 if the joystick is in its bottommost position. |
|
||||
| 9. Click on the “Actuators” category of blocks.<p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep9ControlHub.jpg" width="200"></p> |
|
||||
| 10. Select the “set motorTest.Power to 1” programming block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep10ControlHub.jpg" width="400"></p> |
|
||||
| 11. Drag and place the “set motorTest.Power to 1” block so that it snaps in place right below the “set tgtPower to” block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep11ControlHub.jpg" width="400"></p> |
|
||||
| 12. Click on the “Variables” block category and select the “tgtPower” block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep12ControlHub.jpg" width="300"></p> |
|
||||
| 13. Drag the “tgtPower” block so it snaps in place just to the right of the “set motor1.Power to” block.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/AddingDCMotorStep13ControlHub.jpg" width="400"></p>The “tgtPower” block should automatically replace the default value of “1” block. |
|
||||
|
||||
### Inserting Telemetry Statements
|
||||
Your op mode is just about ready to run. However, before continuing, you will add a couple of telemetry statements that will send information from the Robot Controller to the Driver Station for display on the Driver Station user interface. This telemetry mechanism is a useful way to display status information from the robot on the Driver Station. You can use this mechanism to display sensor data, motor status, gamepad state, etc. from the Robot Controller to the Driver Station.
|
||||
|
Reference in New Issue
Block a user