{"id":2361,"date":"2020-06-29T11:20:50","date_gmt":"2020-06-29T18:20:50","guid":{"rendered":"http:\/\/firstinmichigan.us\/FTC\/?page_id=2361"},"modified":"2022-10-18T06:35:50","modified_gmt":"2022-10-18T13:35:50","slug":"onbot-java-editor-basics","status":"publish","type":"page","link":"https:\/\/firstinmichigan.us\/FTC\/onbot-java-editor-basics\/","title":{"rendered":"OnBot Java Editor"},"content":{"rendered":"\n<script src=\"https:\/\/cdn.jsdelivr.net\/gh\/google\/code-prettify@master\/loader\/run_prettify.js\"><\/script>\n\n\n<h2>The FIRST Robot Controller Console<\/h2>\n<p>Once you access the web tool, you will be greeted with a screen like this:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-2118\" src=\"http:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2019\/10\/unnamed-2.png\" alt=\"\" width=\"522\" height=\"256\" srcset=\"https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2019\/10\/unnamed-2.png 1600w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2019\/10\/unnamed-2-300x147.png 300w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2019\/10\/unnamed-2-768x377.png 768w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2019\/10\/unnamed-2-1024x502.png 1024w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2019\/10\/unnamed-2-425x209.png 425w\" sizes=\"auto, (max-width: 522px) 100vw, 522px\" \/><\/p>\n<p>On the red bar at the top, you can select if you want to program with Blocks or OnBotJava. Since this is an OnBot Java tutorial, click on &#8220;OnBotJava&#8221;.<\/p>\n<h2>The Editor<\/h2>\n<p>You should now be at this screen:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"border alignnone wp-image-3129\" src=\"http:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_1.png\" alt=\"\" width=\"515\" height=\"252\" srcset=\"https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_1.png 3840w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_1-300x147.png 300w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_1-1024x501.png 1024w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_1-768x376.png 768w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_1-1536x751.png 1536w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_1-2048x1002.png 2048w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_1-425x208.png 425w\" sizes=\"auto, (max-width: 515px) 100vw, 515px\" \/><\/p>\n<p>At the left side of the screen is the Project Files area. This is where all of the programs that you write will be stored. Above this area are various button icons:<\/p>\n<ul>\n<li><strong>Settings (gear)<\/strong> &#8211; allows you to tweak specific settings of the editor<\/li>\n<li><strong>Undo (circular arrow)<\/strong> &#8211; reverts the last change that you made to your program. Can also be activated by pressing Ctrl+Z (\u2318+Z on a Mac) on your computer&#8217;s keyboard.<\/li>\n<li><strong>Add File (plus sign)<\/strong> &#8211; opens a prompt that allows you to name and create a new program<\/li>\n<li><strong>Upload Files (up arrow)<\/strong> &#8211; allows you to upload program files from your computer into the project. Note that Java programs are stored as <strong>.java<\/strong> files (example: BasicDrive.java).<\/li>\n<li><strong>Collapse this window (minus sign)<\/strong> &#8211; closes the Project Files area to allow more space on the screen for the code editor.<\/li>\n<\/ul>\n<p>There is also a button with a <strong>wrench<\/strong> icon in the bottom right of the screen. This is called the <strong>Build Everything<\/strong> button. While your Java programs will save automatically, they need to be &#8220;built&#8221; in order to run on the robot. So, whenever you make a change to a program, you need to press the Build Everything button so that your programs can be built and ran on the robot. Keep in mind that since this button builds <em>every<\/em> program, an error in <em>any<\/em> of your programs, even one that you aren&#8217;t using, will cause the entire build to fail.<\/p>\n<h2>Creating a New Program<\/h2>\n<p>Let&#8217;s click the Add File button to create a new program. A prompt like this should pop up:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-3130\" src=\"http:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_2-1024x502.png\" alt=\"\" width=\"478\" height=\"235\" srcset=\"https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_2-1024x502.png 1024w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_2-300x147.png 300w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_2-768x377.png 768w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_2-1536x753.png 1536w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_2-2048x1004.png 2048w, https:\/\/firstinmichigan.us\/FTC\/wp-content\/uploads\/2020\/06\/java_basics_2-425x208.png 425w\" sizes=\"auto, (max-width: 478px) 100vw, 478px\" \/><\/p>\n<p>In the <strong>File Name<\/strong> option, I named my program &#8220;BasicDrive.&#8221; It is good practice to name your programs using <strong>Pascal case<\/strong>, meaning that you don&#8217;t use any spaces and you capitalize the first letter of each word.\u00a0<\/p>\n<p>The <strong>Sample<\/strong> option allows you to choose a sample program to generate your program from. For this guide, let&#8217;s select the &#8220;BlankLinearOpMode&#8221; sample, which will generate a &#8220;bare bones&#8221; program structure for us to write code in.<\/p>\n<p>Below the Sample option is various options for the type of program. Programs that control the robot are known as <strong>OpModes<\/strong>, and there are two types of OpModes:<\/p>\n<ul>\n<li><strong>Autonomous<\/strong> &#8211; in competition, Autonomous OpModes <strong>automatically<\/strong> control robots for the first 30 seconds of the match.<\/li>\n<li><strong>TeleOp\u00a0<\/strong>&#8211; in TeleOp OpModes, drivers <strong>manually<\/strong> control the robots for the rest of the match.<\/li>\n<\/ul>\n<p>For this guide, we will select the <strong>TeleOp<\/strong> option.<\/p>\n<h2>Next Steps<\/h2>\n<p>Once you create your new program called &#8220;BasicDrive&#8221;, code should appear in the right area of your screen. Check out the <a href=\"\/FTC\/java-syntax-basics\/\">Java Syntax Basics guide<\/a> to learn the basics of Java programming and the <a href=\"\/FTC\/ftc-java-basics\">FTC Java Basics guide<\/a> to learn how this Java code works and how to start adding your own code.<\/p>","protected":false},"excerpt":{"rendered":"<p>The FIRST Robot Controller Console Once you access the web tool, you will be greeted with a screen like this: On the red bar at the top, you can select if you want to program with Blocks or OnBotJava. Since this is an OnBot Java tutorial, click on &#8220;OnBotJava&#8221;. The Editor You should now be at this screen: At the left side of the screen is the Project Files area. This is where all of the programs that you write will be stored. Above this area are various button icons: Settings (gear) &#8211; allows you to tweak specific settings of the editor Undo (circular arrow)<a class=\"more-link\" href=\"https:\/\/firstinmichigan.us\/FTC\/onbot-java-editor-basics\/\">Read More &rarr;<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"nf_dc_page":"","footnotes":""},"class_list":["entry","page","publish","author-eschnabel","post-2361"],"_links":{"self":[{"href":"https:\/\/firstinmichigan.us\/FTC\/wp-json\/wp\/v2\/pages\/2361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/firstinmichigan.us\/FTC\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/firstinmichigan.us\/FTC\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/firstinmichigan.us\/FTC\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/firstinmichigan.us\/FTC\/wp-json\/wp\/v2\/comments?post=2361"}],"version-history":[{"count":28,"href":"https:\/\/firstinmichigan.us\/FTC\/wp-json\/wp\/v2\/pages\/2361\/revisions"}],"predecessor-version":[{"id":3258,"href":"https:\/\/firstinmichigan.us\/FTC\/wp-json\/wp\/v2\/pages\/2361\/revisions\/3258"}],"wp:attachment":[{"href":"https:\/\/firstinmichigan.us\/FTC\/wp-json\/wp\/v2\/media?parent=2361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}