Introduction to Autonomous Programming

Slides:



Advertisements
Similar presentations
Getting started with LEGO NXT Mindstorms software This is intended to be a short introduction to the LEGO Mindstorms software and programming the LEGO.
Advertisements

Computer Basics Hit List of Items to Talk About ● What and when to use left, right, middle, double and triple click? What and when to use left, right,
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.
Team 5220 Roboknights. Outline  Getting Started  Hardware Setup/Wiring  Software Setup/Pragmas  Programming with RobotC  Grammar/Syntax  Basic Statements.
Bullseye Bullseye was rolled out to our user base on Friday, January 30. I wanted to take this opportunity to give everyone an update on a.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
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.
Autonomy using Encoders Intro to Robotics. Goal Our new task is to navigate a labyrinth. But this time we will NOT use motor commands in conjunction with.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
App Inventor Barb Ericson July 3, 2013.
Programming – Touch Sensors Intro to Robotics. The Limit Switch When designing robotic arms there is always the chance the arm will move too far up or.
Salesforce.com Web to Leads. Unit Name Web to Leads A web to lead provides users the ability to gather information from their website visitors which automatically.
Android 4: Creating Contents Kirk Scott 1. Outline 4.1 Planning Contents 4.2 GIMP and Free Sound Recorder 4.3 Using FlashCardMaker to Create an XML File.
Editing Java programs with the BlueJ IDE. Working environments to develop (= write) programs There are 2 ways to develop (write) computer programs: 1.Using.
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.
Program ultrasonic range sensor in autonomous mode
Coding for the FIRST Tech Challenge: RobotC Presented by: Audrey Yeoh Acknowledgements: Team Unlimited FTC 0001.
Coding for the FIRST Tech Challenge: RobotC
The New FTC Platform (Connecting your legacy hardware)
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
FTC New Platform Programming Workshop in Android Studio
Making your Robot Move Motorbolts. Notes This presentation will be available on the High Tech Kids’ website: hightechkids.orghightechkids.org For more.
Downloading and Installing Autodesk Revit 2016
Java Programming The Ponytail Posse - FTC #8808 9/12/15.
Downloading and Installing Autodesk Inventor Professional 2015 This is a 4 step process 1.Register with the Autodesk Student Community 2.Downloading the.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
M1G Introduction to Programming 2 5. Completing the program.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Day 1 Session 2. Setup & Installation
PROGRAMMING FTC ROBOTS WITH ANDROID STUDIO EAGLE ROBOTICS TEAM 7373 JORDAN MOSS AND BRIAN BAARS.
Fundamentals of Windows Mouse n 4 Basic Operations: –Pointing –Clicking –Double Clicking –Dragging.
INTRODUCTION TO ROBOTICS Part 5: Programming
Development Environment
OpModes in FTC Eric Golde.
Running a Forms Developer Application
Getting Started with Application Software
Working in the Forms Developer Environment
Data Virtualization Tutorial: Introduction to SQL Script
Android Studio, Android System Basics and Git
Topics Introduction to Repetition Structures
Mobile Application Development Chapter 5 [Persistent Data in Android]
Computer Programming I
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Programming FTC Robots with Android Studio
GETTING STARTED ALL YOU NEED TO KNOW TO MAKE YOUR ROBOT MOVE
Programming Design ROBOTC Software Computer Integrated Manufacturing
Autonomy using Encoders
Programming – Touch Sensors
Automation and Robotics
AN INTRODUCTION TO: POWERPOINT.
Packages and Interfaces
Programming in JavaScript
While Loops and If-Else Structures
While Loops and If-Else Structures
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.
While Loops and If-Else Structures
Android Programming OnBot Java.
While Loops and If-Else Structures
An Introduction to Computers and Visual Basic
Programming in JavaScript
Remote Control For this activity we will use the Squarebot
While Loops and If-Else Structures
Using Animation and Multimedia
Classes, Objects and Methods
While Loops and If-Else Structures
Programming Design ROBOTC Software Principles of Engineering
Review of Previous Lesson
While Loops And If-Else Structures
Getting started with LEGO EV3 Mindstorms software
Selenium IDE Installation and Use.
Presentation transcript:

Introduction to Autonomous Programming Team 7182, Mechanical Paradox Kieran Barvenik

This Class This class is designed to be a hands-on workshop, where students can have the chance not only to learn the information provided, but also to apply it We hope that the workshop’s interactive medium will help people retain the information taught in the class more so than a normal lecture format would Hopefully, everyone has had some interaction with code, as we are going to be going over FTC specific Java programming, and will not be covering the basics. If people have not, however, we are handing out a glossary and the product program in the handouts 2

