FTC – Java Programming

2y ago
738.07 KB
37 Pages
Last View : 14d ago
Last Download : 2m ago
Upload by : Grady Mosby

Kettering FTC WorkshopFTC – JAVA PROGRAMMINGWorkshop 2015Eric WeberFRC: 1322, FTC: 5954 & 7032EW - 2015

Kettering FTC WorkshopJava History First appeared in 1995 Sun Microsystems creates and maintains the corelanguage Community involvement is very high in thedevelopment Appears in many small devices Want college credit in Computer Science?– Java is the standard language for AP CS courses Most importantly, it is currently the gateway intoother languages– Know java? You know C, C , C#, Python, Ruby, Pascaland many others with minimal understandingEW - 2015

Kettering FTC WorkshopWhat you will need? Android Studio– http://developer.android.com/sdk/index.html#top FTC App– https://github.com/ftctechnh/ftc app/archive/master.zip Tutorial for setting up phones– https://github.com/ftctechnh/ftc app/blob/master/doc/tutorial/FTCTraining Manual.pdfEW - 2015

Kettering FTC WorkshopIf you haven’t followed the instructionsonhttp://paws.kettering.edu/ webe3546/Start DownloadingThe process will take a long time tocomplete4EW - 2015

Kettering FTC WorkshopIntroducing the UIProject TabCompilerSource Code EditorEW - 2015

Kettering FTC WorkshopImportant Definitions IDE (Integrated Development Environment):– Android Studio itself is an IDE. It contains a sourcecode editor, compiler, and a debugger all in one. OP Modes: define how our robots behave– Teleop and Autonomous modes are now called OPModes Keywords: Reserved words that Java requires, andcannot be used as an unique nameEW - 2015

Kettering FTC WorkshopTELEOP EXAMPLE CODEWill work with the robot being built during this workshop.EW - 2015

Kettering FTC WorkshopCode Objective:Don’t write this down yet.We will cover this line byline.EW - 2015

Kettering FTC WorkshopTeleop Mode Example: This code is strictly for a simple tele OP mode Not optimal for programming a robot with anautonomous mode Equivalent to a ‘Hello World’ for the robot that isbeing built in the class rooms upstairsEW - 2015

Kettering FTC WorkshopCreating an OP Mode:1) In the Project Tree Navigate:- FTC APP - FtcRobotController - src - main - com.qualcomm.ftcrobotcontroller - opmodes3) Right Click on the Folder4) Go to “New” - “Java Class”5) Give it a name6) Click “OK”EW - 2015

