Programming FTC Robots with Android Studio

Slides:



Advertisements
Similar presentations
US First Robotics Lab View Tutorials Jim Thomas Lawrence Berkeley National Laboratory Team 496 Port Jeff Powerhouse.
Advertisements

08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Jason Howard. Agenda I. How to download robotc II. What is tele-op used for? III. How to build a basic tele-op program IV. Getting the robot to drive.
Linking A quick overview of how to configure PulseWorx UPB devices to control each other.
Team 5220 Roboknights. Outline  Getting Started  Hardware Setup/Wiring  Software Setup/Pragmas  Programming with RobotC  Grammar/Syntax  Basic Statements.
 2005 Pearson Education, Inc. All rights reserved Introduction.
V EX C OACHES ' T RAINING October 12, Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
MT311 Tutorial Li Tak Sing( 李德成 ). Uploading your work You need to upload your work for tutorials and assignments at the following site:
Introduction to Sensors
Programming Part 1 Armond R. Smith Zhenying Wu. Overview of this Class ● Transition from FTC -> FRC ● Using Your Resources ● Java Keywords o Data Types.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Java: Chapter 1 Computer Systems Computer Programming II Aug
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
A First Program Using C#
Prepared by Uzma Hashmi Instructor Information Uzma Hashmi Office: B# 7/ R# address: Group Addresses Post message:
Copyright ©: SAMSUNG & Samsung Hope for Youth. All rights reserved Tutorials Software: Building apps Suitable for: Advanced.
© 2012 LogiGear Corporation. All Rights Reserved Robot framework.
Java: Chapter 1 Computer Systems Computer Programming II.
Weston Schreiber & Joshua Gabrielse Robotics Summer Training Programming #1: EasyC Basics.
Moodle (Course Management Systems). Assignments 1 Assignments are a refreshingly simple method for collecting student work. They are a simple and flexible.
IE 411/511: Visual Programming for Industrial Applications
The New FTC Platform (Connecting your legacy hardware)
Teacher/Mentor Institute Using easyC Joel Kirkland July 30-31, 2015.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
FTC New Platform Programming Workshop in Android Studio
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Making your Robot Move Motorbolts. Notes This presentation will be available on the High Tech Kids’ website: hightechkids.orghightechkids.org For more.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Java Programming The Ponytail Posse - FTC #8808 9/12/15.
1 Methods Introduction to Methods Passing Arguments to a Method More About Local Variables Returning a Value from a Method Problem Solving with Methods.
Session 11 Intro to FRC API.
Controlling Program Flow with Decision Structures.
Chapter 2 – The Little Crab Program:. Little Crab Scenario Inheritance: The Arrows Denote Hierarchy Crab is an Animal Animal is an Actor Therefore, It.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Programming and Debugging with the Dragon and JTAG Many thanks to Dr. James Hawthorne for evaluating the Dragon system and providing the core content for.
THE NEW MOBILE WORKSPACE Enable Business Applications on Mobile Devices hopTo Work “I am amazed to see how easily hopTo transforms the user interface of.
PROGRAMMING FTC ROBOTS WITH ANDROID STUDIO EAGLE ROBOTICS TEAM 7373 JORDAN MOSS AND BRIAN BAARS.
BEST Robotic, Inc. MATLAB/Simulink Team Training
INTRODUCTION TO ROBOTICS Part 5: Programming
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Development Environment
OpModes in FTC Eric Golde.
IDE and Phone Setup Overview Mike Zook 20-Sep-2016.
Programming and Debugging with the Dragon and JTAG
Training Documentation – Replacing GSPR with RFQ 2.0
Written by Anthony McNicoll
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
FTC Driver Station Setup and Operation Mike Zook 20-Sep-2016.
Chapter No. : 1 Introduction to Java.
Introduction to Autonomous Programming
FTC Driver Station Setup and Operation Mike Zook 20-Sep-2016.
Loop Structures.
GETTING STARTED ALL YOU NEED TO KNOW TO MAKE YOUR ROBOT MOVE
Automation and Robotics
UNITY TEAM PROJECT TOPICS: [1]. Unity Collaborate
WEB PROGRAMMING JavaScript.
How to Run a Java Program
We’re moving on to more recap from other programming languages
Block Programming Hello my name is Stephanie. I have been apart of FIRST for 6 years and have 3 years of programming experience. I am currently a member.
Android Programming OnBot Java.
Programming - Buttons Intro to Robotics.
Programming - Buttons Intro to Robotics.
Fast-Track UiPath Developer Module 2: Getting to Know UiPath Studio
Workshop for Programming And Systems Management Teachers
Presentation transcript:

Programming FTC Robots with Android Studio Eagle Robotics Team 7373

Disclaimer This is only an overview We cannot cover every aspect of Android Studio If you have questions, contact us using the information provided in your handout or check out our code library: eaglerobotics.net/code

System.out.println(“Welcome!”); What tools will you need to code in Android Studio? JDK 8 Android Studio 2.1 The latest version of the ftc_app from GitHub Links to all is on web page Install JDK BEFORE As. ftc_app can be either downloaded or forked off GitHub

Android Studio Interface Project Window Program Editor This is the stock view of Android Studio… Project Window – This is where you navigate the projects file tree Program Editor- This is where source code is edited Tool Windows- This can serve many different purposes depending on how you configure you Android Studio Tool Windows

Android Studio Interface This is my custom view of Android Studio. You can customize it to look however you want.

Navigating Projects Package Classes This is that is inside the project windows All work will be done in this directory FtcRobotController / java / com.qualcomm.ftcrobotcontroller / opmodes C is a class Folder is a package These 2 classes are very important Register- This is where you assign what op modes actually show up on the phone NullOp- This is a barebones structure for any program Classes