This Class The class will be covering FTC specific Java programming and the essential building blocks for writing code for your robot We will be creating a program that commands a standard pushbot to move forwards for 2.5 seconds, open, and close its claw 3

Java and Android Studio The FTC hardware system operates over an Android platform, which is written in Java Android Studio is an IDE (Integrated Development Environment) specifically designed for Android programming Interacting directly with the code is an extremely versatile way of writing programs that allows the writer to gain complete control over the program’s operation (in contrast to MIT App Developer, which is fairly limited) JAVA IS CASE SENSITIVE 4

Looking at Android Studio A First look at the IDE 5

The highlighted portion (in red) is the toolbar, where the user has access to the functions and shortcuts of the IDE 6

The highlighted portion is the file explorer, where the user has access to the hierarchy of program files 7

The highlighted portion is the program window, where viewing and editing of code occurs 8

Android Studio Features Android Studio includes a variety of other useful features for programming including, but not limited to: Intelligent code editor (advanced code completion, analysis, and refactoring) Automatic integration with version control and project management software such as GIT Fast and expansive emulator Android studio will auto-fill-in incomplete code snippets, so use that to speed up your typing 9

What is an OpMode? OpMode refers to a user generated operational mode, or a program run on the robot The Term OpMode encompasses both Autonomous and Teleoperated modes Autonomous OpModes are robot-controlled programs that are run during the first 30 seconds of a match Teleoperated OpModes are driver-controlled programs that are run during the last 2 minutes of a match 10

Structure and Run Order The run cycle of the program is its order of operations from the starting to the stopping of the program OpModes contain multiple different prewritten methods (groups of code that perform an operation), each which plays during a different time during the run cycle of the program 11

Structure and Run Order Methods vary between 2 different types of OpModes: Normal and Linear Normal OpMode: employs 4 main methods: init, start, loop, and stop Linear OpMode: only uses one method, the runOpMode method, that runs once the program is initialized. We will be creating a Linear OpMode, because the concepts we are demonstrating work better with the Linear setup Possibly have handout w/ code for each opmode runcycle 12

Run Cycle Explanation In a Normal OpMode, pressing the init button will trigger the init method ; however, in a Linear OpMode, the init button will trigger the only method, runOpMode In a Normal OpMode, pressing the play button will immediately trigger the start method, followed by beginning the loop method In a Normal OpMode, pressing the stop button will stop the loop method, and proceed to run the stop method before exiting the program 13

Creating the Program File The first step in creating an FTC OpMode is to create a file to hold it To do this, we need to navigate to the team code storage directory Path: TeamCode/java/org.firstinspires.ftc.teamcode OR: FTCRobotController/java/com.qualcomm.ftcrobotcontroller/opmodes

Creating the Program File Right click the lowest directory in the hierarchy (for non-Beta users, the opmodes folder; for Beta users, org.firstinspires.ftc.teamcode)

Creating the Program File Select New, and Java Class Enter the name of the program in the box (Note: although you can name the program virtually anything, it is best to name it something that relates to what it does such that you can recognize it easily)

The Program File The resulting file that pops up should look like this: The statement at the top that begins with the keyword package simply declares where our program is located. The curly braces after the public class TestOp contain most of the OpMode’s code

OpMode Creation (importing) Before we start writing code that will actually move the robot, we need to import, or gain access to, the FTC SDK files. We need to add the following statements after the package statement but before public class …

OpMode Creation (importing) Import statements effectively are giving our program access to prewritten files in the package we specify in the statement The above statement gives our program access to the LinearOpMode code located in the package com.qualcomm.robotcore.eventloop.opmode

OpMode Creation (importing) The program should now look like this:

OpMode Creation (extension) To begin creating the OpMode, we must first add the keywords extends LinearOpMode between the public class TestOp and the opening curly brace Extends means the class we’re writing gains all of the characteristics of the file we’re extending 21

Variable Declaration [flesh out] First, we need to define variables to hold data that we will utilize and reference later in the program We need to create 3 DcMotor variables and 2 Servo variables The lines we add to declare motors and servos are added inside the curly braces. The statements look like these: 22

Variable Declaration There are 3 motor variables to create: leftDrive, rightDrive, and arm There are 2 servo variables to create: leftClaw and rightClaw Students can copy and paste variable declarations to reduce time taken. This line WILL have errors 23

OpMode Creation (runOpMode) In the body of the program (between the curly braces and below our variable declarations), we now need to add the following block of code: Throws means that if the method fails, the program will “throw” or give an exception/error message This is the method in our program that will execute when the init button is pressed 24

25

