Home
FTC Training Manual
Contents
1. Figure 144 Change the name to MyTeleOp and hit the OK button Android Studio will create a new class called MyTeleOp that will appear in the opmodes folder in the project browser The contents of the newly created class should be the same as the contents of K9TeleOp except the name of the class should be changed to MyTeleOp If you were to try and build and run your Robot Controller app the newly created op mode would not appear in the selection list on the driver station The newly created op mode must be registered in the FtcOpModeRegister file before it will appear in the driver station s selection list File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help DHG eA y Ei gi ol ppi t gt fi ct FtcRobotController gt amp Eq ftc_app master Ez FtcRobotController mm oe main java Eq ss EJ qualcomm 2 lig Android E MyTele EY E3 FtcRobotController Hf eea a O manifests B java pack a ti FE com qualcomm ftcrobotcontroller g a impor zj E opmodes EL h AutoRotateOp ps is 5 edt la 4 ic Do Re 2 O FtcOpModeRegister E 5 okasi publi t F K9AutoTime a K9lrSeeker i v amp K9Line i h KOTankNrive P Figure 145 Double click on FtcOpModeRegister to open the file for editing FTCTraining Manual v0_93 docx Page 95 of 102 DRAFT Contents Subject to Change In Android Studio double click on the FtcOpModeRegiste
2. amount to change the arm servo position double armDelta 0 1 position of the claw servo double clawPosition amount to change the claw servo position by double clawDelta 0 1 DcMotor motorRight DcMotor motorLeft Servo claw Servo arm x x Constructor a i public K9TeleOp Code to run when the op mode is first enabled goes here see com qualcomm robotcore eventloop opmode OpMode start ny Override public void start Use the hardwareMap to get the dc motors and servos by name Note that the names of the devices must match the names used when you configured your robot and created the configuration file ad F For the demo Tetrix K9 bot we assume the following Thete ere EWO motors motor L end motor 2 motor 1 is on the right side of the bot FTCTraining Manual v0_93 docx floor element Page 100 of 102 DRAFT Contents Subject to Change i Motor 2 268 On the left side of the bot and reversed We also assume that there are two servos servo 1 and serve 6 servo 1 controls the arm Joint Of the manipulator me servo 6 controls the claw joint of the manipulator ey motorRight hardwareMap dcMotor get motor 2 motorLeft hardwareMap dcMotor get motor 1 motorLeft setDirection DcMotor Direction REVERSE arm hardwareMap servo get servo 1 claw hardwareMap servo get servo 6 assig
3. FTCTraining Manual v0_93 docx Page 57 of 102 DRAFT Contents Subject to Change 8 1 3 Driver Station Menu Towards the upper right corner of the main screen there is a set of three vertical dots Touch these dots to display a pop up menu of FTC Driver Station selections 7 E 12 09 pm ES FTC Driver Station Device Name Settings Wifi Direct Not Restart Robot About current op md Exit User 1 User 2 Figure 89 Click on the dots in the upper right hand corner to display menu options 8 1 3 1 Settings Screen If you select the Settings the FTC Driver Station Settings screen will appear can use to modify the settings for your device Tropes amp 8 12 11 pm 22 FTC Driver Station Settings GAMEPAD Gamepad type Logitech F310 Gamepad LOGGING Log Network Traffic Save network data to logs this will generate a large volume of logs WIFI DIRECT CONFIGURATION Pair with Robot Controller Change the Robot Controller this Driver Station is paired with Figure 90 The Settings screen FTCTraining Manual v0_93 docx This is the screen that you Page 58 of 102 DRAFT Contents Subject to Change Through the FTC Driver Station Settings menu you can select which type of gamepad is connected to the device Note that we recommend the use of the Logitech F310 gamepad controller with the device set in Xbox controller emulation mode i e with the switch on the bottom set to X Bef
4. E jes CESS gt ThomasEng My Documents gt develop gt x Search develop p Organize v B Open v Share with v E mail Burn New folder cma E p Open Name Type WinRAR ZIP archive Ft Favorites a E oeo es eere Bb Downloads z r m 5 Recent Places ract to ftc_app master Dropbox Move to Dropbox re Git Init Here Libraries AR jE Computer Open with gt amp Local Disk C O McAfee 3 cy HP_RECOVERY E c HP_TOOLS F Share with i G teng first Fs02 M Scan with Pria Anti Malware G Intranet first fs03 N Restore previous versions S Procedures first fs01 O Send to gt S Projects first fs01 P Ca Tee eS e AN Enh f095 7 4 a 4 Cut ftc_app master zip Date modified 6 1 2015 4 30 PM Copy WinRAR ZIP archive Size 696 KB oe Figure 121 Follow your computer s instructions for extracting the contents of the ZIP file Extract the contents of the ZIP file so that you have the uncompressed project folder om CME L gt Tomas Eng My Documents develop gt Organize v Open Include in library Share with v E mail Burn New folder B il A A Favorites Name Date modified Type BD Desktop ftc_app master 5 29 2015 11 08 AM File folder JB Downloads B ftc_app master zip 6 1 2015 4 30 PM WinRAR ZIP archive S Recent Places 3 Dropbox Libraries JE Computer amp Local Disk C cw HP_RECOVERY E cq HP_TOOLS F GP teng first
5. E com example teng myapplication androidTest mI v Eres v E drawable v EE layout k activity_main xml gt E menu E values Gradle Scripts Figure 39 The project browser can be used to browse the components that make up your project FTCTraining Manual v0_93 docx Page 29 of 102 DRAFT Contents Subject to Change When you select a project item such as a XML file or a java file through the project browser the opened file will be displayed on the right hand side of the screen For example let s consider the file named activity_main xml which is located in the project sub directory app gt res gt layout in the screenshot below When you click on activity_main xml the file should open up and appear on the right hand side of your display File Edit View Navigate Code Analyze Refactor Build Ryn Tools VCS Window Help DHJ EA XM QA gt YF apr ette ft e fnexusay fN apptheme Mainactivityy 217 a E e Ma aaag 3 1 Project gt E manifests E ee Framelayout Serer v M d bl E Ppa eng eee i LinearLayout Horizontal iii 3 LinearLayout Vertical gt E com example teng myappiication androidTest TableLayout 5 v E res F v E TableRow gt drawable A v layout GridLayout A oai H RelativeLayout activity_main fml o b EI menu BB Plain
6. MyTeleOp class into the program module Android Studio should auto save the file Make sure your Android device is connected and that USB Debugging is enabled Select Run gt Run FtcRobotController from the Run menu and install the app onto your target device Once the app has been built you should be able to load the existing configuration file When you install the app it does not overwrite the file If you were able to successfully build and install the revised app the next time you press the Select button on the Driver Station app the MyTeleOp op mode should appear FTCTraining Manual v0_93 docx Page 96 of 102 DRAFT Contents Subject to Change E 9 42 pm Select Op Mode NullOp Stop Robot MyTeleOp K9TankDrive K9Line K9TeleOp K9AutoTime K9IrSeeker Figure 148 MyTeleOp should now be available as an op mode 9 4 QualComm SDK Documentation QualComm has generated documentation for their FTC software development kit The documentation is available as a compressed archive file When you uncompress the file you find a folder that contains a series of HTML documents that describe in detail the classes and methods that are available with the QualComm SDK You can use this documentation to create your own custom robot behaviors FTCTraining Manual v0_93 docx Page 97 of 102 DRAFT Contents Subject to Change om Sh are Vi PM X cut me Je Xx p EN Open HH Selectall M Copy path E Edit 55 Selec
7. button to generate the app Choose options for your new file Creates a new blank activity with an action bar CES Activity Name MainActivity Layout Name activity_main Title MainActivity Menu Resource Name Blank Activity The name of the activity class to create Figure 34 Accept the default values and click Finish to generate your app FTCTraining Manual v0_93 docx Page 27 of 102 DRAFT Contents Subject to Change The Android Studio software will use the parameters that you specified to generate a new project Building MyApplication Gradle project info Gradle Build Figure 35 Android Studio will build the project While it is generating the project the Windows operating system might flash some warning messages about Java and or Android Studio trying to access the network You should Allow access for the Java and Android Studio applications e Windows Firewall has blocked some features of this program O Windows Firewall has blocked some features of this program Windows Firewall has blocked some features of Java TM Platform SE binary on all public private Windows Firewall has blocked some features of Android Studio Windows Launcher on all public and domain networks private and domain networks Name Java TM Platform SE binary Name Android Studio Windows Launcher Orade Corporation is Publisher Android Path C program files java jdk 1 7 0_51 bin java exe Path C
8. gt GA Intranet first fs03 N gt GP Procedures first fs01 O G Projects first fs01 P gt Gye Transfer first fs03 Q gt g i ments first fs01 R D Ciu Network 1 item Figure 65 If the proper driver is not installed your PC might assume the device is a USB media player or storage device If you are able to install the correct USB driver onto your computer then the next time you plug your Android device in with a USB cable the computer and Android studio will recognize it as an Android device and Android Studio will be able to talk to it properly The ZTE Speed driver is conveniently included on the phone itself When you first connect your ZTE speed to your computer using a USB cable you should notice a USB symbol appear near the top of the screen see figure below 9 20 am Figure 66 When connected to PC a USB icon should be visible near top of screen in orange circle FTCTraining Manual v0_93 docx Page 44 of 102 DRAFT Contents Subject to Change To display the Connect to PC activity swipe downwards from the top of the touch screen and click on the Touch for other USB options item Vv Wi Fi GPS Sound 10 10 am WED 05 27 Q Wi Fi networks available Open Wi Fi networks available Connected as a media devic Touch for other USB options USB debugging connected Touch to disable USB debugging Figure 67 Swipe downwards and select
9. 109 110 arm hardwareMap servo get servo_1 ait claw hardwareMap servo get servo_6 112 113 assign the starting posi 114 armPosition 0 2 115 clawPosition 0 2 116 bs Hey r Figure 138 Any code placed in the start method gets executed when an op mode is first enabled We can see that when the start method is executed the robot controller will look for a dcMotor called motor_2 and assign it to a variable called motorRight We also see that the robot controller will look for another dcMotor called motor_1 and assign it to a variable called motorLeft Do the names motor_1 and motor_2 look familiar to you They should since these are the names that were used when we created a configuration file for our robot see section 8 2 3 of this manual Here s an important concept to remember when you configure hardware for your robot using the FTC Robot Controller app the names you assign to the hardware devices will be used to reference these devices in your op mode code For example if you configured your robot and named a servo motor servo_gripper than in your op mode program when you want to find and modify this servo you will have to use the name servo_ gripper as a reference to the device If you accidentally told the robot controller to look for a servo named servo_ grabber then the controller would give you an error because its memory map will only have a reference to
10. 5 Driver Station Android App The driver station needs a special Android app that receives input from the gamepads and communicates with the robot controller FTCTraining Manual v0_93 docx Page 5 of 102 DRAFT Contents Subject to Change STAR EC SS Peay bee tee Dobie oe ei yates vies Cay ES ANAA T PREES took gt Lori te a i mez PL IWER ey Tiny SEs Figure 4 Driver station hardware consists of a tablet an adapter cable a USB hub and two gamepads 5 2 Robot Controller The robot controller acts as the brains of the robot It handles communications with the driver Station It processes sensor data and user commands and sends instructions to the motor and servo controllers to make the robot move For this tutorial the K9 bot is equipped with the following components 1 Android Device Preferably a phone sized smaller Android device is used as the robot controller This device will communicate wirelessly to the driver station This device will also communicate through a USB cable to the onboard robot hardware This device has its own internal battery 2 Robot Controller App The Android device runs a special robot controller app that communicates with the driver station and sends receives messages to the onboard robot hardware 3 12V Rechargeable Battery The battery provides power to a USB hub which in turn provides power to other devices such as the Legacy Module that are conn
11. B EditLegacyM 2 Jump to Source F4 EditMotorCo Find Usages Ales E7 EditSewoCor Analyze af 7 Structure Copy Path Ctrl Shift C Figure 142 Right mouse click on K9TeleOp and select Copy from the pop up menu After you have copied the file right mouse click on the opmodes folder and select Paste from the pop up menu pt File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help DHG ee P ot QA S D Ui E FtcRobotControle r P X v E com qualcomm ftcrobotcontroller v E opmodes Auto New gt Com Cut Ctrl X v FtcO ki Copy Ctrl C gt sel Copy Path Ctrl Shift C a t Copy as Plain Text 5 KIS Reference Ctrl Alt Shift C Vv K9Lir ri Bac K9Ta Kote Find Usages Alt F7 Null Find in Path Ctrl Shift F Nxt Replace in Path Ctrl Shift R aa naer Analyze 4 package Refactor gt FTCTraining Manual v0_93 docx Figure 143 Right mouse click the opmodes folder and select Paste from the pop up menu Page 94 of 102 DRAFT Contents Subject to Change Android Studio should prompt you for a new name for the new Java class that you are creating by pasting the file copy to the folder Change the New Name text box to MyTeleOp and hit OK to create a new class New name Destination package com qualcomm ftcrobotcontroller opmodes e Open copy in editor Cancel Help
12. ORACLE Click Next Steps to access tutorials API documentation developer guides release notes and more to help you get started with the JDK Figure 15 Hit the Close button to finish the installation 7 5 Installing the Android Studio Software Once you have installed the JDK software successfully you can go to the Android developer s website and download the Android Studio software http developer android com sdk index html On the Android Studio SDK website click on the green button to take you to the download webpage FTCTraining Manual v0_93 docx Page 16 of 102 DRAFT Contents Subject to Change Download Android Studic x gt C 5 developer android com sdk index htm v i Developers Design Develop Distribute QO Training API Guides Reference Tools Google Services Samples Download i The official Android IDE Installing the SDK And roid o M T m pies L SS Ath tn a Adding SDK Packages AX cay t J JIC Android Studio e Android Studio IDE Workflow e Android SDK tools Tools Help Android 5 0 Lollipop Platform A e Android 5 0 emulator system image Build System with Google APIs Support Library Revisions Download Android Studio for Windows NDK ADK e System Requirements Eclipse with ADT e Other Download Options e Migrating to Android Studio Press the green button to Siena download the Android Studio software Intelligent code editor Figure 16 Click on green button t
13. AutoRotateOp CompassCalibration FtcOpModeRegister IrSeekerOp Eo Auto Time ROlrseeker EOLine EOTankDrive E9TeleOp NullOp NxtEncoderOp NatTeleQp Figure 133 The FtcRobotController gt java gt com qualcomm ftcrobotcontroller gt opmodes folder contains the op mode files 9 3 2 FtcOpModeRegister java File Inside the opmodes folder there is a special file called FtcOpModeRegister java Note that when you browse the opmodes folder in Android Studio you will see the word FtcOpModeRegister and not FtcOpModeRegister java The java suffix is not displayed in the Project Browser Double click on the FtcOpModeRegister file in the project browser window The contents of the file should appear in the main preview text view of the screen FTCTraining Manual v0_93 docx Page 86 of 102 DRAFT Contents Subject to Change ftc_app master C Users teng Documents develop ftc_app master FtcRobotControll FtcRo File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help OHO eA A AR S dD Ui E FtRobotContole r gt MK FR SRS Se Q Ei ftc_app master C FtcRobotController gt src main E java gt EJ com gt E qualcomm gt E ftcrobotcontroller gt EJ opmodes gt C FtcOpModeRe i Android v O l FtcOpModeRegister java X E3 FtcRobotController param manager op mode manager manifests 3 java E com qualcomm ftcrobotcontroller 31 Project et public
14. If you were able to follow and complete all of the tasks that are outlined in this manual then you are ready to begin writing custom op modes for your robot You can take any of the example op modes particularly the ones that begin with the phrase K9 and use them as the basis for your own custom op mode Also you should consult the Qualcomm SDK documentation to learn what classes are available and to learn the syntax of the methods available through the SDK Thank you for participating in today s training event FTCTraining Manual v0_93 docx Page 99 of 102 DRAFT Contents Subject to Change Appendix A K9TeleOp Example Code package com qualcomm ftcrobotcontroller opmodes import com qualcomm robotcore eventloop opmode OpMode import com qualcomm robotcore hardware DcMotor import com qualcomm robotcore hardware Servo import com gqualcomm robotcore util Range TeleOp Mode KEA Enables control of the robot via the gamepad me public class K9TeleOp extends OpMode Note the configuration of the servos is such that as the arm servo approaches 0 the arm position moves up away from the Also as the claw servo approaches 0 the claw opens up drops the game ae TETRIX VALUES final static double ARM MIN RANGE Dee final static double ARM MAX RANGE 090 final static double CLAW MIN RANGE Dane final static double CLAW MAX RANGE Ou position of the arm servo double armPosition
15. Touch for other USB options To install the driver select the Install driver option from the screen gt i 8 9 20 am Connect to PC Charge only Charge yed phone via USB stall driver Select this option when features Connect to PC software Media device enabled for the first time or when they re unavailable Metta device MTP Use phone as USB Storage and transfer files when it is connected to Windows PC or Mac Camera PTP Use camera software to transfer pictures from phone to PC Enable USB debugging Don t ask me again Help Figure 68 Select the Install driver option FTCTraining Manual v0_93 docx Page 45 of 102 DRAFT Contents Subject to Change Once you select the Install driver option on the phone your PC should prompt you if you want to run the install program AutoRun exe Select the Run AutoRun exe on the PC dialog box to start the installation E Always do this for software and games Install or run program from your media General options Import photos and videos using Dropbox Open folder to view files using Windows Explorer View more AutoPlay options in Control Panel Figure 69 Select Run AutoRun exe option to start installation The install wizard should prompt you for the Setup Language Choose your language and continue with the installation Figure 70 Select language FTCTraining Manual v0_93 docx Page 46 of 102 DRAF
16. communicates through six NXT style ports to existing NXT compatible hardware motor controller servo controller LEGO approved sensors etc The Legacy Module draws power through the USB connection from the Power Module DC Motor Controller with Motors The K9 bot has a single DC motor controller The USB enabled DC Motor Controller communicates with the Android device through a USB connection The USB enabled motor controller also draws 12V power from the Power Module to power the DC motors Servo Controller with Servos The K9 bot has a single servo controller The USB enabled Servo Controller communicates with the Android device through a USB connection The USB enabled servo controller also draws 12V power from the Power Module to power the servos Hitechnic IR Seeker V2 Sensor The K9 bot has an NXT compatible IR seeker sensor The sensor is connected to the Legacy Module The Android device communicates through the Legacy Module to the sensor The sensor draws power from the Legacy Module LEGO Light Sensor The K9 bot has an NXT compatible IR seeker sensor The sensor is connected to the Legacy Module The Android device communicates through the Legacy Module to the sensor The sensor draws power from the Legacy Module NXT Cables The K9 bot uses standard LEGO NXT compatible cables to connect the Legacy Module with the sensors Legacy Module Android Device Power Module DC Motor Controller X Ae
17. i o ZTE N9130 Android 4 4 4 AFI 19 Ro Debuggable Applications if a e r i i 2i atk logcat ADB logs A Memory iki CPU gt Q7 app com qualcomm ftcrobot a i l ez X 2 Favorites TODO 6 Android E Terminal E Unregistered VCS root detected The directory C Users teng AndroidStudioProjects ftc_sdk is under Git but is not registered in the Settings Figure 75 Device should be visible in the Android panel of Android Studio Once you have installed your driver successfully you are ready to build and install your first app 7 8 5 A Note about Emulators If you do not have access to an Android app you can run apps onto a virtual Android device that behaves like a real Android device but runs on your computer instead For the FIRST Tech Challenge programming we need to run our apps on real Android devices because the device must interface with other hardware devices Legacy Module motor and servo controllers etc We will not cover the use of Emulators in this manual but if you would like to use an emulator to learn how to develop apps you can consult the Google developer website http developer android com tools devices emulator htm Please note that using an Android emulator typically requires special graphics hardware accelerators to run properly Your computer might not be equipped with the correct hardware to be able to run an emulator properly For all of the exercises
18. program files android android studio bin studio64 exe Allow Java TM Platform SE binary to communicate on these networks Allow Android Studio Windows Launcher to communicate on these networks V Domain networks such as a workplace network V Domain networks such as a workplace network F Private networks such as my home or work network E Private networks such as my home or work network F Public networks such as those in airports and coffee shops not recommended F Public networks such as those in airports and coffee shops not recommended because these networks often have little or no security because these networks often have little or no security What are the risks of allowing a program through a firewall What are the risks of allowing a program through a firewall Figure 36 You should allow access to your networks for Java and Android Studio Once the project has been successfully created you should see the Android Studio Tip of the Day screen You can close this window and also uncheck the Show Tips on Startup option if you do not want to see any more tips WA Tip of the Day EY Did you know Welcome to Android Studio 1 0 1 You can quickly get familiar with the main features of the IDE by reading these tips You may try out the features described in the tips while this dialog stays open on the screen If you close the dialog you can always get back to it from the Help Tip of the
19. 3 stop When the robot controller receives a stop command from the driver station or when an emergency stop condition occurs the code in the stop method gets executed If you have any cleaning up to do after an op mode run has been completed this is the place to put the cleanup code for your op mode Note that the programming model that is described in this section is different from the linear programming model that is used to program a LEGO NXT with a tool like RobotC The op modes that are described in this section utilize an event driven programming model rather than a inear programming model With a linear programming model commands are executed sequentially one after the other The programming model used by the op modes is a little different With the event driven programming model the loop method will get executed repeatedly until the op mode run is terminated This programming model is similar to how a device like an Arduino is programmed FTCTraining Manual v0_93 docx Page 89 of 102 DRAFT Contents Subject to Change 9 3 3 1 The start Method Let s take a look at the start method of the K9TeleOp op mode see Figure 138 86 0verride 87 f public void start 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 motorRight hardwareMap dcMotor get motor_2 107 motorLeft hardwareMap dcMotor get motor_1 108 motorLeft setDirection DcMotor Direction REVERSE
20. 43 am Wi Fi D LA Please select a W FTC5thFloor Secured with WPA2 WPS available DIRECT MA Josh Nex Secured with WPA2 WPS available FIRST_McAuliffe Secured with WPA2 SEEPublic Open FIRST 5 South Secured with WPA2 iGlobe Secured with WPA2 3 aE Figure 53 You can connect to a WiFi network at this point or skip this step hit Next FTCTraining Manual v0_93 docx Page 36 of 102 DRAFT Contents Subject to Change E EEEE UICC Error The UICC inserted in the device may be installed incorrectly an invalid card or is faulty Please try again Figure 54 You might see this message indicating that the SIM card was not detected Hit OK to continue E 9 43 am Cada Hands Free Activation Configuring your device for voice 4 and data Please wait Emergency call Figure 55 The phone will display a Hands Free Activation screen FTCTraining Manual v0_93 docx Page 37 of 102 DRAFT Contents Subject to Change 9 2 EEEE i Hands Free Activation Waiting for retry If you are not already working with a representative select Activate now Retry 1 of 5 4 60 Activate Emergency call Figure 56 The phone will try to activate itself Hit the Activate button to continue roN 9 0 i amp 9 43 am yT Self Service Information Sorry we experienced a system problem during your task Please dial 611 from your phone or call 1 866 402 7366 from a differ
21. 99 Select Configure Robot from the settings menu Select the Configure Robot option from the settings menu to create a new hardware profile This should launch the Configure Robot activity We will use this activity to scan for attached hardware devices Make sure your robot is powered on the switch on the Power Module should be the main on off switch for the robot before you connect your Android device to the Power Module Go to the Configure Robot screen and press the Scan button to scan for attached hardware devices iia wf e A 2 20 pm 2 Configure Robot Scan Press this button to scan for attached devices Devices i No devices found In order to find devices 1 Attach a robot 2 Press the Scan button Save Configuration o Press this button to write the current configuration to an XML file Figure 100 The Configure Robot activity is used to scan for and configure attached devices FTCTraining Manual v0_93 docx Page 65 of 102 DRAFT Contents Subject to Change After you have pushed the Scan button the app should detect any hardware modules connected to the device through the Power Module 2am F B 2 41 pm a Configure Robot Scan Press this button to scan for attached devices Devices o Motor Controller 1 Servo Controller 3 Legacy Module 2 Save Configuration o Press this button to write the current configuration to an XML file Figure 101 Scan should auto
22. AY Servo Controller Sy gt 12V Battery Figure 5 K9 bot hardware with USB enabled motor servo controllers cables and adapter not shown in detail FTCTraining Manual v0_93 docx Page 7 of 102 DRAFT Contents Subject to Change 5 3 A Note about USB Ports amp Cables The next gen platform uses USB which stands for Universal Serial Bus to connect the Android devices to the robot and game controller hardware The USB cables allow the devices to communicate at a very high speed The USB cables also provide power to the devices that are downstream to the Power Module 5 3 1 USB Host amp Client Modes A USB enabled device such as a smartphone or tablet can act as a USB host or as a USB client device A USB host is the device that initiates all communications on the bus The USB client responds to communications from the host The Android devices that are used for the next gen platform have the ability to act as either a USB host or a USB client When you plug the Android device into a laptop the Android device acts as a USB client When you plug a gamepad into the Android device the Android device acts as a USB host The term USB On the Go or USB OTG is used to describe a device s ability to switch between host and client modes Note that when an Android device is acting as a USB host it cannot simultaneously be charged This means that when you have your Android tablet connected to the Logitech gamepads or wh
23. K9IrsSeeker class Manager register K9AutoTime KS9AutolTime class Figure 135 This code adds NullOp K9TeleOp and other op modes to the register What this Java code is doing is creating a register i e a list of op modes that we would like to make available to the driver station for selection and execution In the example code of Figure 135 there are six op modes that are being registered These op modes NullOp K9TeleOp K9TankDrive K9Line K9IrSeeker and K9AutoTime will all be available to select from the list of op modes on the FTC Driver Station If you would like to make an op mode available to the driver station you must first register it here The following statement registers an op mode K9TeleOp and gives it a name of K9TeleOp for the registry Manager register K9TeleOp K9TeleOp class 9 3 3 Op Mode Life Cycle Let s take a look at what the source code file for a typical op mode looks like FTCTraining Manual v0_93 docx Page 87 of 102 DRAFT Contents Subject to Change File Edit View Navigate Code Analyze Refactor Bt DHG eA Xfm Aaa eds a ftc_app master 3 FtcRobotController src gt D t ti Android c Fte 2 y a FtcRobotController i gt D manifests l v O java v E com qualcomm ftcrobotcontrol vy opmodes Structure b AutoRotateOp CompassCalibration h FtcOpModeRegister amp IrSeekerOp K9AutoTime
24. This is to make it easier to drive the robot more precisely at slower speeds Hy double scaleInput double dVal double scaleArray 0 0 0 05 0 09 0 10 0 12 0 15 0 18 0 24 Deok Usah Odo O50 GeO Vere Gsp 100 22 00 get the corresponding index for the scaleInput array int index int dVal 16 0 if index lt 0 index index else if index gt 16 index 16 double dScale 0 0 if dVal lt 0 dScale scaleArray index else dScale scaleArray index return dScale Page 102 of 102
25. claw if gamepadl x clawPosition clawDelta FTCTraining Manual v0_93 docx Page 101 of 102 DRAFT Contents Subject to Change FTCTraining Manual v0_93 docx if gamepadl b clawPosition clawDelta clip the position values so that they never exceed their allowed range armPosition Range clip armPosition ARM MIN RANGE ARM MAX RANGE clawPosition Range clip clawPosition CLAW MIN RANGE CLAW MAX RANGE write position values to the wrist and claw servo arm setPosition armPosition claw setPosition clawPosition j Send telemetry data back to driver station Note that if we are using a legacy NXT compatible motor controller then the getPower method will return a null value The legacy NXT compatible motor controllers are currently write only mp ee oe eee kkk Robot Data telemetry addData arm arm String format 2 armPosition talonatey addvsts Clelaw Claw String format 2 clawPosition telemetry addData left tgt pwr left pwr String format 2 left telemetry addData right tgt pwr right pwr String format 2 right Code to run when the op mode is first disabled goes here see com qualcomm robotcore eventloop opmode OpMode stop gi Override public void stop This method scales the joystick input so for low joystick values the scaled value is less than linear
26. designed for repeated connect and disconnect cycles These are the same style of USB receptacle found on high end digital SLR cameras 12345 Mini B Figure 8 USB Micro B receptacle The Legacy and Power Module s Mini B receptacle requires a USB Mini Type B style cable Figure 9 USB Micro B cable on January 15 2015 FTCTraining Manual v0_93 docx Page 10 of 102 DRAFT Contents Subject to Change 5 3 4 Micro USB OTG Adapter A special adapter cable is used to connect the Android device to the Power Module or to the USB hub This Micro USB OTG Adapter cable has a male USB Micro B connector on one end and a female standard USB Type A receptacle on the other end Figure 10 USB Micro OTG Adapter Cable When used with the driver station the USB hub is connected to the Android tablet through the Micro OTG adapter cable When used with the robot controller the Power Module is connected to the smartphone through the Micro OTG adapter cable Image from http www monoprice com Product c id 108 amp cp id 10833 amp cs id 1083314 amp p id 9724 amp seq 1 amp format 2 accessed on January 15 2015 FTCTraining Manual v0_93 docx Page 11 of 102 DRAFT Contents Subject to Change 6 The Android Operating System 6 1 Whatis Android The next gen platform uses a tablet and a smartphone to control a robot The tablet and smartphone are actually sophisticated compact computers These handheld computers have a ce
27. detect the attached modules In Figure 101 the app detected three USB modules a motor controller a servo controller and a legacy module The app has the ability to auto detect the USB hardware modules but you still need to configure each module and tell the robot controller what devices are connected to each module Legacy Module Android Device Power Module DC Motor Controller im Servo Controller Sy Figure 102 This diagram shows how the devices are connected on the typical K9 bot SSN SX FTCTraining Manual v0_93 docx Page 66 of 102 DRAFT Contents Subject to Change Let s take a look at Motor Controller 1 For this training manual we assume that Motor Controller 1 has two DC motors connected to ports 1 and 2 on the motor controller If we touch Motor Controller 1 on the screen a new screen will appear which will allow us to specify which motor ports are active and what names we will use to refer to each port In Figure 103 see below the motor controller has two motor channels active 1 and 2 The names of each channel are motor_1 and motor_2 respectively Note that the names you assign for devices including motors servos sensors and even the hardware module itself are important because later on when you want to write a custom op mode to control your robot you will need to refer to these names within your program in order to access these devices on your ro
28. device Note that you only need to modify the Robot Controller app to program custom behaviors for your robot The Driver Station app typically does not change and teams will download it from Google Play onto their driver station FTCTraining Manual v0_93 docx Page 82 of 102 DRAFT Contents Subject to Change Before you build the Robot Controller app make sure your ZTE Speed phone is in USB Debugging mode Connect the ZTE Speed to the computer with a USB cable If the ZTE Speed prompts you to allow USB Debugging hit OK to allow it After you have selected the FtcRobotController configuration select Run gt Run FtcRobotController from the menu at the top of the screen This will initiate the build process ftc app master CAUsers File Edit View Navigate Code Analyze Refactor Build GOGE Tools VCS Window Help peas IPERS A be Ve maa bHO 400 09 9 gt a se 2 8 G ftc_app master Gradle Scripts ed 3 Structure Captures Build Variants J 2 Favorites 06 02 09 31 22 148 06 02 09 31 22 148 m ZTE N9130 Android 4 4 4 API19 Bg 3059 3059 2 EF 3059 3059 F TODO 6 Androic E Run selected configuration Terminal 0 Messages a Debug FtcRobotController K Run FtcRobotController with Coverage P Run ak Debug E Edit Configurations u l id fe jel jel wy My Force Run to Cursor X3 Hl Pause Program P Resume Progra
29. driver station sends a stop command to the robot controller Figure 119 Run the K9TeleOp op mode to drive your test bot FTCTraining Manual v0_93 docx Page 77 of 102 DRAFT Contents Subject to Change 9 The QualComm FTC Robot SDK Now that you ve seen how to use the Robot Controller app let s learn about how the app is made The Robot Controller app was built using a software development kit or SDK that was created by Qualcomm specifically for the FIRST Tech Challenge competition The QualComm SDK includes the libraries that are needed to communicate with the robot hardware such as the Modern Robotics Legacy Module or the DC Motor and Servo controllers The SDK also includes the source code and resource files that define the look and behavior of the Robot Controller app In order to write op modes that will define custom behavior for your robot you will need to install a copy of the Qualcomm SDK onto your computer and learn how to modify the op mode program modules 9 1 Accessing the SDK on GitHub The FTC is available for download on GitHub The FTC SDK repository is currently located at the following URL https github com ftctechnh ftc a If you have a GitHub account you and you know how to use git a version control tool you can clone the repository to your local computer as you would do for any other GitHub repository gt La x C ftctechnh ftc_app x 4 gt C GitHub inc us ht
30. get acknowledged by the robot as well as other status and wireless connection info 8 11 57am A FTC Driver Station z Device Name Wifi Direct Not Paired Network and status info displayed in this area current op mode Teams can select execute and monitor op modes using these controls Telemetry data sent from the robot is displayed in this area User 1 User 2 Gamepad info for drivers 1 and 2 are displayed in this area Figure 88 Main screen for FTC Driver Station Towards the middle of the screen there are buttons that you can use to select the operational mode or op mode of the robot Op modes are pre programmed robot behaviors autonomous and driver controlled that you can launch from the driver station In Figure 88 the buttons are greyed out because the driver station has not yet connected to a robot Below the Op Mode controls is an area on the screen where telemetry data is displayed The new platform has the ability to send information from the robot to the driver station This information such as servo position motor power sensor data etc can be displayed on the driver station Towards the bottom of the screen there is an area that is used to display information about the gamepads that are connected to the Android device The left side of the area is used to display information about User 1 i e driver 1 The right side of the area is used to display information about User 2 i e driver 2
31. i e m a activity_mainxml O lt RelativeLayout gt 5 gt E menu a vu gt E values amp o ei 107 a w Q o gt Gradle Scripts Android DDMS w L Gradle Console l io J 2 Favorites Build Variants Figure 43 Click on the Text tab near the bottom of the screen to see the text version of the XML file Believe it or not our simple test program is just about done For this exercise we are only going to have a simple blank app that reads Hello world on it You might have already noticed this text in the design Devices logcat ADB logs rbose 7 app com example teng myapplication EJ P tm Devices Ei ToDo amp Android Terminal E Event Log Gradle Console a Memory Monitor preview in Figure 42 or Figure 43 Before we can build and install our app we will first need to prepare our machine to connect to a real 1 3 CRLF Android device We will learn how to do this in the next section of this manual FTCTraining Manual v0 _93 docx UTF 8 w 8 Page 31 of 102 DRAFT Contents Subject to Change 7 8 Connecting Android Studio to a Real Device We are just about ready to install our simple test app onto a real Android device Before we can do this we need to first make sure that our Android device has the Developer Options and USB Debugging enabled We also have to make sure that our Win
32. in this manual we recommend using a real Android device preferably the ZTE Speed smartphone instead of an emulator 7 9 Compiling and Installing an App If you have successfully installed the USB driver and enabled USB Debugging mode on your phone then you are ready to reconnect the phone and compile and install an app onto the device The first thing to do is to unplug your phone wait for a few seconds 5 then reconnect your phone to the computer with the USB cable When you do this the Android device might ask you if it is OK to FTCTraining Manual v0_93 docx Page 49 of 102 DRAFT Contents Subject to Change allow USB debugging with the attached computer Select the OK button to allow USB debugging Note that if you would like to disable this prompt you can check the Always allow from this computer option before you select OK on the screen prompt The computer s RSA key fingerprint is 1A E8 FF B4 94 90 4C 03 D9 38 84 63 D0 58 4C 66 Always allow from this computer Figure 76 Your Android device might ask you if it is OK to allow USB debugging Afer you have reconnected your phone return to the Android Studio screen Go to the Run menu and select Run gt Run app where app is the name of the application folder that you would like to build Android Studio should start to build the app for you FTCTraining Manual v0_93 docx Page 50 of 102 DRAFT Contents Subject to Change File Edit Vi
33. launches Figure 130 When Android Studio is done building the app it will ask you to select a target device for the app After you hit the OK button Android Studio will attempt to install the FtcRobotController app onto the ZTE Speed phone When this happens you might get a warning message from Android Studio indicating that it detected that the device already has an application with the same package but different signature If you encounter this message simply press OK to allow Android Studio to uninstall the old app from the phone and to replace it with your newly compiled version of the app Installation failed since the device already has an application with the same package but a different signature In order to proceed you have to uninstall the existing application WARNING Uninstalling will remove the application data Do you want to uninstall the existing application Figure 131 You might get a warning indicating from Android Studio that the target device already has a copy of the application installed but with a different signature Hit OK to uninstall the app and replace it with your copy of the app Once Android Studio has successfully installed the app onto your phone the Gradle Console should display the words BUILD SUCCESSFUL indicating that the app was built and installed onto the target device Congratulations you have just built your first FTC related app FTCTraining Manual v0_93 docx Page 84 o
34. left and right joysticks plus the button presses and the status of the trigger will be displayed If the gamepad that represents driver 2 is active then the lower right hand corner of the screen will be highlighted blue The gamepad status information for that driver will be displayed on the lower right hand area of the screen Remember before you can use a gamepad you need to tell the Driver Station which driver that gamepad represents FTCTraining Manual v0_93 docx Page 60 of 102 DRAFT Contents Subject to Change o amp B 12 40 pm F FTC Driver Station Device Name Wifi Direct Not Paired current op mode User 1 User 2 Gamepad type F310 Ix 0 00 ly 0 00 rx 0 00 ry 0 00 It 0 00 rt 0 00 b start Figure 93 Driver 1 gamepad info is on left 2 is on right Note that for the joysticks on the gamepads the values range from 1 to 1 For the x axis 1 represents the far left range of motion and 1 represents the far right range For the y axis 1 represents the topmost position and 1 represents the bottommost position 8 1 5 Op Mode Controls The center of the FTC Driver Station main screen contains controls that can be used to select an operation mode or op mode of a robot Op modes are preprogrammed robot behaviors that you can select and execute from the driver station The Select button will display a list of available op modes that can run on your robot The Start button is used to start th
35. method which is a member of an object called telemetry lets the user send text data back to the robot controller The first argument of the addData method is a string that acts as a key or index for the piece data The second argument is the actual data or message FTCTraining Manual v0_93 docx Page 91 of 102 DRAFT Contents Subject to Change These telemetry messages will be underneath the op mode controls of the FTC Driver Station app The telemetry messages are refreshed regularly as the op mode continues to run Device Name F FTC Driver Station ZTE 029 Wifi Direct Connected to ZTE 030 Ping 2ms RobotController battery level 70 0 Robot Battery Level 12 76 current op mode K9TeleOp Select Stop k Robot Data arm 0 20 claw 0 20 Telemetry data appears here left pwr 0 00 right pwr 0 00 User 1 User 2 Gamepad type F310 Ix 0 00 ly 0 00 rx 0 00 ry 0 00 It 0 00 rt 0 00 Figure 140 Telemetry data gets refreshed regularly while the op mode is running FTCTraining Manual v0_93 docx Page 92 of 102 DRAFT Contents Subject to Change 9 3 3 4 The stop Method When the robot controller receives a stop command or if it has to stop due to an emergency stop condition the stop method of the op mode will be run For the K9TeleOp example the stop method is empty You do not need to write code to turn off the motors or servos when a stop command is received The Robot Contro
36. previous version of Android Studio or I do not want to import my settings Figure 23 Android Studio might prompt you to import previous settings Once Android Studio has finished downloading and installing the additional software components click the Finish button to continue FTCTraining Manual v0_93 docx Page 20 of 102 DRAFT Contents Subject to Change Setup Wizard Downloading Components KR Android Studio Android SDK was installed to C Users teng AppData Local Android sdk Refresh Sources Fetched Add ons List successfully Refresh Sources Installing Archives Preparing to install archives Installing Android SDK Tools revision 24 0 2 Installed Android SDK Tools revision 24 0 2 Installing Android Support Repository revision 11 Installed Android Support Repository revision 11 Done 2 packages installed Android SDK is up to date Creating Android virtual device Android virtual device Nexus_5 API 21 x86 was successfully created Figure 24 Click on the Finish button to continue 7 6 Android SDK Manager The Android Studio software lets you launch an application known as the Android SDK Manager The Android SDK Manager can be used to install SDK components and tools that you might need to build your app You can launch the SDK Manager from the Welcome screen of Android Studio Select Configure from the Welcome screen to open a configuration menu D Welcome to Android Studio Recent Projects Qu
37. string hello_world Properties layout height style accessibilityLiveRegion alpha background backgroundTint backgroundTintMode clickable O rnantantMNarerintima match_parent L Gradle Console ose E app com example teng myapplication BA E ee Figure 42 Android has a WYSIWYG design editor that lets you drag widgets onto the activity screen By clicking on the Text tab towards the bottom of the screen Android Studio lets you also edit the layout of your activity with a text editor Od LAA aA gt EH lar PhP Hh YH 3 MyApplication E3 app gt src main PS res layout K activi i I Geinacti i 3B t 1 Android ae Preview gt l eS glv Caapp 5 lt RblativeLayout xmins android http schemas android com apk res androi BpNeus4 E appmeme manawiy O a E Al gt manifests xmlns tools http schemas android com tools android layout_width 3 H a jija android layout_height match parent android paddingLeft 16dp Bea QQ Gm amp P v E com example teng myapplicatio saroia pantag ne 2 5 amp MainActivi android paddingTop 16dp 5 E mAy android paddingBottom 16dp tools context MainActivity gt S fz gt E com example teng myapplication androidTest 3 bs v Cares lt TextView android text Hello world android layout_width wrap con v gt drawable android layout_height wrap_content gt v layout
38. their respective machines Your Driver Station should display its WiFi direct status In the screen shots below the driver station and the robot controller are not yet paired together 10 13 am Mi USB debugging connected EA FTC Driver Station EA FTC Robot Controller Device Name Device Name ZTE 030 Wifi Direct Not Paired Wifi Direct enabled Robot Status running current op mode Figure 109 The driver station and robot controller have not yet been paired together The pairing process is initiated through the driver station app To start the pairing process touch the three vertical dots on the upper right hand corner of the FTC Driver Station app and then select Settings from the pop up menu Y Connected as a media device a FTC Driver Station Device Name ER Settings Wifi Direct Not Restart Robot About current op ma ir Figure 110 Touch the three dots and select Settings from the pop up menu FTCTraining Manual v0_93 docx Page 71 of 102 DRAFT Contents Subject to Change Once you have launched the FTC Driver Station Settings menu press the Pair with Robot Controller option to start the pairing process le Saving screenshot 3 FTC Driver Station Settings GAMEPAD Gamepad type Logitech F310 Gamepad LOGGING Log Network Traffic Save network data to logs this will generate a large volume of logs WIFI DIR RATJON Pair with Ro
39. v0_93 docx Page 76 of 102 DRAFT Contents Subject to Change the robot to the driver station This information is displayed in the area below the Op Mode controls on the Driver Station app This telemetry feature is useful for getting remote information from the robot We will learn how to send telemetry data to the driver station when we write our own op mode program modules At the bottom of the screen gamepad activity and state information are displayed Remember you have to hit the Start button and the A key on the gamepad to assume the role of User 1 or the Start button and the B key to assume the role of User 2 If you were able to run K9TeleOp properly drive the robot around for a bit and play with the controls K9TeleOp only uses one gamepad User 1 The left joystick on the gamepad controls the drive train The yellow Y button raises the manipulator arm The green A button lowers the arm The blue X button closes the gripper The red B button opens the gripper Once you have had a chance to drive the robot around and test the controls hit the Stop button to stop the op mode run Running a timed op mode is very similar to running a regular op mode However instead of pushing the Start button you simply press the Start w Timer button The op mode will begin running and a countdown timer will appear next to the word Stop on the stop button When the timer gets to zero the
40. void register OpModeManager manager spalolg UALJN 3 E opmodes h AutoRotateOp Or CompassCalibration h FtcOpModeRegister Or IrSeekerOp K9AutoTime b K9lrSeeker manager register NullOp Null0p class C K9Line manager register K9TeleOp K9Tele0p class K9TankDrive Manager register K9TankDrive K9TankDrive class K9TeleOp rr ees K9Line class r NullOp mnoge E aea aer ter Can pes manager register K9AutoTime K9AutoTime class b NxtEncoderOp NxtTeleOp i package info java AboutActivity Ox AutoConfigureActivity ConfigWifiDirectActivity EditLegacyModuleControllerActivity ed 7 Structure apea Gy Build Variants Captures Jb 2 Favorites M h EditMotarCantrollerActinite i P 4 Run SSTODO 6 Android Terminal 0 Messages 1 Eventlog E Gradle Console C Session FtcRobotController running 19 minutes ago 40 14 LF windows 1252 gt amp Figure 134 FtcOpModeRegister contains a list of op modes that the robot controller will share with the driver station Let s take a close look at the FtcOpModeRegister file If you look at the FtcOpModRegister Java code you will see the following lines of code manager register NullOp NullOp class Manager register K93TeleOp KSTeleOp class Manager register K9TankEDrive K9TankDrive class manager register K9Line K9Line class manager register K9IrSeeker
41. 250 Check for updates now Figure 124 Select Import Non Android Studio project from the Quick Start menu It might take Android Studio a while for it to generate a directory structure that you can browse to look for your project file Browse the directory to look for the Qualcomm SDK and select it then click on the OK button to import the project into Android Studio FTCTraining Manual v0_93 docx Page 80 of 102 DRAFT Contents Subject to Change Select Eclipse or Gradle Project to Impor Select your Eclipse project folder build gradle or settings gradle AT aARx OO E Hide path C Users teng Documents develop ftc_app master Y O Documents D Box Sync gt O CAD Drawings Fo Code v develop E ftc_app master zip FO FIC Archive gt LabVIEW Data b D LEGO Creations gt My Kindle Content E My Shapes gt NetBeansProjects D Personal FS Reference H Fo repos i Mi n Drag and drop a file into the space above to quickly locate it in the tree Figure 125 Find the QualComm SDK project folder and select it Hit OK to begin importing the project Android Studio will display a progress bar and begin to import the Qualcomm SDK project folder Building ftc_app master Gradle project info Gradle Build Figure 126 Android Studio will begin to import the project Once you Android Studio has completed the import process your Android Studio window might look like the following screenshot
42. AN eai E E ee re eee 13 T Wae Anaro S NO E went err e et enn eee 14 T Important Note Regarding the Android Studio Instructions ccccccssseccceesecceeeeeceeceeseceseeneess 14 7 2 Android Studio W CDSITE coassssccavecavs consis n N A 14 7 3 System Regu ements xriisacsusec nities sir a E TE NEN 14 7 4 Installing the Java Development Kit cccccccessccccessececeesececceeceeseesececeueceseeaecesseeecetsusecetseneess 14 7 5 Installing the Android Studio SOftWALE cccsscsesssssressonssscucnssscnecssressoussectenssscneusrensousressensnss 16 7 6 ANOrod SDK MANIEE ganna nee neS 21 7 7 BUNE OU FI TAD E E cess nator 25 7 8 Connecting Android Studio to a Real Device ssessssssssesesrersssrrresrrressrrresrrerssreresereresrereserreesrerese 32 7 8 1 Removing the SIM card from the ZTE Speed cccccccesseccccessececeeseceesenecceeesceeesesecessuneees 32 7 8 2 Enabling Developer Options on your Android Device ssssessssssssesrrseressrrreerrrerrresrreereeseees 40 7 8 3 Enabling USB Debugging cccccccsssecccceseccccesececsesececeueceeeenseceseusecesseneceesegeceessnecetsenesss 42 7 8 4 Installing the USB Driver for your D VICE cccccessecccceseceecesececeusececeeneceeseeueceseusecessuneess 43 7 8 5 A Note AD OUT EMULATOR EE vices 49 FTCTraining Manual v0_93 docx Page 1 of 102 DRAFT Contents Subject to Change 7 9 Compiling and Installing an App ssesssessseesessensssresssrresssreresrresssrereseress
43. DRAFT COPY CONTENTS SUBJECT TO CHANGE FTC Training Manual JAVA Programming for the Next Gen Controller Thomas Eng 5 25 2015 FTG FIRST Tech Challenge This document contains training material to introduce students and mentors to the next gen FIRST Tech Challenge robot controller platform DRAFT Contents Subject to Change Contents WIA ON E E saeen cinerea etc sects E E eeeseasiecee E E 3 Bo NN cea arses ss ee see ss ce ace rsa sc tne voc ewe cana oc we nis so geacea unaeane danniSesenoeoraecesasnesstacava et N 3 MEMES 10 1289 WN 1 2 ol gt meee ne ene are Crier E rer een eer eee 3 re 210710900 0 6 sare een eee eee ee er eee ree E re eT eee 4 5 Overview of the Next Gen PlatfOrim cccccsessccccccccssesssseecccceesseeesseeceeceessueesseeeceeeesseaeeeeeeeesesaageaseeeeeess 5 5 1 FIVER SU AION ereer nne A a E E AE EEE 5 5 2 RODOCCONTTOCI soara AE E 6 5 3 A Note about USB Ports amp Cables n sssssssserressssssserressssssrerreesssssseereesssssseeereesssssseereesssssseereeee 8 5 3 1 USB Host amp Client MOROS scrios EE O 8 5 3 2 VS VANCES TYDE Bosasin Ta T T T T 8 5 3 3 LS VANE TYDE D oe E E N E E E EA 10 5 3 4 Micro USB OTG Adapte ccecsscdeererevssccesscsdobdarcasarseedaeutsecseessunddieatieseriecsasseeeadesosentaseetiebdertoasans 11 6 TheAndroid Operating Syste essorer A A 12 6 1 WA EA N O E TAA OE EN A EE AE 12 6 2 ARTO UO e E AEE E E S 13 6 3 MIT Google APP IVC O aerieni iE EOE E 13 6 4 T
44. Day main menu item V Show Tips on Startup Figure 37 Android Studio has a Tip of the Day screen If you were able to install Android Studio and the JDK successfully you should see an Android Studio screen for your newly created project FTCTraining Manual v0_93 docx Page 28 of 102 DRAFT Contents Subject to Change My Application ir jects MyApplication app app src main res la File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help DO H SMM AAS DI HEJP Mh YR SERS S Q 3 MyApplication gt app gt src main gt SS res gt layout gt activity_mainxml gt a E activity_main xml x 3 v Ea pa Palette t A Neuss j aApptheme mMainativiy 21 Component Tree 74 A b ifests a a ot t K E g a T 7 FIM E Device Screen ma FrameLayout y H Relativelayout 3 v Eres _ g 5 M LinearLayout Horizontal Ab TextView string hello_world E E gt drawable j a BD ha H LinearLayout Vertical 5 v layout ki i E TableLayout e act vity_main xm A TableR v gt E menu BENA 5 gt Eval EA GridLayout er ee iti RelativeLayout radle Scripts iat S Ab Plain TextView Bb Large Text a Ab Medium Text ae Ab Small Text Properties 3 OK Button oe Small Button layout height match_parent RadioButton G style CheckBox u Switch accessibilityLiveRegion 2 ToggleButton alpha
45. E BE Google Play Licensing Library 2 Not installed E amp Android Auto AP Simulators 1 Not installed 7 E Google USB Driver 11 Not installed E g Google Web Driver 2 Not installed A Intel x86 Emulator Accelerator HAXM installer 52 Installed Show V Updates New V Installed Select New or Updates Obsolete Show Updates and New pi Done loading packages Figure 28 In this image the USB Driver is not yet installed After you have selected which components you would like to install uninstall click on the install button then accept the user license agreements to begin the download and installation process FTCTraining Manual v0_93 docx Page 23 of 102 DRAFT Contents Subject to Change of Android SDK License of Android TV ARM EABI v7a System Imi a f Android TV Intel x86 Atom System Im of Android Wear ARM EABI v7a System I Android Wear Intel x86 Atom System of ARM EABI v7a System Image Androic f Intel x86 Atom_64 System Image And af Intel x86 Atom System Image Androi of Android Support Library revision 21 0 f Google USB Driver revision 11 Package Description amp License Packages a Android TV ARM EABI v7a System Image Android API 21 revisionl Android TV Intel x86 Atom System Image Android API 21 revisionl Android Wear ARM EABI v7a System Image Android API 21 revision 1 Android Wear Intel x86 Atom System Image Android API 21 revision 1 ARM EABI v7a System
46. E ImageButton background o amp E ImageView backgroundTint Ail p Bar L as ee backgroundTintMode ProgressBar Normal 2 ProgressBar Small clickable O 5 ProgressBar Horizontal contentDescription 5 SeekBar elevation E We RatingBar focusable o Gradle build finished in 1 min 4 sec Design Tet Terminal 0 Messages i 6 Android TODO Event Log E Gradle Console ba Memory Monitor E Gradle build finished in 1 min 4 sec a minute ago Indexing n a nya Figure 38 If you successfully create a project your screen should look something like this Take a look at the screen shot in Figure 38 At the top of the screen there is a set of menus similar to the menus you might find on any other Windows application You can use these menus to get information about your project or adjust settings for your project or Android Studio environment On the left hand side of the screen you can see a project browser This project browser is similar to the Windows File Explorer You can use the project browser to browse through the components of your Android project You can click on the project components to expand or collapse them i e show more or less information about that component File Edit View Navigate Code Analyze Refactor Build OHO x 0 ol gt i 3 MyApplication 3 app gt src gt main gt java t l E m v O java v E com example teng myapplication F MainActivity 5
47. Image Android API 21 revision 1 Intel x86 Atom_64 System Image Android API 21 revision 1 Intel x86 Atom System Image Android API 21 revision 1 Android Support Library revision 21 0 3 Google USB Driver revision 11 License To get started with the Android SDK you must agree to the following terms and conditions This is the Android SDK License Agreement the License Agreement Accept Reject Copy to clipboard Print Figure 29 Accept the license agreements to download and install the components Once you have completed installing the SDK components and extra tools you can close the Android SDK Manager Note that it might take a long time for the SDK Manager to download and install the components so please be patient while it does so FTCTraining Manual v0_93 docx Page 24 of 102 DRAFT Contents Subject to Change 7 7 Building your First App Once you have installed the SDK components that you would like for your computer you can close the SDK manager and start programming your first app On the Android Studio Welcome screen you should see an option to Start a new Android Studio Project in the Quick Start menu Click on this option to Start a new project Android Studio Seup W E beai a a A Welcome to Android Studio Recent Projects Quick Start Open an existing Android Studio project Import an Android code sample Check out project from Version Control Import Non Android Studio projec
48. Manual v0_93 docx Page 74 of 102 DRAFT Contents Subject to Change Select Op Mode TEVolt NullOp Stop Robot K9TankDrive K9Line K9TeleOp K9AutoTime K9IrSeeker Figure 116 Select an Op Mode to run from the list Y Connected as a media device 2 FTC Driver Station Device Name ZTE 029 Wifi Direct Connected to ZTE 030 Ping 2ms RobotController battery level 70 0 Robot Battery Level 12 76 queued K9TeleOp current op mode Stop Robot Select Stop Start Start w Timer Robot is stopped User 1 User 2 Gamepad type F310 Ix 0 00 ly 0 00 rx 0 00 ry 0 00 It 0 00 rt 0 00 Figure 117 Once an Op Mode has been selected it will appear as queued and the Start buttons will be enabled Once you have selected an op mode from the list the FTC Driver Station screen should change The name of the selected op mode should appear next to the word queued towards the top of the screen Also the Start and Start w Timer buttons should be enabled FTCTraining Manual v0_93 docx Page 75 of 102 DRAFT Contents Subject to Change If you press the Start button then the queued op mode will run indefinitely until the program terminates or until the Stop button is pressed If you press the Start w Timer button then the queued op mode will run for a preset amount of time currently 30 seconds In our example if you have selected the K9TeleOp program press the Start button to run a simple dri
49. P_RECOVERY E HP_TOOLS F GP tengs first fs02 ME Intranet first fs03 Nz Procedures first fs01 O Projects first fs01 P m Te Ee ET E F a G index html Chrome HTML Docurnent Share with Date modified 5 29 2015 11 08 AM Size 2 79 KB Print E mail Burn Name m com allelasses frame html allclasses noframe html constant values html deprecated list html help doc html index htm index all html eC overview frame html overview summiary html oweriew tree html _ package list script js serialized form htrml etulerheet rec New folder Date modified 5 29 2015 11 08 AM 5 29 2015 11 08 AM 5 29 2015 11 08 AM 5 29 2015 11 08 AM 5 29 2015 11 08 AM 5 29 2015 11 08 AM 5 29 2015 11 08 AM Type Chrome HTML Document Sire 2 79 KB Date modified 5 29 2015 11 08 AM 5 29 2015 11 08 AM 5 29 2015 11 08 AM 5 29 2015 11 08 AM 5 29 2015 11 08 AM 5 70 9015 11 08 AM mT Date created 6 1 2015 5 03 PM Double click File folder Chrome HTML D Chrome HTML D Chrome HTML O Chrome HTML O Chrome HTML D Chrome HTML D Chrome HTML D Chrome HTML D Chrome HTML D Chrome HTML File JScript Script File Chrome HTML D Caorainn Thula Se t Figure 150 Open the JavaDoc folder and double click on index html to view the documentation You can browse the various topics in the user documentation through a standard web browser FTCTraining Manu
50. RAFT Contents Subject to Change 1 Introduction The FIRST Tech Challenge FTC will be adopting a new controller for its robot competitions This new platform uses Android devices that are powered by QualComm Snapdragon processors This document contains information and exercises to teach students and mentors how to use and program this new system Figure 1 FTC s new Android based platform 2 Agenda This training document is organized in following manner e Overview of the new platform e Getting started with Android programming e Using your Robot e Operation Modes e QualComm FTC Robot SDK e Building the Robot Controller e Writing your own Op Mode e SDK documentation 3 Scope of Material This document only provides a very basic introduction to Android programming and how it relates to the next gen FTC robot controller platform Participants are encouraged to learn more about Java and Android development for other resources such as the official Android Developer s website http developer android com index html Note that the user interfaces that are pictured on the Android devices are simulated FTCTraining Manual v0_93 docx Page 3 of 102 DRAFT Contents Subject to Change The Android Developer s website has a series of Android development tutorials including video based interactive training http developer android com training index html There is an excellent free tutorial from Oracle that teaches
51. Station app click on it and follow the onscreen instructions to install Note that the application might prompt you to enter a credit card number or some other FTCTraining Manual v0_93 docx Page 54 of 102 DRAFT Contents Subject to Change method of payment The app is free and no payment method is required You should be able to hit the Skip button to skip the process of providing a method of payment Jae i Driver Station App gt FTC Driver Station FTC FIRST Tech Challenge INSTALL 0a Downloads Education Similar Provides driver station functionality for FIRST Tech Challenge competitions READ MORE Gamepad type Logtech F310 Gerneped LOGGING Figure 84 Follow the on screen instructions to install the app If you were able to install the app successfully then there should be an FTC Driver station icon on your Android device F A 11 26am auto location S FreDiivers Station ae eae MA Jo HA m Figure 85 After installing the app you should see an icon on your Android s screen IMPORTANT NOTE After you have successfully installed the app go to your Wi Fi settings menu and forget the wireless network that you used to connect to Google Play In general you do not want to be connected to any wireless networks with the exception of your FTC Robot Controller device FTCTraining Manual v0_93 docx Page 55 of 102 DRAFT Contents Subject to Change Connected Signal strengt
52. T Contents Subject to Change fe ZTE N9130 ZTE Handset USB Driver i Welcome to the ZTE Handset USB Driver Setup Wizard This will install ZTE Handset USB Driver on your computer Itis recommended that you dose all other applications before continuing Click Next to continue or Cancel to exit Setup Figure 71 Follow the on screen instructions to install the driver Follow the instructions on the setup wizard screens to install the ZTE handset USB driver The setup wizard will display a progress bar showing the status of the install When the install is complete click on the Finish button to end the installation process fe ZTE N9130 ZTE Handset USB Driver a i Completing the 7TE Handset USB Driver Setup Wizard Setup has finished installing ZTE Handset USB Driver on your computer The application may be launched by selecting the installed icons Click Finish to exit Setup nnsnnnnsdannnunnnnnnnnnnnnnn nana Figure 72 Click on Finish to complete installation FTCTraining Manual v0_93 docx Page 47 of 102 DRAFT Contents Subject to Change After installing the ZTE Speed driver you want to go back to your ZTE phone and go to the Connect to PC activity again swipe downwards from the top on the main screen and select the Touch for other USB options Select the Charge only option from the list of options 7 B 9 24am Connect to PC Charge only l harge your phone via Install drive
53. Test PeP A v Cures z iii H TableLayout v E drawable iz y Bea HH GridLayout m4 iii RelativeLayout n 7 m p k i pin Ab Plain TextView values 4b gt Gradle Scripts Eh Lange Test Ab Medium Text Ab Small Text OK Button ok Small Button RadioButton r CheckBox we C 22 nl Figure 41 You can choose which file to view by clicking on its tab near the top of the display In Figure 40 the activity_main xml file contains the layout information for the main activity of the app that you are creating Android Studio has a What You See Is What You Get WYSIWYG style graphical editor that lets you drag widgets things like text boxes buttons etc onto your activity FTCTraining Manual v0_93 docx Page 30 of 102 DRAFT Contents Subject to Change ication lication andfoidTest E activity_main xml x I Che neuss K aApptheme MainActivityy ii2i O FrameLayout m LinearLayout Horizontal E LinearLayout Vertical H TableLayout E TableRow GridLayout Hal RelativeLayout Widgets Ab Plain TextView Ab Large Text Ab Medium Text Ab Small Text OK Button OK Small Button RadioButton 7 CheckBox Switch ToggleButton E ImageButton am ImageView ProgressBar Large Design Tet 5 E e E Q a BDA Component Tree PIM o Device Screen v H RelativeLayout ol rik Ab TextView
54. TextView a Ab Medium Text Ab Small Text layout height style accessibilityLiveRegio OK Button OK Small Button O RadioButton 2 CheckBox m Switch ToggleButton E ImageButton m ImageView ProgressBar Large D AAA atch_parent spafolg uane SJ JBPUBWWOD pi apea DEG Te Android DDMS Gradle Console oe a rm Devices logcat ADB logs rbose 7 Qr a ig Devices Z J 2 Favorites Build Variants 9 20 PM Figure 40 Selected files will open up in the right hand side of the screen 1419 2015 If you have more than one file open on the right hand side of the dispay you can click on the tabs towards the top of the screen to select the file that you would like to view My Application CAUser SESE File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help DHO e XM AA o Hew P eR FR SR ae a MyApplication i app gt src gt main gt Pres Eitey6tit activity mainxml gt QQEhOS 4 y E Manaciviyjna x EM P manifests h Ne i apptheme Mainactivityy 2i nm gt man f Layouts E a oO FrameLayout v l i i E com nas myapplication ii T PT TOE h MainActivity LinearLavout Verti 5 gt com examplet application android
55. a servo named servo_ gripper In start the method of the K9TeleOp op mode see Figure 138 there is also some code to get a reference to the two servos on the K9 bot 9 3 3 2 The loop Method Let s take a brief look at the Loop method see Appendix A The Loop method contains the source code that gets executed by the robot controller repeatedly until a stop command is received At FTCTraining Manual v0_93 docx Page 90 of 102 DRAFT Contents Subject to Change the beginning of the Loop method contains code to read gamepad 1 The code uses the left joystick on gamepad 1 to control the left and right motors to make the robot move The loop method also contains code to check if certain buttons A Y X and B are pressed If the A button is pressed the robot controller will increment the position of the arm s servo which will cause the arm to move downwards for the K9 bot increasing values of the arm servo position correspond to a lowering of the arm If the Y button is pressed the controller will decrease the arm servo position which effectively raises the arm Similarly if controller detects that the X button is being pressed the controller will close the claw by increase the claw s servo position for the claw servo high values of the servo position correspond to the claw being closed If the controller detects that the B button is being pressed it will
56. al v0_93 docx Page 98 of 102 DRAFT Contents Subject to Change I E E cAusers Tom AndroidStudioProject All Classes PACKAGE CLASS TREE DEPRECATED INDEX HELP Packages PREV NEXT FRAMES NO FRAMES com qualcomm ftccommon com qualcomm robotcore eventlooy com qualcomm robotcore eventlooy Packages com qualcomm robotcore exceptior w com qualcomm robotcore hardware Package Description lt gt com qualcomm ftccommon Classes common to FTC aps All Classes com qualcomm robotcore eventloop RobotCore event loop library AccelerationSensor AccelerationSensor Acceleration com qualcomm robotcore eventloop opmode CommandList CompassSensor CompassSonsor CompassMode com qualcomm robotcore hardware RobotCore hardware library DbgLog rary DcMotor DcMotor Direction DcMotor MotorCallback DcMotorController DcMotorController DeviceMode PACKAGE CLASS TREE DEPRECATED INDEX HELP DcMotorController RunMode Device PREV NEXT FRAMES NO FRAMES DeviceManager DeviceManager DeviceType DifferentialControlLoopCoefficients DigitalChannel DigitalChanne Controller DigitalChanne Controller Mode ElapsedTime EventLoop lt com qualcomm robotcore exception RobotCore exception library com qualcomm robotcore util gt Figure 151 You can use a standard web browser to view the documentation 10 Conclusion Due to time constraints this user manual only covers the very basics of operating and programming a next gen Android based FTC robot
57. basic and advanced Java programming http docs oracle com javase tutorial 4 Demo Robots The training material in this document assumes that students will have access to a demo robot The robot aka the K9 bot is a small sized robot that is equipped with a DC motor controller a servo controller and two sensors The DC motor controller controls two 12V DC motors The servo controller controls two 180 degree servos The K9 bots also are equipped with a Power Module device and a Legacy Module device The motor and servo controllers and the Power and Legacy Modules are made by a company called Modern Robotics Figure 2 This training material often makes references to a K9 bot Matrix or Tetrix If you are interested in building your own version of the K9 bot a rudimentary build guide is available and distributed with this training manual IMPORTANT NOTE The K9 Bot that is described in this build guide was designed as a training robot The K9 Bot is useful for learning how to write op modes for the new Android control platform The K9 Bot is also easy to build and compact in size The K9 Bot was not designed to be a competition ready robot It is mainly intended for training purposes FTCTraining Manual v0_93 docx Page 4 of 102 DRAFT Contents Subject to Change 5 Overview of the Next Gen Platform The next gen platform is a point to point system This system has two main components the Driver Station and the Robot Controll
58. bot Once you have configured the robot click on the Done button to exit the Edit Motor Controller screen 0 a oni F B 2 42 pm 3 Edit Motor Controller Done Cancel Motor Controller 1 Enter the name for this motor controller here Port Attached 1 A motor_1 Enter the name for this 2 A motor_2 Enter the name for this n Figure 103 Configuring the Motor Controller After you have configured the motor controller you ll need to do the same for the servo controller and the legacy module For this training manual the servo controller has two active channels 1 and 6 and the names of the servos are servo_1 and servo _6 respectively see Figure 104 FTCTraining Manual v0_93 docx Page 67 of 102 DRAFT Contents Subject to Change k Saving screenshot 3 Edit Servo Controller Done Cancel Servo Controller 3 Ed Enter the name for this servo controller here Port Attached 1 vV servo_l Enter the name for this Enter the name for this Enter the name for this Figure 104 Edit Servo Controller activity For this manual the Legacy Module has an NXT compatible Hitechnic IR Seeker V2 called ir_seeker connected to port 2 of the Legacy Module and an NXT reflected light sensor called light_sensor connected to port 3 of the Legacy Module see Figure 105 i Gaaea F B 2 42 pm F3 Edit Legacy Module Controller Done Cancel 2 IR SEEKER v Select the type of connected dev
59. bot Controller Change the Robot Controller this Driver Station is paired with Figure 111 Touch the Pair with Robot Controller option to start the pairing process From the driver station s wifi direct pairing activity look for your robot controller in the list of available devices In the example below the robot controller is named ZTE 030 Select the device and then use the Android back arrow to make a connection request from your driver station to the robot controller k Saving screenshot Eg FTC Driver Station Settings Make sure that the FTC Robot Controller app is open on your other device and that both devices have wifi enabled Wifi Direct Devices None Do not pair with any device ZTE 030 aa a6 68 a6 27 da Figure 112 Look for your robot controller in the list of available devices FTCTraining Manual v0_93 docx Page 72 of 102 DRAFT Contents Subject to Change If this is the first time you are pairing to the robot controller the robot controller device might display a prompt asking you if it is OK to allow an Android device to establish a WiFi Direct connection In the example below the driver station ZTE 029 has requested a connection with the robot controller ZTE 030 Click on Accept to accept the connection request From ZTE 029 Decline Accept Figure 113 Click Accept to accept the WiFi Direct connection request Once you have successfully paired y
60. device Device Serial Number State Com DIILGE Nexus 5 Android 4 4 3 API19 06ac199800693af4 Online Ves Launch emulator Android virtual device Nexus 5 API 21 x86 Use same device for future launches ES e Figure 79 Android Studio should prompt you for the target device Once the app has been installed it should auto launch and you should see your activity with the words Hello world on the top left hand corner of the screen Congratulations You successfully built your first app My Application Hello world ee Os oe Figure 80 Congratulations You ve just built your first app FTCTraining Manual v0_93 docx Page 52 of 102 DRAFT Contents Subject to Change 8 Using Your Robot Now that you have successfully built your first Android app let s focus on the driver station and robot controller 8 1 FTC Driver Station The driver station is the Android device that sits near the team drivers and is connected to one or two USB gamepads Teams use the touch screen and the gamepads to operate their robot remotely The driver station Android device runs a special app called the FTC Driver Station 8 1 1 Installing the FTC Driver Station App The FTC Driver Station app is located on Google Play To install the app you first need to connect the ZTE phone to an available wireless network that has access to the Internet Launch the Settings activity on your phone and select the Wi Fi item to displa
61. dows PC has the correct USB driver installed for the Android device that you are using 7 8 1 Removing the SIM card from the ZTE Speed The ZTE Speed is the recommended Android device for the upcoming 2015 2016 FTC season Before you use your phone you should physically remove the SIM card and then place the phone into Airplane Mode with WiFi still enabled in order to make sure that the Soeed phone does not try to connect to the Boost Mobile network whenever it is turned on Figure 44 ZTE Speed The first step in this process is to make sure that your phone is powered off You will need to remove the plastic back cover of the phone With the screen facing you if you look in the lower right hand corner of the device you will see a gap that you can use to pry the plastic rear cover off of the phone Pry the back cover off of the phone and then place the phone screen down onto the table Along the right hand side of the phone you should see the SIM card Push in on the SIM card this will eject the card partially from its slot Remove the card and store it in a safe place Replace the back cover and then power the phone on FTCTraining Manual v0_93 docx Page 32 of 102 DRAFT Contents Subject to Change Figure 45 There is a gap in lower right hand corner that you can use to pry the back cover off the phone Figure 46 Pry the back cover off of the phone FTCTraining Manual v0_93 docx Page 33 of 102 DRAFT Contents Subj
62. e selected op mode The Stop button stops the current op mode The Start w Timer button will start the op mode and let it run for a predetermined amount of time The buttons will not be enabled until the Driver Station is connected wirelessly to a robot controller We will revisit the Op Mode controls in greater detail at a later section of this manual 8 2 Robot Controller The Robot Controller is the Android device that is mounted on the robot frame It acts as the brains of the robot and runs a special app known as the FTC Robot Controller app In this training manual you will be instructed on how to modify parts of the Robot Controller app to create your own op modes that will run on your robot You will use a development kit to create edit and register your own op modes for your Robot Controller app However you can also download a copy of the robot controller that includes some sample op modes pre installed FTCTraining Manual v0_93 docx Page 61 of 102 DRAFT Contents Subject to Change 8 2 1 Installing the Robot Controller App The FTC Robot Controller app is also available for download from the Google Play store The instructions are almost identical to the instructions provided in section 8 1 1 of this document see page 53 Connect to a wireless network with your phone and use Google Play to search for FTC Robot Controller Install the app with Google Play and don t forget to forget the wireless network that you had conn
63. e these tools are more stable have less bugs or work better with your target Android hardware The SDK Manager also lists some extra software tools which might be useful for your development environment If you are a Windows user then you want to make sure a couple of Extras are installed onto your local machine Towards the bottom of the scrolling view of the SDK manager there is a package of components labeled Extras Navigate to this package and expand the package to view its components Make sure the components Google USB Driver is installed on your machine If they are not installed make sure you select them by checking the boxes next to their listing then hitting the install button In the screen grab below the Google USB driver was not yet installed The check box next to the Google USB component has been selected indicating that the user would like to install the Google USB driver onto the machine Anco SOc Manager a Android SDK Manager _ Packages Tools SDK Path C Users jwierman AppData Local Android sdk Packages TT Name Rev Status 4 Extras Android Support Repository 11 amp Installed 7 Android Support Library 21 0 3 Not installed E Ea Google Play services for Froyo 12 Not installed E Google Play services 22 Not installed Google Repository 15 amp Installed Google Play APK Expansion Library 3 Not installed Google Play Billing Library 5 Not installed
64. ect to Change f Mitel ATE N TNO MAN uwi FOO 1 BROSTENOHDD gue LU a eM atu umam Mada i Cina Figure 47 The SIM card is installed in the right hand side Figure 48 Push in on the SIM card to eject it from its slot Figure 49 Remove the card from its slot and replace the back cover FTCTraining Manual v0_93 docx Page 34 of 102 DRAFT Contents Subject to Change After you have removed the SIM card from the ZTE Speed phone power the device on and step through the opening screens see images below 9 lt il amp 9 43 am Talkback is a navigation feature for the visually challenged and impaired To activate this feature double tap the center of your screen To explore other accessibility features tap Accessibility To continue activation press Next Accessibility Next Figure 50 The phone will ask you if you would like to set up Talkback Hit Next to skip this step i 9 43 am Please select your language English Japanese Spanish Next Figure 51 Select your language and hit Next to continue FTCTraining Manual v0_93 docx Page 35 of 102 DRAFT Contents Subject to Change ad i amp 9 43 am Why use Wi Fi Connecting to Wi Fi will improve your overall experience by Extending your battery life Give you faster connections during peak times Next Figure 52 The phone will prompt you to connect to a WiFi Network Hit Next to continue E 9
65. ected to in order to access the Internet Robot Controller A FTC Robot Controller FTC FIRST Tech Challenge INSTALL Provides robot controller functionality for FIRST Tech Challenge competitions READ MORI Figure 94 The FTC Robot Controller is available on Google Play IMPORTANT NOTE After you have successfully installed the app go to your Wi Fi settings menu and forget the wireless network that you used to connect to Google Play In general you do not want to be connected to any wireless networks with the exception of your FTC Driver Station device or if you are doing wireless ADB which is an advanced topic not covered in this document IMPORTANT NOTE You do not want to install the FTC Driver Station on the same Android device as the FTC Robot Controller app These two apps should be installed on separate devices One of the apps the Robot Controller will configure the device to operate as a WiFi Direct Group Owner Itis important that the two apps are installed and run on separate devices 8 2 2 Launching the Robot Controller App After you install the app there should be an FTC Robot Controller icon on your Android devices main screen Touch the icon to launch the Robot Controller FTCTraining Manual v0_93 docx Page 62 of 102 DRAFT Contents Subject to Change Donni OF B 1 22pm auto location Contr oT 5 me lt i Fy i 4 A ENN y aa ve ao Googles Play Sue email A l CYN i m
66. ected to the USB hub The battery also provides power to drive the DC motors and servos on the robot 4 Power Module The Power Module is an electronic device that has a built in USB hub which connects the Android device to one or more USB enabled modules such as the Legacy Module The Power Module draws power from the 12V battery and feeds it to the USB devices through the USB cables The Power Module also feeds power directly to the DC motor and servo controllers 5 Micro USB Adapter The robot controller Android device has a type of connector port known as a Micro USB Type B female connector An adapter cable is needed to connect the Android Device to the built in USB 6 USB Cables The USB connected modules such as the Power Module and Legacy Module for the next gen platform use USB Mini style cables to connect with each other and with the Android device Note that an adapter cable is needed to connect the USB Mini style cable to the Android s Micro USB Type B port 7 Legacy Module This module is a special electronic device that acts as a bridge between the new Android robot controller and the older LEGO NXT compatible devices motor and servo FTCTraining Manual v0_93 docx Page 6 of 102 DRAFT Contents Subject to Change 10 11 12 controllers sensors etc The Legacy Module communicates with the Android device through a USB connection It receives commands and sends data from to the Android device It also
67. eloper Options Exit the About phone activity and look at your Settings screen You should now see the Developer options item listed above About phone in the Settings menu FTCTraining Manual v0_93 docx Page 41 of 102 DRAFT Contents Subject to Change P lal 8 36 am ro Settings m Security Backup amp reset ACCOUNTS Add account SYSTEM Accessibility Printing Developer options Activate this device System updates About phone Figure 63 Once Developer Options are enabled you should see a listing in the Settings menu 7 8 3 Enabling USB Debugging In order for your Android Studio computer to be able to talk to your Android phone properly you will need to enable USB Debugging for your phone Click on the Developer options item of the Settings menu see Figure 63 The Developer options screen should appear on your phone Look for the USB debugging option and check the checkbox to enable this option on your phone FTCTraining Manual v0_93 docx Page 42 of 102 DRAFT Contents Subject to Change 8 8 36 am Developer options ON Olay dWdKe Screen will never sleep while charging Select runtime Use Dalvik Enable Bluetooth HCI sno Capture all bluetooth HCI packets in a file Process Stats Geeky stats about running processes DEBUGGING USB debugging Debug mode when USB is Ceanected Revoke USB debugging authori Power menu bug reports Include option in pow
68. en you have your Android phone connected to the Power Module or Legacy Module with the phone acting as a USB host the Android device will be drawing power from its internal battery The Android device s internal battery currently cannot be charged while it is acting as a host for the gamepad or robot modules 5 3 2 USB Micro Type B The Android devices have a special type of USB port called a USB On the Go OTG port This USB OTG port allows the Android device to automatically switch between host and client modes The USB OTG devices typically have a USB Micro Type B receptacle Figure 6 USB Micro B receptacle The Android device s micro USB receptacle requires a USB Micro B cable simultaneously through a accessed January 15 2015 3 Image from http i FTCTraining Manual v0_93 docx Page 8 of 102 DRAFT Contents Subject to Change Figure 7 USB Micro B cable From http www monoprice com Product c id 103 amp cp id 10303 amp cs id 1030307 amp p id 8639 amp seq 1 amp format 2 accessed on January 15 2015 FTCTraining Manual v0_93 docx Page 9 of 102 DRAFT Contents Subject to Change 5 3 3 USB Mini Type B The electronic modules from Modern Robotics that are used to communicate between the Android phone and the robot hardware motors servos and sensors are equipped with USB Mini Type B receptacles This type of receptacle was selected by the manufacturer because they are the most durable type of connector
69. ent device you will have to edit the configuration file for your robot since the serial number of the new device will not match the serial number of the original device Similarly if you were to remove your Android device from one robot and attach it to a new robot you would have to create a new configuration file since the serial numbers of the devices on the new robot would not match the serial numbers that were stored in the original configuration file 8 2 4 Pairing the Driver Station to the Robot Controller If your robot controller is properly configured to match the installed hardware on your robot then you are almost ready to begin controlling your robot Before you can control your robot from your driver station you must first pair the driver station to the robot controller The new control system uses a technology known as WiFi Direct to establish a unique and persistent connection between the driver station and the robot controller For this system the robot controller acts as the WiFi Direct group owner Once a driver station has been paired to a robot controller then the driver station will always look for that robot until it is paired with a different robot controller FTCTraining Manual v0_93 docx Page 70 of 102 DRAFT Contents Subject to Change In order to pair your two devices you need to make sure that both Android devices are powered on and the FTC Robot Controller app and the FTC Driver Station app are running on
70. ent phone and we will be happy to assist you Figure 57 The activation should fail Hit Done to complete the process FTCTraining Manual v0_93 docx Page 38 of 102 DRAFT Contents Subject to Change Phone a o O Messaging Mobile ID Music RI Ka Photos Play Books Play Games I N Play Movies amp Play Music Play Play Store TV Settings Q Figure 59 Find the Settings app and press it to launch the Settings activity FTCTraining Manual v0_93 docx Newsstan 2222 Video Player Voice Dialer Voice Search Page 39 of 102 DRAFT Contents Subject to Change P il amp 9 44 am i Settings WIRELESS amp NETWORKS 7 Airplane mo OFF Wi Fi Bluetooth Mobile networks Data Usage Mobile Hots OFF More DEVICE Boeliite Display Figure 60 Turn on Airplane Mode so the device won t try to connect to mobile network a A 9 amp 9 44am Settings WIRELESS amp NETWORKS 7 Airplane mo Wi Fi Bluetooth Mobile networks 1 Data Usage Mobile Hots OFF More DEVICE Boeliiate Display Figure 61 Turn WiFi back on once the phone is in Airplane Mode Once you have removed the SIM card and switched the phone to Airplane Mode it is now ready for use 7 8 2 Enabling Developer Options on your Android Device For this training manual we assume you will be using a ZTE Speed Android phone as your primar
71. er The driver station communicates wirelessly with the robot controller WiFi Direct Connection Robot Controller Driver Station y 1 y 1 Driver 1 Driver 2 Figure 3 The new FTC platform is a point to point solution 5 1 Driver Station The driver station is the component that the teams use to provide input from a pair of gamepads and or a touch screen to the Robot Controller The driver station also displays messages status information motor speed sensor data etc from the Robot Controller The driver station consists of the following components 1 Android Device An Android device is used as the base of the driver station This Android device communicates wirelessly with the robot controller This device has its own internal battery 2 USB Gamepad Controllers The driver station uses a pair of USB enabled gamepad controllers for driver input For this tutorial we will use a pair of Logitech F310 gamepads with the devices set in X mode Xbox emulation mode i e the switch on the bottom of the F310 should be set to the X position 3 Non Powered USB Hub The driver station Android tablet only has a single USB port A USB hub is used to connect both gamepads to the driver station tablet 4 Micro USB Adapter The driver station Android device has a type of connector port known as a Micro USB Type B female connector An adaptor cable is needed to connect the USB hub to the Android device
72. er menu for taking a bug report Figure 64 Make sure USB debugging is enabled for your phone Once the USB debugging option is enabled for your phone when you connect your phone it will connect in debug mode which will allow Android Studio to talk to your phone as an Android device 7 8 4 Installing the USB Driver for your Device If you ve enabled USB debugging for your Android device you are just about ready to install your Android App onto the device However there is one last step that you need to do in order to connect your device successfully to Android Studio You will need to install the correct driver for your Android device onto your Windows computer If your Windows computer does not have the correct driver for your phone installed then when you connect your device to the computer via a USB cable the Windows computer will think that the device is a media player or storage device like a FLASH drive You might be able to access files on your device in this mode but your Android Studio software will not recognize the device as an available Android device that it can talk to FTCTraining Manual v0_93 docx Page 43 of 102 DRAFT Contents Subject to Change OO aa aola C a gt Computer gt N9130 Search N9130 p Organize v a Phone gt C Libraries MF 3 61 GB free of 4 11 GB 4 Computer gt amp Local Disk C ea HP_RECOVERY E HP_TOOLS F gt GP teng first fs02 M
73. erformance Intel HAX Space required 3 8GB Figure 19 Select the default values when prompted by the installation wizard During the installation process the Installation Wizard will prompt you for the Install Locations for the Android Studio software and the Google Android Software Development Kit SDK The Android Studio software is the tool such as the text editor project browser and debugger that you will use to create and edit your apps The Android SDK contains the actual software components that are used to build and install the apps When the Installation Wizard prompts you for the Install Locations you should note the install location of the Android SDK You might need to know this location later on to find and run tools that are available in the SDK In the screenshot below the Android SDK will be installed to the directory C Users teng AppData Local Android sdk on the Windows computer FTCTraining Manual v0_93 docx Page 18 of 102 DRAFT Contents Subject to Change Android Studio Setur Configuration Settings Install Locations Android Studio Installation Location The location specified must have at least 500MB of free space Click Browse to customize C Program Files Android Android Studio Android SDK Installation Location The location specified must have at least 3 2GB of free space Click Browse to customize C Users teng AppData Local Android sdk Figure 20 N
74. ersion of your FTC Driver Station app FTCTraining Manual v0_93 docx Page 59 of 102 DRAFT Contents Subject to Change 8 1 4 Using the Gamepads As it was mentioned in a previous section if you are using the Logitech F310 gamepad with your driver station then make sure the switch on the bottom of the pad is set to the X position The driver station app is designed to work with up to two gamepads When you connect your gamepads to the Android device through a USB hub you need to tell the FTC Driver Station app which gamepad will be used to represent driver 1 User 1 and which gamepad will be used to represent driver 2 User 2 You can select which driver a gamepad will represent by pushing the Start key on the gamepad while simultaneously pressing the A button if you want to be driver 1 or the B button if you want to be driver 2 Figure 92 Press Start A to be driver 1 or Start B to be driver 2 When you first connect your gamepads to the Android device you must push a button combination to designate which driver your gamepad will represent Once you have designate which driver your gamepad will represent the gamepad status information will appear below the appropriate area near the bottom of the screen For example supposed the gamepad that represents driver 1 is active then the lower left hand corner of the screen will be highlighted green and gamepad status information such as the x and y positions of the
75. es Gradle to keep track of all of the program module dependencies and to build and link these modules to create your app You can click on the Gradle Console tab in the lower right hand corner of the screen This will open the Gradle console window and you should see messages from the gradle process appear If your build is successful you should see the words BUILD SUCCESSFUL appear in the gradle window 1 Gradle Console 4 ir maad gp a PEIS s nyapplication Ea app processDebugManifest UP TO DATE e app processDebugResources UP TO DATE app generateDebugSources UP TO DATE app compileDebugJava UP TO DATE app preDexDebug UP TO DATE app dexDebug UP TO DATE app processDebugJavaRes UP TO DATE app validateDebugSigning app packageDebug UP TO DATE app ZipalignDebug UP TO DATE BUILD SUCCESSFUL Total time 1 mins 24 467 secs FTCTraining Manual v0_93 docx Log E Gradle Console Memory Monitor RLF UTF 8 Figure 78 When build is complete the words BUILD SUCCESSFUL should appear in the Gradle console Page 51 of 102 DRAFT Contents Subject to Change Once your build is complete Android Studio should ask you to select a target device for your app Make sure your phone is selected and hit OK to install the app onto the phone Note that in the screen grab below the phone that is listed is an LGE Nexus 5 Che i i Choose a running
76. ew Navigate Code Analyze Refactor Build Ow go il ak Debug app E3 MyApplication Sapp gt src gt main gt E3 res gt k i i Android Ir ores FA bl a a Debug o Ciapp E Edit Configurations ail manifests wu m java E com example teng myapplication Reload Changed Classes E MainActivity Tae 5 com example teng myapplication androidTest Force Ste Pa res etree v drawable Force Step Intc E layout mart Step activity_main xml otep Out E menu un to Cursor 2 values orce Run to Curso O Gradle Scripts Android DDMS R Fe Drop Frame P Resume Program E aluate Expression EJ Devices logcat ariants Pa S E ADB logs bose M Q7 Toggle Breakpoir Tools VCS Window Help uP Shift F9 Alt Shift F10 Alt Shift F9 android com apk res androi I Z ools android layout width 0id paddingLeft 16dp t MainActivity gt roid layout _width wrap con Alt Shift F7 gt sradle Console Preview A amp app dexDebug UP TO DATE e app preDexDebug UP TO DATE i tamminrocessNehualavaRes TTP TO NAT Figure 77 Select Run gt Run app to build your app You can monitor the progress of the build by opening the Gradle window Gradle is a tool that is used to help automate the build process for a complex piece of software Gradle is similar tools like make or Apache Ant Android Studio us
77. f 102 DRAFT Contents Subject to Change i Gradle Console r FtcRobotController generateDebugsources UP TO DATE FtcRobotController compileDebugJava UP TO DATE FtcRobotController preDexDebug UP TO DATE FtcRobotController dexDebug UP TO DATE FtcRobotController processDebuqJavakes UP TO DATE FtcRobotController validateDebugsSigning FtcRobotController packageDebug UP TO DATE FtcRobotController zipalignDebug UP TO DATE FtcRobotController assembleDebug UP TO DATE BUILD SUCCESSFUL Total time 21 487 secs Messages Eh Event Log E Gradle Console Figure 132 Once the build is complete and the app installed the Gradle Console will indicate success Once you have built the FTC Robot Controller app and installed it on your phone you can configure it and operate it like you did with the pre installed copy of the app 9 3 Building Your Own Op Mode Now that you have learned how to compile the robot controller app let s take a look at how to make our own op mode As we mentioned earlier in this document an op mode is a software module stored on the robot controller that you can execute from the driver station These op mode software modules contain pre programmed behaviors for your robot Op modes are useful because you can create a variety of them that will allow your robot to behave in different ways depending on the competition requirements For example you might have one op mode that you use for the autonomous porti
78. fs02 M amp Intranet first fs03 N S Procedures first fs01 O G Projects first fs01 P al 1 ee ee ee ae ftc_app master Date modified 5 29 2015 11 08 AM d File folder Figure 122 The ZIP contains a project folder ftc_app master that can be imported into Android Studio Once you have extracted the contents of the ZIP file you can import the project folder into Android Studio If your Android Studio environment is currently opened to another project select File gt Close Project to close the current project FTCTraining Manual v0_93 docx Page 79 of 102 DRAFT Contents Subject to Change ation veh Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help New Project 1 i apr PhP MeL FR SRS we New Module m SRO z i in gt E res gt layout activity_main xml gt Import Project T ma valt i ivity j x Ra activi i x a D 4 jal Minin java x K activity_main xml Import Sample Q lt RelativeLayout xmlns android http schemas android com N AR ae xmlns tools http schemas android com tools android eee new android layout_height match_parent android paddingLe E Open ion android paddingRight 16dp Reopen Project gt android paddingTop 16dp Close Project sre android paddingBottom 16dp tools context MainActiv ition androidT est 4 Q P Settings Ctri Alt S o lt TextView andro
79. h Excellent Link speed 86Mbps Sania WPA2 PSK IP address 192 168 1 115 Cancel Forget Figure 86 Don t forget to forget the wireless network after the installation is complete IMPORTANT NOTE You do not want to install the FTC Driver Station on the same Android device as the FTC Robot Controller app These two apps should be installed on separate devices One of the apps the Robot Controller will configure the device to operate as a WiFi Direct Group Owner It is important that the two apps are installed and run on separate devices 8 1 2 Launching the FTC Driver Station Figure 87 depicts an Android tablet with a single Logitech F310 gamepad controller connected This Android tablet has the FTC Driver Station app running This app is used to communicate with and control the robot SL Figure 87 Driver Station with a single gamepad connected To launch the FTC Driver Station app simply touch its icon on the screen see Figure 85 FTCTraining Manual v0_93 docx Page 56 of 102 DRAFT Contents Subject to Change The FTC Driver Station app will launch into its main screen see Figure 88 Towards the top of the screen you can see some information about the status of the wireless connection Right now in Figure 88 the driver station is not connected to a robot If the driver station were connected to a robot you would see ping statistics i e it would show the time it takes for a message to get sent to the robot and
80. h KolrSeeker K9Line h K9TankDrive C b K9TeleOp a NullOp E b NxtEncoderOp fi Captures Jild Variants Figure 136 Find the K9TeleOp op mode in the project browser In the left hand side of your Android Studio environment use the project browser to find the file K9TeleOp and double click on the file to open it up Hf aa K9TeleOp java X package com qualcomm ftcrobotcontroller opmodes import feet Telep Mode lt p gt Enables control of the robot via the gamepad public class K9TeleOp extends OpMode Note the configuration of the servos s such that as the arm servo approaches 0 the arm position moves up away from the floor Also as the claw servo approaches 0 the claw opens up drops the game element TETRIX VALUES final static double ARM MIN RANGE 0 20 final static double ARM MAX RANGE 0 90 final static double CLAW MIN RANGE 0 20 final static double CLAW MAX RANGE 0 7 double armPosition if smannt y hs h rr nostian f amount Co change the arm servo position double armDelta 0 1 ss ngst Af h nilay cert f POsition or tne claw servo double clawPosition I amann n rcha Eh rlisy e try newts z amount to change the ciav servo position by double clawDelta 0 1 Figure 137 The K9TeleOp source code FTCTraining Manual v0_93 docx Page 88 of 102 DRAFT Contents Subject to Change If yo
81. ici here ir_seeker Enter the name for this device here 3 LIGHT_SENSOR z Select the type of connected devici here Figure 105 Edit Legacy Module Controller activity Important note The names of the devices that you assign in the edit screens are very important The Robot Controller app will use these names as references to the corresponding devices When you create your own Op Mode to run on your robot your Java code will have to refer to these device names in order to be able to find and control these devices with your Java code In our example if you want to be able to control the first motor configured in Figure 103 then your Java code will need to refer to it by its name motor_1 FTCTraining Manual v0_93 docx Page 68 of 102 DRAFT Contents Subject to Change After you have provided the details for the motor controller servo controller and legacy module you are ready to save the hardware configuration to the Android device To save your configuration press the Save Configuration button on the Configure Robot screen and type in the name of your configuration file and hit the OK button Enter file name Please enter the file name k9bot Cancel labor knot Minot min kaa liae Aaa Ma es Sie Maa lais daai a ae her a Pe y rae a amp 7 eae Ae alk ale ee ae CPx ecw nmnm EN 7123 N Er E Figure 106 Press the Save Configuration button and then specify the file name After you have saved
82. ick Start Ew Start a new Android Studio project ma Open an existing Android Studio project No P roject o pen Yet FY Import an Android code sample T Check out project from Version Control EY Import Non Android Studio project E Docs and How Tos gt gt Android Studio 10 1 Build 135 1641136 Check for updates now Figure 25 Select Configure from the Quick Start menu of the Welcome screen In the Configure menu select the SDK Manager option to launch the Android SDK Manager FTCTraining Manual v0_93 docx Page 21 of 102 DRAFT Contents Subject to Change WF Android Studio Setup Welcome to Android Studio Recent Projects Configure Rg Plugins 5 K Import Settings A Export Settings PA Project Defaults Android Studio 10 1 Build 135 1641136 Check for updates now Figure 26 Select SDK Manager from Configure menu The SDK Manager will list available packages of software tools that you can download if they are not already installed on your machine The SDK Manager also lets you remove uninstall components from your computer In the screen grab below you can see that the Android SDK Tools revision 24 0 2 the Android SDK Platform tools revision 21 and the Android SDK Build tools revision 21 1 2 are already installed on the computer Fackages Tools SDK Path C Users teng AppData Local Android sdk Packages ig Name tev Status 4 Tools El Pa Android SDK Tools am
83. id text Hello world android layout_w E Project Structure Ctrl Alt Shift S a android layout height wrap content gt Other Settings gt z lt RelativeLayout gt Import Settings Export Settings lel Save All Ctrl S QJ Synchronize Ctrl Alt Invalidate Caches Restart e Design Text Export to HTML E Print L Sade Console P Add to Favorites Pe v app com example teng myapplication E Eo File Encoding Ei Line Separators r nd Make File Read only kA Figure 123 Select File gt Close Project to close the current project After you have closed the current project you should see the Android Studio Welcome screen Select the option Import project Eclipse ADT Gradle etc from the Quick Start menu on the Welcome screen Important make sure you select the Import project Eclipse ADT Gradle etc option and not the Open an Existing Android Studio project option r Android Studio Welcome to Android Studio Recent Projects Quick Start ftc_sdk AndroidStudioProjects ftc_sdk Ew Start a new Android Studio project FTech_4_00_Beta4 AndroidStudioPr s FTech_4 00 Beta My Application AndroidStudioProjects h EA Open an existing Android Studio project k K Import an Android code sample T Check out project from Version Control Ey Import project Eclipse ADT Gradle etc Psi Configure E Docs and How Tos Android Studio 1211 Build 1411903
84. l http docs oracle com javase tutorial Students are encouraged to review the online Java tutorial before they attempt to try the exercises in this training manual It would be helpful if students have a basic knowledge of Java to complete the exercises in this manual Students do not have to be Java experts but should understand the basic syntax of java and be familiar with concepts such as classes inheritance and other key object oriented concepts FTCTraining Manual v0_93 docx Page 13 of 102 DRAFT Contents Subject to Change 7 Installing Android Studio 7 1 Important Note Regarding the Android Studio Instructions IMPORTANT NOTE This training manual contains instructions on how to install the Android Studio software onto your PC Please note that this information is provided to help you with the installation of the software however the screen shots and links in this document might be out of date The most up to date reference for installing and using the Android Studio software can be found on the Android developer website http developer android com sdk index html Please read and refer to the instructions on the Android developer website before you attempt to install this software onto your own PC 7 2 Android Studio Website In order to create programs for your next gen FTC robot you will need to have Android Studio installed on your laptop Android Studio is distributed freely by Google and it is available on the And
85. l 12 92 current op mode Stop Robot Select Stop Robot is stopped Figure 115 Op Mode Select and Stop buttons are enabled Robot is in Stop mode Note that if the Driver Station app is connected successfully to the Robot Controller app then some ping statistics should be visible at the top left hand corner of the Driver Station screen In the example of Figure 115 the ping statistics reads 4 ms This means it took 4 milliseconds for the driver station to send a packet to the robot and for the robot to acknowledge the packet and send its acknowledgement back to the driver station The ping round trip time is a rough measure of network quality As the round trip time increases the network performance usually degrades In our testing an ideal round trip time is anything on the order of 10 milliseconds or lower Sometimes you might see the ping time period increase if there is a surge in network traffic or interference If the period starts to increase to the order of or greater than 100 milliseconds then there might be excessive network traffic or noise on the wireless channel that your system is using Touch the Select button to display a list of the available Op Modes for this robot You can select an Op Mode from the list and the FTC Driver Station should indicate that the Op Mode has been queued for execution For our demonstration there should be an op mode called K9TeleOp in the list Select the mode from the list FTCTraining
86. ller framework will do this automatically for you for safety reasons Jri prm pm m nE m a mrm J im a a lt P a P Override public void stop Figure 141 The stop method for K9TeleOp is empty However if you do have some cleanup items that you would like to do after your op mode run is complete you can place these tasks in the stop method of the op mode 9 3 4 Making Your Own Op Mode Let s make our own op mode To make it easy instead of making our own op mode from scratch we will simply copy an existing op mode rename it register it then build the app and run the new op mode We will use the K9TeleOp program as the basis of our new op mode In Android Studio right mouse click on the K9TeleOp program file and select Copy from the pop up menu FTCTraining Manual v0_93 docx Page 93 of 102 DRAFT Contents Subject to Change File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help pao 4 X GO AA KEL AT mai Erase Eh sh Een Erce a O manifests Y jaa v com qualcomm ftcerobotcontroller v opmodes AutoRotateOp CompassCalibration h FtcOpModeRegister h IrSeekerOp K9AutoTime h K9lrSeeker K9Line K9TankDrive C KTeleOp New h NullOp b NetEncoc NxtTeled package inf On Aboutdctivit Copy as Plain Text AuicConfigg _ COPY Reference Ctrl Alt Shift C Configwiripi Lil Paste Ctrl V
87. m E Evaluate Expression k Show Execution Point 8 View Breakpoints Stop Reload Changed Class Step Over Force Step Over Step Into Force Step Into Smart Step Into Step Out Run to Cursor Drop Frame es Quick Evaluate Expression Toggle Line Breakpoint Toggle Method Breakpoint Toggle Temporary Line Breakpoint Toggle Breakpoint Enabled Shift F9 Alt Shift F10 Alt Shift F9 Ctrl F2 F8 Alt Shift F8 F7 Alt Shift F7 Shift F7 Shift F8 Alt F9 Ctrl Alt F9 F9 Alt F8 Ctrl Alt F8 Alt F10 Ctrl F8 Ctrl Alt Shift F8 Ctrl Shift F8 spaloid UJALI 3 alpea wy Figure 129 Select Run gt Run FtcRobotController to compile the FtcRobotController folder While Android Sturdio is building the app for you you can click on the Gradle Console tab towards the lower right hand side of the screen to see the status messages from the gradle software as it builds and links the modules needed for the app When Android Studio successfully completes the build it should prompt you to select which device it should install the app onto Select the ZTE Speed phone from the list of available devices and hit OK FTCTraining Manual v0_93 docx Page 83 of 102 DRAFT Contents Subject to Change Choose a running device Device Serial Number State Com ZTE N9130 Android 4 4 4 AP119 7a7180e E Launch emulator Android virtual device Use same device for future
88. n the starting position of the wrist and claw armPosition 0 2 clawPosition 0 2 This method will be called repeatedly in a loop see com qualcomm robotcore eventloop opmode OpMode run Override public void loop fs Gamepad 1 Gamepad 1 controls the motors via the left stick and it controls the wrist claw via the a b x y buttons Pi throttle left stick y ranges from 1 to 1 where 1 is full up and 1 is full down direction left stick x ranges from 1 to 1 where 1 is full left and 1 is full right float throttle gamepadl left stick_y float direction gamepadl left stick_x float right throttle direction float left throttle direction clip the right left values so that the values never exceed 1 right Range clip right 1 1 left Range clip left 1 1 scale the joystick value to make it easier to control the robot more precisely at slower speeds right float scaleInput right left float scaleInput left write the values to the motors motorRight setPower right motorLeft setPower left update the position of the arm if gamepadl a if the A button is pushed on gamepadl increment the position of the arm servo armPosition armDelta if gamepadl y if the Y button is pushed on gamepadl decrease the position of the arm servo armPosition armDelta update the position of the
89. needs to know what hardware devices are connected to the Robot Controller amp D EA RY Load Configuration File New Click here to create a new configuration file Available files o No files found in order to proceed you must create a new file AutoConfigure o Press this button to use the AutoConfigure tool Figure 97 The Robot Controller app might complain if it doesn t detect a configuration file In order to create a configuration file if you are in the Active Configuration file screen of Figure 97 simply press the New button to create a new hardware configuration file for your robot BO eed F3 FTC Robot Controller Device Name Wifi Direct disconnected Robot Status null Cannot open robot configuration file storage emulated 0 FIRST No current file xml Figure 98 Main screen of Robot Controller app no hardware configuration file specified yet FTCTraining Manual v0_93 docx Page 64 of 102 DRAFT Contents Subject to Change If you are in the main FTC Robot Controller screen see Figure 98 you can create a new hardware configuration by first launching the Settings menu Touch the three dots in the upper right hand corner of the main screen to bring up the Settings menu EF IES E Ra B 2 24 pm ae Settings WIFI CHANNEL SELECTION Change Wifi Channel ROBOT CONFIGURATION SETTINGS Configure Robot Load Configuration File Autoconfigure Robot Figure
90. ntral processor volatile and non volatile memory input output devices and other features commonly found on modern computers Android is the operating system that runs on these handheld devices Similar to a laptop that has Microsoft Windows or MacOS as its operating system a tablet or smartphone has its own operating system that manages the device s hardware and software components Figure 11 Android is the world s most popular computing platform You may have heard people refer to Android as firmware The term firmware implies that the instructions and data that are make up the device s operating system are stored in the device s non volatile memory The firm in the word firmware originally implied that the instructions and data that are used to run an electronic device like a digital camera or MP3 player did not change very frequently if at all Typically the firmware was installed once onto the device at the factory and left there for the rest of the device s life Android is more similar to the Windows MacOS and Linux operating systems It is installed onto non volatile parts of memory of a tablet or phone However Android is often updated with patches or upgrades just like Windows MacOS and Linux Even though Android can be updated regularly people still often refer to it as firmware Google produces Android which is the world s most popular operating system Google develops and maintains
91. o download the software The Android web page should prompt you to accept or reject the license agreement Check the checkbox to accept the agreement then press the blue button to begin the download E Download Android Studio x Y e C developer android com sdk index html top v7 ii Develop gt Tools gt Download Android Studio and SDK Tools al z Download Installing the SDK Before installing Android Studio or the standalone SDK tools you must agree to the following terms and conditions Adding SDK Packages 1 3 Google means Google Inc a Delaware corporation with principal place of business at 1600 Amphitheatre Android Studio Parkway Mountain View CA 94043 United States Workflow 2 Accepting this License Agreement Tools Help ping g 2 1 In order to use the SDK you must first agree to this License Agreement You may not use the SDK if you do not Build System ante accept this License Agreement S rt Lib ome 2 2 By clicking to accept you hereby agree to the terms of this License Agreement Revisions 2 3 You may not use the SDK and may not accept the License Agreement if you are a person barred from receiving NDK the SDK under the laws of the United States or other countries including the country in which you are resident or from which you use the SDK ADK 2 4 If you are agreeing to be bound by this License Agreement on behalf of your employer or other entity you Eclipse with ADT represent and warrant tha
92. on of a match and another for the driver controlled portion You might also have multiple op modes for different tasks during the autonomous period The new robot control platform lets you create multiple op modes that can be selected and executed remotely from the driver station Let s take a look at how the op modes are organized in the FtcRobotController program folder in your QualComm SDK Android Studio project 9 3 1 FtcRobotController opmodes Folder The source code i e the Java instructions that are used to create the program module for the op modes are stored in a subfolder of the FtcRobotController program folder If you use the project browser on the left hand side of your Android Studio development environment you can browse the FtcRobotController folder and navigate to the following subdirectory FtcRobotController gt java gt com qualcomm ftcrobotcontroller gt opmodes This folder contains all of the files for the robot controller app s op modes FTCTraining Manual v0_93 docx Page 85 of 102 DRAFT Contents Subject to Change T ee ee ee PR oy Se a Jsers teng Documents develop ftc_app mas File Oo H i3 1 Project Structure i lt s Captures i Build Variants Edit View Wavigate Code Analyze Refactor Build Ru Seer PA QA 5 Hit Ea FtcRobotController O manifests B java H com qualcomm ftcrobotcontroller kd opmodes Ga Oa ici ice h a ioe a h ci
93. open the claw slightly by decrease the claw s servo position IMPORTANT NOTE for the event driven programming model it is important that you do not block within the loop method This means that in the loop method you do not want your code to dwell wait within the method Your code should do what it needs to do then exit the loop method as soon as possible For example you should avoid sleeping or waiting within the loop event There are certain tasks that need to be executed for the FTC Robot Controller app These tasks occur in between the loop events If your program waits or blocks within the loop event it could cause negative effects for your robot controller 9 3 3 3 Telemetry Statements In the Loop method for the K9TeleOp program module you can see that there are some telemetry statements in the code telemetry addData Text Robot Data t telemetry addData arm arm Double toString armPosition telemetry addData claw claw Double toString clawPosition telemetry addData left tgt pwr left pwr Float toString left telemetry addData right tgt pwr right pwr Float toString right Figure 139 There are several telemetry statements in the example run method The new robot control platform allows you to send telemetry data from the robot back to the driver Station In Figure 139 you can see that a method called addData is called five times in a row This addData
94. or build and install apps for the Android operating system App development might seem intimidating at first However for the FTC robots the process is fairly simplified The engineers at Qualcomm have developed an Android framework for the FTC robots This framework takes care of much of the more complex programming tasks The student or mentor can focus on programming the robot behavior and not have to worry much about developing the framework of the app 6 3 MIT Google App Inventor Work is being done to integrate the new FTC platform with the MIT Google App Inventor http appinventor mit edu explore The App Inventor is a user friendly server based tool to create Android apps using a visual development environment The App Inventor is being modified so that it will able to support the FIRST Tech Challenge hardware Teams will eventually be able to use the App Inventor to create apps for their competition bots Unfortunately the App Inventor will not be covered in this manual A separate App Inventor training manual will be available 6 4 Java Java is a popular text based object oriented programming language Android apps are written using Java syntax The programs that we will be using in this tutorial require a basic knowledge of Java Unfortunately the scope of this document does not allow for a detailed examination of the Java programming language However the Oracle Corporation maintains an excellent free online Java tutoria
95. ore you use your gamepad make sure that the Logitech F310 is in Xbox emulation mode This means that the little switch on the bottom of the controller should be set to the X position Figure 91 Make sure the switch is in the X position The Settings menu also lets you select the option to Log Network Traffic This option can be useful if you are debugging your wireless connection it logs information about packets sent to and from the robot controller but this option can use up all of the storage on your Android device very quickly We do not recommend that you use this option and you should never have this feature enabled during a match The Settings menu also has an option to pair the driver station to the robot controller You need to connect or pair your driver station to a specific robot controller We will review this pairing process in greater detail later on in this document 8 1 3 2 Restart Robot The FTC Driver Station menu has an option called Restart Robot This option will do a remote soft restart of the robot controller Sometime the robot controller might enter a stop mode Inthe event that this happens the driver can issue a remote restart command to the robot controller with this option The Driver Station needs to be connected to a Robot Controller in order to restart the robot 8 1 3 3 About Menu Selecting the About menu option will bring up a screen which displays info about the app version and the build v
96. ote the installation location of the Android SDK Continue with the installation process Note that Android Studio is a large program and it can take a long time to install the required components Please be patient and wait for the install to complete BET Android Studio Setup Installation Complete Setup was completed successfully Figure 21 Android Studio can take a long time to install the required components Once the installation is finished press the Finish button to close the Installation Wizard and to launch Android Studio FTCTraining Manual v0_93 docx Page 19 of 102 DRAFT Contents Subject to Change _ Android Studio Setup Completing the Android Studio Setup Android Studio has been installed on your computer AX Click Finish to dose Setup Android StUQ Figure 22 Press Finish to complete the install and to launch Android Studio When the Android Studio software is launched it might prompt you to import Android Studio settings from a previous installation of the software Unless you are an advanced user who has previous Android Studio settings that you would like to preserve select I do not have a previous version of Android Studio or do not want to import my settings and click OK to continue You can import your settings from a previous version of Android Studio Specify config folder or installation home of the previous version of Android Studio I do not have a
97. our device to the robot controller you should see a WiFi Direct message on the driver station main screen indicating that the driver station is now connected to a robot controller F3 FTC Driver Station Device Name ZTE 029 Wifi Direct Connected to ZTE 030 Ping 4ms RobotController battery level 76 0 Robot Battery Level 12 92 current op mode Stop Robot Select Stop Robot is stopped User 1 User 2 Gamepad type F310 Ix 0 00 ly 0 00 rx 0 00 ry 0 00 It 0 00 rt 0 00 Figure 114 This driver station is now connected to a robot controller named ZTE 030 Once your driver station is paired with its robot controller you are ready to begin executing op modes FTCTraining Manual v0_93 docx Page 73 of 102 DRAFT Contents Subject to Change 8 3 Selecting and Running Op Modes Operational Modes or Op Modes are program modules that you can execute to have your robot perform specific behaviors The downloaded Android apps that you installed should include some pre installed op modes that you can select and run If your robot has been successfully paired to the driver station and if the robot is running i e Legacy Module is powered on and connected then the Op Mode buttons on the FTC Driver Station app should now be enabled P i gO E 11 37 am F3 FTC Driver Station Device Name ZTE 029 Wifi Direct Connected to ZTE 030 Ping 4ms RobotController battery level 76 0 Robot Battery Leve
98. p Installed E Pa Android SDK Platform tools f amp Installed El P Android SDK Build tools 2 amp amp Installed E Pa Android SDK Build tools l Not installed El A Android SDK Build tools Not installed El Pa Android SDK Build tools _ Not installed El Pa Android SDK Build tools 2 _ Not installed El Pa Android SDK Buid tools Not installed E 4 Android SDK Build tools _ Not installed El A Android SDK Build tools i Not installed E y4 Android SDK Build tools 19 03 Not installed E 4 Android SDK Build tools 2 Not installed I Android SDK Build tools Not installed Show Updates New Installed Select New or Updates Install 9 packages Obsolete Deselect All Delete packages C os Done loading packages FTCTraining Manual v0_93 docx Page 22 of 102 DRAFT Contents Subject to Change Figure 27 The SDK Manager shows what software packages are available and what have been installed The Android Studio development environment will use the SDK tools to build your Android app You can configure the Android Studio software to use different versions of the SDK tools to build your app Sometimes you might want to use a more recent version such as Android SDK Tools revision 24 0 2 of the tools because they contain bug fixes or new features that you would like to incorporate into your app Other times you might want to use an older version of the SDK tools becaus
99. r Select thi option when fe ba f Connect to PL software unavailable Media device MTP Use phone as USB storage and transfer files when it is connected to Windows PC or Mac Camera PTP Use camera software to transfer pictures from phone to PC Enable USB debugging Don t ask me again Help Figure 73 Select the Charge only option If have successfully installed the USB driver on your PC then your ZTE Speed phone should prompt you on whether or not to allow USB debugging by your PC 8 9 29 am The computer s RSA key fingerprint is C8 AE D0 7F 50 C0 48 78 8F CC F7 C7 DB 9C 41 40 Always allow from this computer Cancel Figure 74 Select the Always allow option and hit OK Note that if you do not see this prompt you can unplug your phone from the USB cable wait a few seconds and then reconnect your phone to the cable You should now see the prompt Select Always allow from this computer option and hit OK to allow USB debugging access for your PC FTCTraining Manual v0_93 docx Page 48 of 102 DRAFT Contents Subject to Change Once you have successfully installed the driver and configured your ZTE Speed phone you should see the phone appear as an available Android device in the Android panel of Android Studio telemetry addData right tgt pwr right pwr Fr Podo fa Fam green fro on mada 71g fire Ha gsh load rt 1 FHEH mi iF F E Gi i Gradle Console E Android LL 2
100. r class in the opmodes folder to open the file in the editor In the editor window look for the following line manager register NullOp NullOp class gt Manager register K9TeleOp K98TeleOp class Manager register K9TankDrive K9TankDrive class gt Manager register K9Line K9Line class Manager ja ii eter Kol rseeker cane eal i Qc g F ii T m Tr Fi mE P La aia i F ee er ee ii raj manager register j Seekertp IrSeckertp class i Eii ma m E ES FF EEE EEE Se E ae s T a mn gT Giri of a 5 J 1h i ami TY nmr mye j a Fa ga ga a ma Wafer FEGLS Ler Ompas La LLOFA LLON F LOMpasslLallera LLOND class r e m m m oo e m de i ee M T o PE ETa aide MI a T a T ee l Figure 146 Look for the line that reads manager register K9AutoTime K9AutoTime class Use your mouse and keyboard to insert the following text after the line shown in Figure 146 4 i Hh ctr T 4 Fe Ej LJ Fa it Li Ta 1 LJ Di thi Ly Eli Fe tb a ip iy a L Ct tb Fa th F x thi Ly Fli th Manager register NullOp NullOp class Manager register K3TeleOp BKS8TeleOp class Manager register K9TankDrive K9TankDrive class Manager register K9Line K9Line class gt manager register K9IrSeeker K9lirseeker class Manager Aa EE at a Le cat K9AutolTime class r Figure 147 Insert manager register MyTeleOp
101. re onto your computer i Java SE Development Kit 7 Update 71 64 bit Setup ORACLE Welcome to the Installation Wizard for Java SE Development Kit 7 Update 71 This wizard will guide you through the installation process for the Java SE Development Kit 7 Update 71 The Java Mission Control profiling and diagnostics tools suite is now available as part of the JDK Figure 13 Follow the steps of the Installation Wizard When prompted select the default recommended settings from the Installation Wizard FTCTraining Manual v0_93 docx Page 15 of 102 DRAFT Contents Subject to Change a Pe J Java SE Development Kit 7 Update 71 64 bit Custom Setup a S 2 java ORACLE Select optional features to install from the list below You can change your choice of features after installation by using the Add Remove Programs utility in the Control Panel Feature Description H Development Tools Java SE Development Kit 7 Update 71 64 bit induding the JavaFX SDK a private JRE a private JavaFX runtime and the Java Mission Control tools suite This will require 300MB on your hard drive C Program Files Java jdk1 7 0_71 Figure 14 Select the default recommended settings for the installation After the installation is complete hit the Close button to close the Installation Wizard You do not need to click on the Next Steps button Development Kit 7 Update 71 64 bit Comple
102. roid Developer s website http developer android com sdk index html Android Studio is available on the MacOS Windows and Linux operating systems This version of the manual currently only describes how to install Android Studio for the Windows environment 7 3 System Requirements Before you download and install the Android Studio you should first check the list of system requirements on the Android developer s website to verify that your system satisfies the list of minimum requirements http developer android com sdk index html Requirements 7 4 Installing the Java Development Kit You will need to download and install the Java Development Kit JDK onto your computer prior to installing the Android Studio software At the time this document was originally written Android Studio requires the JDK version 7 for Windows installations The JDK version 7 software can be downloaded from the Oracle com website http www oracle com technetwork java javase downloads jdk7 downloads 1880260 htm If you visit the JDK download website you will want to select either the Windows X86 download file if you are using a 32 bit version of Windows or the x64 download file if you are using a 64 bit version of Windows At the time of this writing JDK 7u75 is the kit you should download FTCTraining Manual v0_93 docx Page 14 of 102 DRAFT Contents Subject to Change Java SE Development Kit 7u71 You must accept the Oracle Binary Code Licen
103. s Figure 95 After you install the app an icon should be visible on your Android device The FTC Robot Controller app should also auto launch whenever it is plugged into the Power Module and connected to the USB electronic modules on the robot When you first connect the Robot Controller Android device to the Power Module the Android operating system might prompt you on whether or not it s OK to launch the FTC Robot Controller app whenever this USB device is connected You should check the Use by default for this USB device option and hit OK Note that the Android operating system might prompt you multiple times once per connected USB module You should check the Use by default option and hit OK each time you are prompted After you have configured the FTC Robot Controller to be the default app for the connected USB modules this app should auto launch whenever it detects any of the previously detected USB modules Open FTC Robot Controller when this USB device is connected Use by default for this USB device ear default in System setti Downloader Cancel Figure 96 Check the Use by default Option and hit OK FTCTraining Manual v0_93 docx Page 63 of 102 DRAFT Contents Subject to Change 8 2 3 Creating a Configuration File for the Robot Controller When you first launch the Robot Controller app it might complain to you because it doesn t have an active configuration file that it can use The app
104. se Agreement for Java SE to download this software Accept License Agreement Decline License Agreement Product File Description E Linux x86 119 44 MB amp jdk 7u71 inux i586 rpm Linux x86 136 76 MB jdk 7u71 linux i586 tar gz Linux x64 120 81 MB jdk 7u71 inux x64 rpm Linux x64 135 63MB jdk 7u71 linux x64 tar gz Mac OS X x64 185 84MB amp jdk 7u71 macosx x64 dmg Solaris x86 SVR4 package 139 36MB jdk 7u71 solaris i586 tar Z Solaris x86 95 48MB jdk 7u71 solaris i586 tar gz Solaris x64 SVR4 package 24 68 MB jdk 7u7 1 solaris x64 tar Z Solaris x64 16 36MB jdk 7u71 solaris x64 tar gz Solaris SPARC SVR4 package 138 74MB jdk 7u71 solaris sparc tar Z Solaris SPARC 9862MB jdk 7u71 solaris sparc tar gz Solaris SPARC 64 bit SVR4 package 23 94 MB jdk 7u71 solaris sparcv9 tar Z Solaris SPARC 6dehi B Fete selefic palcy Windows x86 127 78MB jdk 7u71 windows i586 exe Windows x64 129 52MB jdk 7u71 windows x64 exe Figure 12 Select x86 for 32 bit versions of Windows or x64 for 62 bit versions of Windows Note that you will only need the JDK 7 software You do not need to download any of the extra files that are available on the Oracle website such as the Demos amp Samples download Once you have the executable file downloaded from the Oracle website double click on the file to open it and start the installation Follow the steps of the Installation Wizard to install the softwa
105. see Figure 127 Click on the Project tab on the left side of the Android Studio window to see the project folder view FTCTraining Manual v0_93 docx Page 81 of 102 DRAFT Contents Subject to Change File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help Oo ape spafoig uae 3 y v 3 a i 2 g 2 a vy Build Variants J 2 Favorites E Terminal oj 6 Android 0 Messages TODO E EventlLog Gradle Console Gradle build finished in 18s 645ms 2 minutes ago a g Figure 127 Click on the Project tab to view the project folder in Android Studio In the left hand pane of the Android Studio window you should see the FtcRobotController Project folder You can click on the folder to expand it and see its subfolders and the project structure o x Ele Et View Nevgnte Code Anabae Befacior Build Ryn Tool VCS Window Help HHO e TM ARS gt HFA gt ek RSL AH apeg spafoig uaren 3 zi t a ey vy D i 5 is uw cay Build Variants El Terminal 6 Android 0 Messages TODO E EventlLog Gradle Console Gradle build finished in 18s 645ms 10 minutes ago Figure 128 Expand the FtcRobotController to view the project structure 9 2 Building the Robot Controller App If you were able to import the project successfully into your Android Studio environment then you are ready to build the Robot Controller app and install it on your Android
106. seereserersseereserereseeresereeeseerese 49 D Wee ror RODO anana NE 53 8 1 PEG DRIVER Stall OM areenat a e A idence wands 53 8 1 1 Installing the FTC Driver Station App ccccccsscccccssecccceseccceescceceesececeeneceeseenceeeeeneceesenesss 53 8 1 2 hauinching the FTE Driver Stallions a a a A 56 8 1 3 Divers taNOnME NU nire A A ea soe oa eee ater enedles 58 8 1 4 Usine the Gamepads arenis A a N 60 8 1 5 OPMOIE CONTOS aA T A E 61 8 2 RODOU CONTONE saen E E 61 8 2 1 Installing the Robot Controller App erena a A a 62 8 2 2 Launching the Robot Controller App sesesesenesrereseseresrererureresrereruneresrereruneresserereneresserersreress 62 8 2 3 Creating a Configuration File for the Robot Controllef ssssessssereesrrrerresereesrrresrresrerseee 64 8 2 4 Pairing the Driver Station to the Robot Controller cccccssccccsseccccsecceeeescceeeseceseeneees 70 8 3 Selecting and RUDNINE OP MOGE Seeria a a a N 74 9 NEQU COMM F IrCRODOT SDK ierra E EEE E 78 9 1 ANECESSING the SDKOMOIHUD e E ase aliens aes 78 9 2 Buildine the RODO CONTOS AD Dsnirugennm A S 82 9 3 Building Your OWN Op Mode aeri on a EA 85 9 3 1 FtcRobotControllerOpmodes Folder earinnaeioneni ann e r O A 85 9 3 2 FteOpModeRegist r java File ser a e A A a a added 86 9 3 3 Op Mode Lre Cle saia a A 87 9 3 4 Makine Your Own Op Mod sinea aa a e N A 93 9 4 QualComim SDK Documentatii Npe a E 97 10 CONCUSSION eree E E N EE 99 FTCTraining Manual v0_93 docx Page 2 of 102 D
107. t Configure Docs and How Tos Android Studio 10 1 Build 135 1641136 Check for updates now Figure 30 Select Start a new Android Studio project from the Quick Start menu Android Studio will prompt you for some information about your new project You should provide a name for your project the default value of My Application is fine you can leave it there Also Android uses a naming scheme which uses the names from an Internet domain that you provide to make the Java classes that you create unique Android Studio will store your classes using this domain name This helps avoid conflicts with classes that you might use from other software libraries For this example you can leave the default domain name jwierman example com in the screen shot below yours will be slightly different FTCTraining Manual v0_93 docx Page 25 of 102 DRAFT Contents Subject to Change New Project Android Studio Configure your new project Application name TE atin Package name com example jwierman myapplication Edit Project location C Users jwierman AndroidStudioProjects MyApplication Figure 31 You can accept the default values for the application name domain and project location The next screen prompts you for the minimum SDK version that you want to target your app to work with Since our app is going to be a simple one we can target an older version of the Android Operating system Accept the default val
108. t none Copy Paste s Move Copy Delete Rename New Properties e a Paste shortcut toy tor X folder o Pa History oo Invert selection Clipboard Organize New Open Select T a lt Tom gt AndroidStudioProjects ftc_app master y Search ftc_app master A A 49 Favorites CO Name Date modified Type Size E Desktop I gradle m3 Downloads di idea D buia Recent places J doc 6 2 2015 9 02PM _File folder SkyDrive di FtcRobotController 6 2 2015 9 11 PM File folder J gradle 6 2 20159 02PM_ File folder 6 2 2015 9 02 PM GRADLE File 6 2 2015 9 02 PM IML File 6 2 2015 9 11 PM IML File 6 2 2015 9 02 PM File 6 2 2015 9 02 PM Windows Batch File 6 2 2015 9 03 PM PROPERTIES File A 2 2015 O02 DM MN File 6 2 2015 9 11 PM File folder 6 2 2015 9 11 PM File folder 6 2 2015 9 11 PM File folder gt e Homegroup _ build gradle _ ftc_app iml a jM This PC D k Desktop gt F Documents gt JB Downloads D J Music n IE n a Es 14 items 1 item selected _ ftc_app master iml _ gradlew gradlew _ local properties RFANMF me Figure 149 You must uncompress the archive file to access the documentation To access the documentation open the doc folder and then open the javadoc subfolder on the file index htm to launch your web browser and to view the documentation Open zr Favorites MB Desktop Mp Downloads E Recent Places 2 Dropbox Libraries jE Computer Local Disk C H
109. t you have full legal authority to bind your employer or such entity to this License Agreement If you do not have the requisite authority you may not accept the License Agreement or use the SDK on behalf of your employer or other entity Z have read and agree with the above terms and conditions Download Android Studio for Windows Figure 17 Accept the license agreement and click blue button to begin download Once you have downloaded the installation file double click on it to begin the install process An Installation Wizard should appear Follow the steps of the Installation Wizard to install the software FTCTraining Manual v0_93 docx Page 17 of 102 DRAFT Contents Subject to Change WT Android Studio Set Welcome to the Android Studio Setup Setup will guide you through the installation of Android Studio It is recommended that you dose all other applications before starting Setup This will make it possible to update relevant system files without having to reboot your computer Click Next to continue Figure 18 Follow the steps of the Installation Wizard to install the software When prompted by the Installation Wizard select the default values for the settings and continue with the installation process Check the components you want to install and uncheck the components you don t want to install Click Next to continue Select components to install Android SDK Android Virtual Device P
110. the Android code This source code is available to the public under an open source license Google provides free developer tools that can be used to write applications or apps for the Android platform Starting with version 1 5 the different versions of Android are denoted by their version number and by the name of a dessert or candy Android version 1 5 is known as Cupcake Android 4 4 is known as Kit Kat As of the January 2015 the most current version of Android 5 0 is known as Lollipop en wikipedia org wiki File Android robot svg Retrieved December 4 2014 See http developer android com about index html for details ji http en wikipedia org wiki Android_ operating_system Retrieved January 15 2015 FTCTraining Manual v0_93 docx Page 12 of 102 DRAFT Contents Subject to Change 6 2 Android Studio The driver station tablet and the robot controller smartphone run special apps for the FTC competition These apps are created using tools that are provided for free by Google The official development tool for Android development is known as Android Studio n order to be able to write programs to control a robot you will need to learn how to build apps using Android Studio Android Studio is a tool known as an Integrated Development Environment IDE Android Studio is a software package that you install onto a computer or laptop It has a suite of tools such as a text editor debugger and other tools to help auth
111. tps github com ftctechnh ftc_app q This repository Explore Gist Blog Help 42 ftctechnh 7 O amp P ftctechnh ftc app Unwatchy 2 we Star o0 YFork 2 FTC Android Studio project to create FTC Robot Controller app lt gt Code 10 i 1 3 1 D Issues branch master ftc_app I Pull requests added javadoc documentation note that the javadoc documentation has Wiki Thomas Eng latest mit 4e835bab1 fe EE FtcRobotController eaned up and some old files i Pees E doc j that t t di Graphs Ei gradle wrapper nitial uploac B README md reate README md 2 Settings B build gradle EN A i PAR HTTPS ftc_app iml nitial uploa B gradlew nitial uploa You can clone with HTTPS SSH B gradlew bat or Subversion B settings gradle nitial upload 6 days ago ffl Clone in Desktop lt gt Download ZIP EE README md Figure 120 SDK is available on GitHub Press Download ZIP to download the project folder as a ZIP file If you are not familiar with how to use git you can also download the project folder as a compressed file zip To download the project folder as a compressed archive look towards the lower right hand side of the repository s webpage for a button labeled Download ZIP This will start the download process Once the file has been downloaded locate the downloaded file and move it to its desired folder on your computer FTCTraining Manual v0_93 docx Page 78 of 102 DRAFT Contents Subject to Change
112. u browse the source code you will discover that the K9TeleOp is a Java class that reads gamepad input that was sent to the robot controller from the driver station The op mode uses this gamepad input to control the DC and servo motors on the robot If you take a look at the structure of the K9TeleOp code you will see that there are three functions or methods that are defined for the class These methods are named start loop and stop Every op mode that you will create should have its own start loop and stop methods in its class definition These three methods correspond to the three distinct stages of an op mode s life cycle 1 start When an op mode is executed by a driver i e when the driver pushes the Start button on the touch screen the start method for the selected op mode gets triggered If you have any initialization tasks that you would like to do for your robot you can place the initialize code into the start method s body 2 loop When a driver pushes the Start button on the driver station the code that is written in the op mode s Loop method will be executed regularly approximately every 25 milliseconds The robot controller app has a built in event loop that executes the contents of the Loop method repeatedly until a stop command is received from the driver station or unless an emergency stop condition occurs This method is where you will put the bulk of your robot code for an op mode
113. ue which in the following screen shot is Android 4 0 3 Ice Cream Sandwich New Project Android Studio Select the form factors your app will run on Different platforms require separate SDKs v Phone and Tablet Minimum SDK API 15 Android 4 0 3 IceCreamSandwich v Lower API levels target more devices but have fewer features available By targeting API 15 and later your app will run on approximately 87 9 of the devices that are active on the Google Play Store Help me choose Minimum SDK _ Wear L Glass Not Installed Minimum SDK o S Figure 32 Accept the default minimum SDK version that your app will work with and press Next Android Studio will prompt you to specify what type of activity that you would like to add to your project An activity is like a window on a computer application An activity is a container that holds widgets for your Android app Make sure the default activity type a Blank Activity is selected and press Next to continue FTCTraining Manual v0_93 docx Page 26 of 102 DRAFT Contents Subject to Change Add an activity to Mobile Add No Activity Blank Activity with Fragment Fullscreen Activity Google Maps Activity Ce annn annn Figure 33 Select the Blank Activity type and hit Next Android Studio will prompt you for information about the blank activity that it will create for your project You can accept the default values and push the Finish
114. ver controlled program la Saving screenshot faq FTC Driver Station Device Name ZTE 029 Wifi Direct Connected to ZTE 030 Ping 2ms RobotController battery level 70 0 Robot Battery Level 12 76 Status info displayed here current op mode K9TeleOp Current op mode Press to stop robot immediately Select kk Robot Data Telemetry data can be sent arm 0 20 back from the robot to the claw 0 20 driver station and displayed left pwr 0 00 right pwr 0 00 in this area Local gamepad activity and state info are displayed towards the bottom of the screen User 1 Gamepad type F310 Ix 0 00 ly 0 00 rx 0 00 ry 0 00 It 0 00 rt 0 00 Figure 118 The screen displays useful info during an op mode run The driver station screen displays useful information during an op mode run The WiFi connection status info ping time is continuously updated at the top of the screen The name of the current running op mode is displayed below the ping information The Select and Stop mode buttons are still enabled You can hit the Stop button to force the robot to stop immediately Underneath the Op Mode controls there is an area reserved for telemetry data from the robot The software development kit that has been developed by QualComm has a feature that lets you send data any kind of data battery voltage levels sensor data motor speed and position time etc back from FTCTraining Manual
115. y development device In order to be able to be able to use this device with the Android Studio software you will need to make sure the phone has Developer Options enabled and that the USB Debugging mode is enabled FTCTraining Manual v0_93 docx Page 40 of 102 DRAFT Contents Subject to Change Detailed instructions on how to enable the Developer Options mode and how to connect an Android device to Android Studio are available on the Android developer website http developer android com tools device html If your Android device is not yet in developer options mode you can go to the settings screen of your Android device touch the icon that looks like a cog or gear and go to the Settings gt About phone activity Look for the Build number or in the case of the ZTE Speed look for the SW Version of your phone Tap the Build number or SW Version number seven times to enable Developer Options on your device z 4 79 9 54 PM i B 8 35 am lt About phone About phone Lega mtormation Icon glossary Status 4 i Show status of battery network and other G settings information Legal information Model number N9130 Phone name SAMSUNG SM N910V Android version 4 4 4 Baseband version N9130B01 Kernel version 3 10 28 g1d9936e 00247 g6a6f8a8b zte kernel Zdroid SMT SW Version N9130V1 0 0B05 HW Version cwfB Figure 62 Tap on the Build number left or SW Version number right 7 times to enable Dev
116. y the Wi Fi activity Wi Fi FTC5thFloor Secured with WPA2 WPS available FIRST_McAuliffe Secured with WPA2 SEEPublic Open FIRST 5 South Secured with WPA2 SEEAcademy Secured with WPA WPA2 iGlobe Secured with WPA2 Moveras Secured with WPA2 WPS yy Jr Figure 81 Select your wireless network from the Wi Fi activity Select your desired wireless network from the Wi Fi activity and provide the password information required to access the wireless network FTCTraining Manual v0_93 docx Page 53 of 102 DRAFT Contents Subject to Change oes E F B 11 11 am Figure 82 Launch the Google Play Store app Once you have connected successfully to your wireless network launch the Google Play Store app from your phone The Play Store app might prompt you to either login to an existing Google account or create a new one Follow the onscreen instructions to either create a new free account or login to your existing account Once you have successfully logged in to Google Play click on the search icon a little magnifying glass and search for the phrase FTC Driver Station Il USB debugging connected FS fte driver station Apps d 1 FTC Driver Station FIRST Tech Challenge FTC Ak FIRST Toch ChaWongo FREE 2 FTC Robot Controller FIRST Tech Challenge FTC FIRST Tech Challenge FREE Figure 83 Search for the phrase FTC Driver Station Once you have found the FTC Driver
117. your configuration file the Configure Robot screen should display the name of the current active configuration file in the upper right hand corner of the screen lw Saving screenshot 3 Configure Robot Scan Press this button to scan for attached devices Devices o Motor Controller 1 Servo Controller 3 Legacy Module 2 Save Configuration o Press this button to write the current configuration to an XML file Figure 107 The name of the active configuration file is displayed in the upper right hand corner FTCTraining Manual v0_93 docx Page 69 of 102 DRAFT Contents Subject to Change Press the back arrow button on your Android device to return to the main FTC Robot Controller screen The name of the active configuration file should now be visible in the upper right hand corner of the main screen Hane F 8 2 43 pm EA FTC Robot Controller Device Name ZTE 018 Wifi Direct enabled Robot Status running Figure 108 The active configuration file is displayed in the upper right hand corner of the main screen 8 2 3 1 Module Serial Numbers Before we move on it is important to note that each configuration file for a Robot Controller is matched to the specific hardware on the machine Each USB enabled device on the robot has its own unique serial number This unique serial number is stored in the configuration file If you replace one of the USB enabled devices such as a Legacy Module with another equival
Download Pdf Manuals
Related Search
Related Contents
Toshiba Equium 100 PC Desktop CDS-9020 - ARC Electronics Brochure mobilité Psychologie étudiants étrangers 2012-2013 MELSEC iQ-F FX5 Simple Motion Module User`s Manual (Startup) principíos de cocción del horno microondas Samsung SP-A400B Priručnik za korisnike I2100 232 manual Do not drive in - Arizona Kawasaki Sony VGNZ899GSB Marketing Specifications Copyright © All rights reserved.
Failed to retrieve file