Editing Opmodes Double click class to open it here This is where the source code is edited. Classes being edited are listed in tabs on the top Do not leave too many open at once or you will get confused

Registering Opmodes In order to use an opmode, it must be enabled In order to do this you only need to comment out one line of code above the class header You can also change the labels that describe your opmode to keep things more organized They can be organized by Autonomous/Teleop, Group, and Name @Autonomous(name = "Concept: NullOp", group = "Concept") //@Disabled public class ConceptNullOp extends OpMode {

Uploading the Project Plug in Android Robot Controller Press Play Button in Menu Select Android Device to Deploy to Press OK The App Should Now be on your Android Robot Controller Put the app on your home screen for easy quick access This is basics of using Android studio… onto basic Java syntax

Basic Java Syntax Almost All Statements will end with a ; i.e. System.out.println(“Hello World”); Every method or class will be surrounded by braces i.e. public void method () { //Code goes here… } Java is very particular so be patient Java is case sensetive

Basic Java Syntax Comments can be written using // These are ignored by the compiler but help to document and organize code i.e. //set drive motor power to 1 driveMotor.setPower(1); These can also be quite helpful for testing small sections of the code at a time Comments can span multiple lines if the following from is used /* * put an asterisk on every line * then you can comment * on multiple lines */ Helps for testing by commenting out troublesome portions of code or code that is known to work Be careful to end the multiple lines comment or it will comment all code

Java Variable Types Double, float, and int boolean Enumerated types These are the most commonly used number type in programming FTC robots boolean This is a value that stores TRUE or FALSE This is used for logic statements such as While, For, If, etc. Enumerated types These are a specific type of variable that can hold explicit values like Go, Stop, Start… This is not the same as a string Float is a number with decimals, int is a whole number Motor and servo are propriotery (only use for robots)

Java Logic Opertators && - And || - Or ! - Note == - Equals > - Greater Than < - Less Than >= - Greater Than or Equal To <= Less Than or Equal To != - Does Not Equal

Java Iterative and Logic Statements while(conditions) { … } for(int i = 0; I <= 100; 1++) { … } if(condition) { … } else { … } switch(case){ case 1: … break; case 2: … break; default: … break;

opModeIsActive() method Returns a Boolean This method is very important to be able to stop your robot at any time even when you are running a loop while( opModeIsActive() ) { … }

Basic Form of a Program There are 2 basic forms any robot program will take Iterative Init/start Method Starts when init button is hit in driver station Runs code once then waits for start to move to run the start and then loop method loop Method Runs repeatedly until stopped by the driver station Linear runOpMode Method Runs through only once until stop button is pressed or timer runs out waitForStart method is used to separate the initialization of the robot from the start of the program Iterative is good for Teleop Linear is good for Autonomous But you can use both for either type of opmode and oftentimes there are advantages… I tend to work with Linear opmodes for flexibility

Initializing the Robot Create objects Servo and Motor i.e. Motor leftdrive; Servo arm; Reference the variable to the hardware map leftdrive = hardwareMap.dcMotor.get(“motor name”); arm = hardwareMap.servo.get(“servo name”); Fill in motor name or servo name for the name used on the robot controller hardware map Keep these names simple and consistent yet descriptive Best practice is to keep an excel spreadsheet will all hardware map data, wiring information, and any serial numbers or labeling information for each controller and motor/servo

Running the Robot Use either object gamepad1 or gamepad2 to get input Fill in * for direction, Left, Right gamepad1. Output Range *_bumper Boolean True or False *_trigger Float [0,1] *_stick_y or *_stick_x [-1,1] dpad_* a, b, x, y A note for all axis on joysticks… the values they return is – up and + down… If button is pressed, it will return true

Running the Robot: Motors Running a motor motor.setPower(float); Fill in your motor variable for motor name and drive power value for float This drive power can be from -1 to 1 If a value outside the bounds is sent, a null pointer error will be returned To prevent this clip the range of the input into the motor power = Range.clip(power, -1, 1); Use the gamepad joystick to control your power variable float power = gamepad1.left_joystick_y; power = Range.clip(power, -1, 1); motor.setPower(power); Range.clip has 3 arguments, number to clip, lower bound , and upper bound It will return the closest bound if it exceeds either bound

Running the Robot: servos Running a servo servo.setPosition(float) Fill in servo variable name for servo and position value for float The position can be from 0 to 1 The same range clipping technique can be used for servos position = Range.clip(position, 0, 1); Running a servo… if(gamepad1.dpad_up) { servo.setPosition(1); } else { servo.setPosition(0); } Or any value for that matter…

A Basic Teleop public void init() { Servo arm; Motor leftDrive; Motor rightDrive; arm = hardwareMap.servo.get(“arm”); leftdrive = hardwareMap.motor.get(“leftdrive”); rightDrive = hardwareMap.motor.get(“rightdrive”); } Now that we have the knowledge to write a basic teleop program lets walk through one init

A Basic Teleop public void loop() { //get boolean values from dpad and change position of servo if(gamepad1.dpad_up) { servo.setPosition(1); } else if(gamepad1.dpad_down){ servo.setPosition(0); } //get power from left joystick and run motor float leftPower = gamepad1.left_joystick_y; power = Range.clip(leftPower, -1, 1); leftDrive.setPower(leftPower); float rightPower = gamepad1.right_joystick_y; power = Range.clip(leftPower, -1, 1); rightDrive.setPower(rightPower); } Now that we have the knowledge to write a basic teleop program lets walk through one init

Questions? www.eaglerobotics.net/code Email us at team7373robotics@gmail.com or kk4jrq@gmail.com We hope you enjoyed… Prepared for programming robots…