Initializing Hardware 1 Next, we need to bind the variables we created earlier in the program to the robot’s hardware, such that the variables we interact with represent the motors and servos on the robot The lines of code that we have to write to do this are placed inside the curly braces for the runOpMode method 26

Initializing Hardware 2 The line to initialize a motor looks as follows: The line to initialize a servo looks as follows: The name inside the quotation marks is a name we give to the hardware device on the robot controller once the program is downloaded to the phone 27

The lines are almost exactly the same, so students should write one line, then copy and paste it for the other lines; however, make sure to substitute keywords and names Also draw attention to the point that for every motor or servo variable, there is a line of code to bind it 28

Wait for Start After these lines of code, we have to add a waitForStart() method call. Because the runOpMode() method begins when the user presses the init button, the waitForStart() command tells the system not to continue until the play button is pressed on the phone WaitForStart() is a method included in the FTC API 29

30

Motor Movement After the waitForStart() method call, is where the movement procedure is written To make a motor move, the method [motorName].setPower(0.0) is called. The number put between the parenthesis is a decimal value that can range from -1.0 to 1.0, with -1.0 being full power in reverse and 1.0 being full power forwards. To stop a motor’s movement, use 0 for the decimal number The [motorName] should be whatever we called our motor variables, for example: leftDrive, rightDrive, or arm 31

Servo Movement To move a servo, the line [servoName].setPosition(0.0) is called in the runOpMode() method The number inside the parenthesis is a decimal value that ranges from 0 to 1.0 The decimal represents a position from 0 degrees to 180 degrees, so the decimal equivalent to the position in degrees can be found by dividing the number of degrees by 180 The [servoName] should be whatever we called our servo variables, for example: leftClaw or rightClaw Also give visual example of what 0.0 and 1.0 represent in terms of position on the robot 32

Movement Code To command the robot to drive forwards and open its claw, add the following code after the waitForStart();: Indefinite movement, because we have no form of measuring distance. This is our next goal 33

34

Creating a Timer To effectively write autonomous programs, a means of measuring distance must be utilized The simplest way to accomplish this is by creating a timer, though encoders or sensors can also be utilized The timer included in the FTC API is called ElapsedTime, a user controlled timer that can measure in units as small as milliseconds 35

Creating a Timer First, we need to create an instance of ElapsedTime by placing the following line of code after our movement code: 36

Waiting To tell our program to wait until a specific time has elapsed, we have to set up a loop that will continually check if our desired amount of time has passed (2.5 seconds, in our example) To accomplish this, we add the following code after our movement code in the runOpMode() method (eTime.time() returns seconds, not milliseconds) eTime.reset() resets the amount of recorded time to 0.0 and begins counting up again. If we did not call it, we would have already been counting up from the moment we initialize the variable, so the time would be incorrect. The while loop will continually execute whatever code is inside the curly braces until the eTime.time() (the amount of time that has elapsed since the last reset) is greater than 2.5, at which point the condition will return false and the program will move on. 37

38

Stopping Movement After the time has elapsed, we want to command the robot to cease movement To accomplish this, we will reuse the movement code we used earlier, but substituting 0 for the power value. The result is this: 39

Stopping Movement Additionally, we are going to close the claw by implementing this code: After this, your program should look like the program in the handout sheet 40

41

Waiting at the End In order for the servos to fully close, we need the program to give them time to close; otherwise, the program will end and the servos will not move We need to copy this code: And paste it at the end of the program to do that Recycle w/ copy and paste! 42

43

Registration of Your Program (non-Beta) Even though the FTC OpMode is now complete, the program will not show up on the phone without registering it in the FTCOpModeRegister file To do this, open the file and add a line of code like the following to the main body (with the other manager.register lines): Add picture 44

Registration Select the FTCOpModeRegister Program in the FTCOpModeRegister->com.qualcomm.ftcrobotcontroller->opmodes->FTCOpModeRegister directory 45

Registration Add the following line next to the other similar lines: 46

Registration (Beta Users) Alternatively, if you are using the new beta version of the FTC SDK, registration of your program is far easier. Simply scroll to the top of your program file (the one the majority of code is written in) and insert the following line beneath the import statements:

Registration This line identifies the program to the FTC Robot Controller as an autonomous program (you can also use @Teleop for teleop programs). With the new version, the coding is all contained within one file rather than spread across multiple files, so the entire coding process is much more streamlined.

Contact Information and Website Address The PowerPoint used in this class will be uploaded to our team’s website for anyone interested in going over the material again Our team’s website is: http://mechanicalparadox.org/ If anyone from the class has questions about any of the topics covered, our team’s email is: mechanicalparadox7182@gmail.com 50