Kettering FTC WorkshopEdit Class Definition: Once we have created our OP Mode, we need toedit a line immediately. Please add “extends OpMode” between the nameof class and the “{“EW - 2015

Kettering FTC WorkshopAnyone Notice This? Then you may auto complete with theselected word below Press the “Tab” key to allow completion. A benefit of using an IDE allows easierfunctionalityEW - 2015

Kettering FTC WorkshopImportant Notes: First we are defining a public class– Classes defines data formatting and procedures– Public defines how it may be accessed In this case, anywhere Second we have a unique name for these classes– Must be unique and not be a keyword Third we are extending a parent class (Inheritance)– We are directly adding onto a class already made– We also gain the functionality of this classEW - 2015

Kettering FTC WorkshopDefine Properties Next we will enter in the following below These are what are called properties or fields– From here on out, we will refer to them as propertiesEW - 2015

Kettering FTC WorkshopImportant Notes: Properties allow us to define data to be used In this case we are defining:– 1 DcMotorController (a class soon to be an object)– 2 DcMotor (another class soon to be an object) Later we will be able to effect the values of the DCMotors In non-OOP languages, these are also known asvariables (RobotC) If you want more, you have to define moreEW - 2015

Kettering FTC WorkshopOur first Method Methods allow us to perform tasks Please enter the next lines after our properties:EW - 2015

Kettering FTC WorkshopImportant Notes: First off, @Override allows us to over write aprevious method from OpMode.– This is one of two methods that MUST be overridden.– This will always be the first method called once theARM button is pressed on the robot controller. Second, we are assigning actual objects to theproperties we already have definedEW - 2015

Kettering FTC WorkshopImportant Notes: Third, what is hardwareMap?– It is an object that contains all the hardware mappingas defined by the configuration files on your RobotController app– Everything stated by your robot configuration file willbe here. This makes setting up your configurationcorrectly and translate it EXACTLY into your javacode.EW - 2015

Kettering FTC WorkshopOur Second Method The second method we must override is the loop()method. Please enter the next lines after our previousmethod.EW - 2015

Kettering FTC WorkshopImportant Notes: This method is called every time the robot cycles(approx. 20ms give or take) Not where to apply a loop Since a part of OpMode, this will be consistentwith autonomous OpModes as wellEW - 2015

Kettering FTC WorkshopFinal step: Register your OpMode We need to finalize the app by registering our OpMode with therest of the program. Navigate through the project tab to: ftc app-master - FtcRobotController - src - main - java - com - qualcomm - ftcrobotcontroller - opmodes - FtcOpModeRegister Under the register method, type: manager.register(“Tutorial”,Tutorial.class);EW - 2015

Kettering FTC WorkshopImportant Notes: To be able to select your OpMode, it needs to beadded to a list. I have already trimmed down the OpModes thatwere used as tutorials. NullOp will do nothing.– Good to keep due to any issues that arise.EW - 2015

Kettering FTC WorkshopImportant Definitions: Class: Defines data format and proceduresProperties: Variables defined by the classMethods: Procedures that work on inputs or propertiesInheritance: The ability to extend a class to include morefunctionality (methods) or data (properties) Overriding: The ability to take a method and change it togive different functionality Constructor: As an object is created, a special method isalways called immediately.EW - 2015

Kettering FTC WorkshopSTRUCTURAL SUGGESTIONSIdeas to extend your code from Teleop to Autonomous modes24EW - 2015

Kettering FTC WorkshopHierarchy Object Oriented Programming’s Greatestasset is reusability and extensibility. Better to define a robot by its actions, thencontrol it through those actions.CoreFunctionsTeleopModeTestZoneAutoModesEW - 2015

Kettering FTC WorkshopKey Ideas on Inheritance Inheritance Properties:– Extending a base class forces the base class to exist,giving us those methods as well Think drive systems, arms, sensors, or timers required But know about Private, Public, and Protected– We only need to override the operation modes wewant.– For instance, leave initialization for the base class, onlywork with loop() in the actual OpModes.EW - 2015

Kettering FTC WorkshopImportant Keys to Note: Methods with inheritanceOverriding (Virtual Methods)OpModesEncapsulationEW - 2015

Kettering FTC WorkshopNOW AN OPEN DISCUSSION.Questions and Suggestions?What would you like to see28EW - 2015

Kettering FTC WorkshopAUTONOMOUS MODEA method to accomplish tasks in Autonomous mode29EW - 2015

Kettering FTC WorkshopState Machines For this style of programming, State Machines arethe suggested method. Review of State Machines:– Idea of states: Set of instructions unique to a phase ofa program– States define what the robot is to do– Redefine outputs– Read inputs to trigger next stateEW - 2015

Kettering FTC WorkshopState Machines Requirements of a state machine:––––A state variable (usually an enumeration)A state selector (always a case-switch operator)State triggers (sensors or timers)An initial stateInitializeDriveForwardCheckEncodersStopEW - 2015

Kettering FTC WorkshopEnumerations: Enumerations are unique names with valuesdefined behind them Common examples include compass directions(values of NORTH, SOUTH, EAST, and WEST) Place above the actual OpModeEW - 2015

Kettering FTC WorkshopSwitch and Case Structure: Allows for multiple cases or states to make differentoperations Selector can take Enumeration’s, Integer’s commonlySwitch Structure – Refers to allcasesSelector – Selects whatever valueis enteredCase – Different states, as selectedby the selectorBreak- Escapes out of structureDefault- If no valid case exists,default will always be usedEW - 2015

Kettering FTC WorkshopTriggers: Usually done by an if statement– If statements are like case’s, but can easier to definewith logical statements Causes a change in our state variableEW - 2015

Kettering FTC WorkshopPutting it Together: We get the following OpMode:EW - 2015


Kettering FTC WorkshopThank YouNow get out their and program!EW - 2015

Kettering FTC Workshop EW - 2015 FTC –JAVA PROGRAMMING Workshop 2015 Eric Weber FRC: 1322, FTC: 5954 & 7032

Related Documents:

Java Version Java FAQs 2. Java Version 2.1 Used Java Version This is how you find your Java version: Start the Control Panel Java General About. 2.2 Checking Java Version Check Java version on https://www.java.com/de/download/installed.jsp. 2.3 Switching on Java Console Start Control Panel Java Advanced. The following window appears:

Former VP of Sales for Defendant Alliance Security Inc. FTC-0000219 : FTC-0000231 : 23 : Transcript of Deposition of Defendant Jasjit Gotra, CEO of Defendant Defendant Alliance Security Inc. FTC-0000232 ; FTC-0000261 : 24 ; Transcript of Deposition of Justin Ramsey, former Lead Generator and Telemarketer for Defendant Alliance Security Inc. FTC .

JAR Javadoc Java Language jar Security Others Toolkits: FX Java 2D Sound . Java Programming -Week 1. 6/25. Outline Java is. Let’s get started! The JDK The Java Sandbox . into your namespace. java.lang contains the most basic classes in the Java language. It is imported automatically, so

The Java Platform The Java platform has two components: The Java Virtual Machine (Java VM) The Java Application Programming Interface(Java API) The Java API is a large collection of ready-made software components that provide many useful capa

–‘java’ command launches Java runtime with Java bytecode An interpreter executes a program by processing each Java bytecode A just-in-time compiler generates native instructions for a target machine from Java bytecode of a hotspot method 9 Easy and High Performance GPU Programming for Java Programmers Java program (.

3. _ is a software that interprets Java bytecode. a. Java virtual machine b. Java compiler c. Java debugger d. Java API 4. Which of the following is true? a. Java uses only interpreter b. Java uses only compiler. c. Java uses both interpreter and compiler. d. None of the above. 5. A Java file with

besteht aus der Java-API (Java Application Programming Interface) und der Java-VM (Java Virtual Machine). Abbildung 1: Java-Plattform Die Java-API ist eine große Sammlung von Java-Programmen, die in sog. Pakete (packages) aufgeteilt sind. Pakete sind vergleichbar mit Bibliotheken in anderen Programmiersprachen und umfassen u.a.

Animal nutrition has pronounced direct impact not only on animal health but also indirectly through animal products on human health and through excreta on the environment. Due to increased awareness and concerns about animal health, due to increased incidence and severity of chronic non-communicable diseases in developed world that are linked to nutritional quality of (animal) food and due to .