Updated Creating and Running an Op Mode (OnBot Java) (markdown)

FTC Engineering
2019-07-09 13:11:44 -04:00
parent 95150f99fe
commit 3a8760345c

@ -16,11 +16,11 @@ Teams who are participating in the FIRST Tech Challenge have a variety of progra
The FTC OnBot Java Programming Tool is a user-friendly programming tool that is served up by the Robot Controller phone. A user can create custom op modes for their robot using this tool and then save these op modes directly onto the Robot Controller. Users write their op modes using Java. The op modes are compiled very quickly on the Robot Controller and then loaded dynamically by the Robot Controller during run time. The FTC OnBot Java Programming Tool is a user-friendly programming tool that is served up by the Robot Controller phone. A user can create custom op modes for their robot using this tool and then save these op modes directly onto the Robot Controller. Users write their op modes using Java. The op modes are compiled very quickly on the Robot Controller and then loaded dynamically by the Robot Controller during run time.
<p align="center">[[/images/Creating-and-Running-an-Op-Mode-(OnBot Java)/OnBotDoc001_MainScreen.jpg]]<p> <p align="center">[[/images/Creating-and-Running-an-Op-Mode-(OnBot-Java)/OnBotDoc001_MainScreen.jpg]]<p>
The examples in this document use a Windows laptop computer to connect to the Robot Controller. This Windows laptop computer has a Javascript-enabled web browser installed that is used to access the FTC OnBot Java Programming Tool. The examples in this document use a Windows laptop computer to connect to the Robot Controller. This Windows laptop computer has a Javascript-enabled web browser installed that is used to access the FTC OnBot Java Programming Tool.
<p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/OnBotJava/OnBotDoc002_WiFiConnection.jpg" width="500"><p> <p align="center">[[/images/Writing-an-Op-Mode-with-FTC-Blocks/BlocksPicture2.jpg]]<p>
Note that the process used to create and edit an op mode is identical if you are using a Control Hub as your Robot Controller. Note that the process used to create and edit an op mode is identical if you are using a Control Hub as your Robot Controller.
@ -37,14 +37,14 @@ If you connected your laptop successfully to the Program & Manage wireless netwo
| ---- | | ---- |
| 1. Launch the web browser on your laptop (FIRST recommends using Google Chrome) and find the web address that is displayed on the Program & Manage screen of the Robot Controller. <br/><br/>**Important Note:** If your Robot Controller is an Android smartphone, then the address to access the Program & Manage server is "192.168.49.1:8080".<br/><br/><p align="center">[[/images/Writing-an-Op-Mode-with-FTC-Blocks/WritingFirstOpModeStep1a.jpg]] </p>**Important Note:** If your Robot Controller is a Control Hub, then the address to access the Program & Manage server is "192.168.43.1:8080". Notice the difference in the third octet of the IP addresses (the Control Hub has a "43" instead of a "49"). <br/><br/><p align="center">[[/images/Writing-an-Op-Mode-with-FTC-Blocks/WritingFirstOpModeStep1aControlHub.jpg]] </p>Type this web address into the address field of your browser and press RETURN to navigate to the Program & Manage web server.<br/><br/><p align="center">[[/images/Writing-an-Op-Mode-with-FTC-Blocks/WritingFirstOpModeStep1bControlHub.jpg]] </p>| | 1. Launch the web browser on your laptop (FIRST recommends using Google Chrome) and find the web address that is displayed on the Program & Manage screen of the Robot Controller. <br/><br/>**Important Note:** If your Robot Controller is an Android smartphone, then the address to access the Program & Manage server is "192.168.49.1:8080".<br/><br/><p align="center">[[/images/Writing-an-Op-Mode-with-FTC-Blocks/WritingFirstOpModeStep1a.jpg]] </p>**Important Note:** If your Robot Controller is a Control Hub, then the address to access the Program & Manage server is "192.168.43.1:8080". Notice the difference in the third octet of the IP addresses (the Control Hub has a "43" instead of a "49"). <br/><br/><p align="center">[[/images/Writing-an-Op-Mode-with-FTC-Blocks/WritingFirstOpModeStep1aControlHub.jpg]] </p>Type this web address into the address field of your browser and press RETURN to navigate to the Program & Manage web server.<br/><br/><p align="center">[[/images/Writing-an-Op-Mode-with-FTC-Blocks/WritingFirstOpModeStep1bControlHub.jpg]] </p>|
| 2. Verify that your web browser is connected to the programming mode server. If it is connected to the programming mode server successfully, the Robot Controller Console should be displayed.<br/><br/><p align="center">[[/images/Writing-an-Op-Mode-with-FTC-Blocks/WritingFirstOpModeStep2ControlHub.jpg]] | | 2. Verify that your web browser is connected to the programming mode server. If it is connected to the programming mode server successfully, the Robot Controller Console should be displayed.<br/><br/><p align="center">[[/images/Writing-an-Op-Mode-with-FTC-Blocks/WritingFirstOpModeStep2ControlHub.jpg]] |
| 3. Click on the word “OnBotJava” towards the top of the screen. This will switch the browser to OnBot Java Programming mode.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/OnBotJava/OnBotDoc_Step3_OnBotJavaButton.jpg" width="250"></p> | | 3. Click on the word “OnBotJava” towards the top of the screen. This will switch the browser to OnBot Java Programming mode.<br/><br/><p align="center">[[/images/Creating-and-Running-an-Op-Mode-(OnBot-Java)/OnBotDoc_Step3_OnBotJavaButton.jpg]]</p> |
| 4. Take a look at the OnBot Java user interface. On the left hand side, there is the project browser pane. In the upper right hand corner, there is the source code editing pane. In the lower right hand corner, there is the message pane.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/OnBotJava/OnBotDoc_Step4_OnBotScreen.jpg" width="650"></p> | | 4. Take a look at the OnBot Java user interface. On the left hand side, there is the project browser pane. In the upper right hand corner, there is the source code editing pane. In the lower right hand corner, there is the message pane.<br/><br/><p align="center">[[/images/Creating-and-Running-an-Op-Mode-(OnBot-Java)/OnBotDoc_Step4_OnBotScreen.jpg]]</p> |
| 5. In the project browser pane, press the “+” symbol to create a new file. Pushing this button will launch the New File dialog box. This dialog box has several parameters that you can configure to customize your new file.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/OnBotJava/OnBotDoc_Step5_NewFile.jpg" width="350"></p><br/>For this example, specify “MyFIRSTJavaOpMode” as the File Name in the New File dialog box.<br/><br/>Using the Sample dropdown list control, select “BlankLinearOpMode” from the list of available sample op modes (see image above). By selecting “BlankLinearOpMode” the OnBot Java editor will automatically generate a basic LinearOpMode framework for you.<br/><br/>Check the option labeled “TeleOp” to ensure that this new file will be configured as a tele-operated (i.e., driver controlled) op mode.<br/><br/>Also, make sure you check the “Setup Code for Configured Hardware” option. If this option is enabled, the OnBot Java editor will look at the hardware configuration file for your Robot Controller and automatically generate the code that you will need to access the configured devices in your op mode.<br/><br/>Press the “OK” button to create your new op mode. | | 5. In the project browser pane, press the “+” symbol to create a new file. Pushing this button will launch the New File dialog box. This dialog box has several parameters that you can configure to customize your new file.<br/><br/><p align="center">[[/images/Creating-and-Running-an-Op-Mode-(OnBot-Java)/OnBotDoc_Step5_NewFile.jpg]]</p><br/>For this example, specify “MyFIRSTJavaOpMode” as the File Name in the New File dialog box.<br/><br/>Using the Sample dropdown list control, select “BlankLinearOpMode” from the list of available sample op modes (see image above). By selecting “BlankLinearOpMode” the OnBot Java editor will automatically generate a basic LinearOpMode framework for you.<br/><br/>Check the option labeled “TeleOp” to ensure that this new file will be configured as a tele-operated (i.e., driver controlled) op mode.<br/><br/>Also, make sure you check the “Setup Code for Configured Hardware” option. If this option is enabled, the OnBot Java editor will look at the hardware configuration file for your Robot Controller and automatically generate the code that you will need to access the configured devices in your op mode.<br/><br/>Press the “OK” button to create your new op mode. |
| 6. You should see your newly created op mode in the editing pane of the OnBot Java user interface.<br/><br/><p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/OnBotJava/OnBotDoc_Step6_NewOpModeEditPane.jpg" width="550"></p> | | 6. You should see your newly created op mode in the editing pane of the OnBot Java user interface.<br/><br/><p align="center">[[/images/Creating-and-Running-an-Op-Mode-(OnBot-Java)/OnBotDoc_Step6_NewOpModeEditPane.jpg]]</p> |
Congratulations, you created your first op mode! The op mode currently does not do much, but you will eventually modify it to make it more useful. Congratulations, you created your first op mode! The op mode currently does not do much, but you will eventually modify it to make it more useful.
<p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/OnBotJava/OnBotDoc_Step6_ProjectBrowser.jpg" width="400"></p> <p align="center">[[/images/Creating-and-Running-an-Op-Mode-(OnBot-Java)/OnBotDoc_Step6_ProjectBrowser.jpg]]</p>
Note that when you create an OnBot op mode, you create a .java file that is stored on the Robot Controller. You can access your saved op modes using the project browser on the left side of the screen. You can also organize your saved op modes by right mouse clicking on the project browser to display a list of options to create, edit or delete files and folders. Note that when you create an OnBot op mode, you create a .java file that is stored on the Robot Controller. You can access your saved op modes using the project browser on the left side of the screen. You can also organize your saved op modes by right mouse clicking on the project browser to display a list of options to create, edit or delete files and folders.
@ -53,7 +53,7 @@ Also, note that the OnBot Java editor automatically saves your op mode as you ar
### Examining the Structure of Your Op Mode ### Examining the Structure of Your Op Mode
It can be helpful to think of an op mode as a list of tasks for the Robot Controller to perform. For a linear op mode, the Robot Controller will process this list of tasks sequentially. Users can also use control loops (such as a while loop) to have the Robot Controller repeat (or iterate) certain tasks within a linear op mode. It can be helpful to think of an op mode as a list of tasks for the Robot Controller to perform. For a linear op mode, the Robot Controller will process this list of tasks sequentially. Users can also use control loops (such as a while loop) to have the Robot Controller repeat (or iterate) certain tasks within a linear op mode.
<p align="center"><img src="https://github.com/FIRST-Tech-Challenge/WikiSupport/blob/master/ftc_app/images/OnBotJava/ExaminingStructurePic2.jpg" width="300"></p> <p align="center">[[/images/Creating-and-Running-an-Op-Mode-(OnBot-Java)/ExaminingStructurePic2.jpg]]</p>
If you think about an op mode as a list of instructions for the robot, this set of instructions that you created will be executed by the robot whenever a team member selects the op mode called “MyFIRSTJavaOpMode” from the list of available op modes for this Robot Controller. If you think about an op mode as a list of instructions for the robot, this set of instructions that you created will be executed by the robot whenever a team member selects the op mode called “MyFIRSTJavaOpMode” from the list of available op modes for this Robot Controller.