FTC New Platform Programming Workshop in Android Studio












- Slides: 12

FTC New Platform Programming Workshop in Android Studio A Presentation by FTC Team 6022 Rockwell Automation Kickoff September 12 th, 2015

What’s New? • Android-Based Control Platform with Cell Phones • Replaces NXT/Samantha Control System • Robot Controller Phone is Mounted to Robot and Connected to Core Module • Driver Station Phone Connects to Two Joysticks • Utilizes Wi-Fi Direct Technology • Replaces Central FCS • Utilizes “Sports Start” to Begin Match Play • Controllers are USB-Based • Replaces I 2 C Protocol for Sensors and Controllers

What’s New? • Robot is Programmed through Android App Development in Java • Uses Android Studio, a Full Android IDE (Integrated Development Environment) • MIT App Inventor is Available as a “Scratch-Like” and “Drag-and-Drop” Interface • Java Information • Object-Oriented Language • Programmed through Editing Instances of the Op. Mode() Class • Will Be Discussed In-Detail Later…

Android Studio Setup (Should Be Completed) • Android Studio IDE • http: //developer. android. com/sdk/index. html • FTC Robot App Template (Git. Hub) • https: //github. com/ftctechnh/ftc_app • Project Configuration • Requires SDK Version 19 (Kit. Kat)

Types of Operation Modes Looping Op Mode Linear Op Mode • Defined as a Class • Motors, Sensors, Etc. are Referenced as Attributes in the Class • The “init()” Method Runs One Time • The “loop()” Method Runs Continuously Until Stop • Defined as a Class • Motors, Sensors, Etc. are Referenced as Attributes in the Class • The “run. Op. Mode()” Method Runs One Time

Defining and Using Motors Description of Process Code Syntax as an Example Op Class • First, we must create a variable to reference an instance of a motor object. • Second, we must reference the robot hardware map. • Third, we can set the power of the motor. Powers are a value between 0 and 1. public Dc. Motor test. Motor; @Override public void init() { test. Motor = hardware. Map. dc. Motor. get(“name. Here”); } @Override public void loop() { test. Motor. set. Power(0. 75); }

Defining and Using The Joystick Description of Process Code Syntax as an Example Op Class • This code assumes that we have already defined a motor as described in the previous slide. • The joysticks are already inherited into the op mode classes as gampad 1 and gamepad 2. • In the code to the right, the loop reads the y-axis of the leftmost analog stick on joystick 1 to allow a user to drive the motor. public Dc. Motor test. Motor; @Override public void init() { test. Motor = hardware. Map. dc. Motor. get(“name. Here”); } @Override public void loop() { test. Motor. set. Power(gamepad 1. left_stick_y); }

Other Useful Things • Telemetry Data • Allows for Robot Data to be Displayed on Driver Station • Example: telemetry. add. Data(“Title”, “Detail/Value”); • Sensors • SDK Includes Many Modern. Robotics and Lego Sensor Classes and Objects • Example: public Touch. Sensor button; button = hardware. Map. touch. Sensor. get(”sensor. Name”); telemetry. add. Data(“Button/Touch”, button. is. Pressed());

Where to Find More Information • The SDK provides Javadocs that outlines how to interact with different methods, classes, and objects. Javadocs can be found in the “doc” folder of the SDK. • Read through example op mode classes in order to get a feel for the code flow and see different uses of programming techniques.

Challenge #1 • Read Axis Values from a Joystick • Set Motor to Joystick Values to Create a Basic Teleop Mode

Challenge #2 • Drive Forwards for 2. 5 Seconds • Wait 1 Second • Drive Backwards for 2. 5 Seconds

Challenge #3 • Drive Forwards until Touch Sensor Pressed • Drive Backwards for 2 Seconds