From caf3e07730f965648918ab8fb73f3bc8be814b9c Mon Sep 17 00:00:00 2001 From: FTC Engineering Date: Wed, 10 Apr 2019 18:42:26 -0400 Subject: [PATCH] Updated Writing an Op Mode with FTC Blocks (markdown) --- Writing-an-Op-Mode-with-FTC-Blocks.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Writing-an-Op-Mode-with-FTC-Blocks.md b/Writing-an-Op-Mode-with-FTC-Blocks.md index bebd2d3..85b6376 100644 --- a/Writing-an-Op-Mode-with-FTC-Blocks.md +++ b/Writing-an-Op-Mode-with-FTC-Blocks.md @@ -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.

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.

| -| 3. Once you have created your new variable, some additional programming blocks should appear under the “Variables” block category.

| -| 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.

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.

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.

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.

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 (“-“).

| -| 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.

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.

| -| 10. Select the “set motorTest.Power to 1” programming block.

| -| 11. Drag and place the “set motorTest.Power to 1” block so that it snaps in place right below the “set tgtPower to” block.

| -| 12. Click on the “Variables” block category and select the “tgtPower” block.

| -| 13. Drag the “tgtPower” block so it snaps in place just to the right of the “set motor1.Power to” block.

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.

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.

| +| 3. Once you have created your new variable, some additional programming blocks should appear under the “Variables” block category.

| +| 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.

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.

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.

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.

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 (“-“).

| +| 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.

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.

| +| 10. Select the “set motorTest.Power to 1” programming block.

| +| 11. Drag and place the “set motorTest.Power to 1” block so that it snaps in place right below the “set tgtPower to” block.

| +| 12. Click on the “Variables” block category and select the “tgtPower” block.

| +| 13. Drag the “tgtPower” block so it snaps in place just to the right of the “set motor1.Power to” block.

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.