OpModes in FTC Eric Golde.

Slides:



Advertisements
Similar presentations
Robot Code MVRT 2010 – 2011 Season. Robot code controls the robot Robot Main.vi –Calls all the smaller SubVis Rules of programming the robot –Be careful.
Advertisements

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.
Loops For While Do While. Loops Used to repeat something Loop statement creates and controls the loop.
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.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
Programming Part 1 Armond R. Smith Zhenying Wu. Overview of this Class ● Transition from FTC -> FRC ● Using Your Resources ● Java Keywords o Data Types.
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.
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
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.
LabView Basics The Fighting Pi Controls Group. About LabView LabView is a highly adaptable programming GUI (Graphic User Interface) LabView compiles the.
Coding for the FIRST Tech Challenge: RobotC Presented by: Audrey Yeoh Acknowledgements: Team Unlimited FTC 0001.
Coding for the FIRST Tech Challenge: RobotC
Weston Schreiber & Joshua Gabrielse Robotics Summer Training Programming #1: EasyC Basics.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
LabVIEW Workshop September 26, 2009 Hauppauge High School SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp.
The New FTC Platform (Connecting your legacy hardware)
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.
EV3 Workshop Oct 3, 2015 Instructor: Chris Cartwright
Java Programming The Ponytail Posse - FTC #8808 9/12/15.
FRC Robot Programming 1.PID Continued 2.Downloading and Deploying Code 3.Program a 2012 Robot from Spec Basic code For FIRST Robotics.
Part III Robot Drive. Robot Main.vi The main body of your code: accesses all of the other programs in your project A big loop! Do not add any more loops.
Understanding The 2008 FRC Robot Controller Chris Gregory FRC1089 – Team Mercury
Session 12 Sensors and Timers. 3 Main Types of Robot Projects Command-Based Robot A more complicated project for more complicated robots Iterative Robot.
Session 11 Intro to FRC API.
Programming with LabVIEW Intro to programming and.
Robot Project by Ahmad Shtaiyat Supervised by Dr. Salem Al-Agtash.
Get your software working before putting it on the robot!
© 2006 Carnegie Mellon Robotics Academy Designed for use with the LEGO MINDSTORMS ® Education NXT Software and Base Set #9797 Sentry System Two-Way Communication.
Python Programming Module 4 Sensors and Loops Python Programming, 2/e1.
PROGRAMMING FTC ROBOTS WITH ANDROID STUDIO EAGLE ROBOTICS TEAM 7373 JORDAN MOSS AND BRIAN BAARS.
LEGO Robotics Workshop
Introduction to Programming in RobotC
INTERMEDIATE PROGRAMMING LESSON
Branching Error (a.k.a. the VM Program Instruction Break Error)
Deriving Consistency from LEGOs
Advanced Software Concepts
INTERMEDIATE programming LESSON: debugging Techniques: DISPLAY, LIGHT, Sound, Button Press… By Droids Robotics © 2014, Droids Robotics, v. 1.0,
ROBOTC for VEX Online Professional Development
ROBOTC for VEX On-Site Professional Development
Advanced EasyC Jim Cline July 20-21, 2017.
Bitfields and Logic Basics
IF statements.
Programming Scratch to Control a K’NEX Fairground Ride
ADVANCED BRAIN Training
Programming FTC Robots with Android Studio
Basics for Robotics Programming
Programming – Touch Sensors
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
FTC Programming Goals for Good Hardware Management
Automation and Robotics
Beginner Programming Lesson
BEGINNER PROGRAMMING Lesson
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
INTERMEDIATE PROGRAMMING LESSON
UNITY TEAM PROJECT TOPICS: [1]. Unity Collaborate
An Introduction to VEX IQ Programming with Modkit
Beginner Programming Lesson
Line Following Behavior
Beginner Programming Lesson
BEGINNER PROGRAMMING Lesson
Automation and Programming
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.
INTERMEDIATE PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
Lecture 9 Announcements.
Advanced LabVIEW
Introduction to Programing the Cortex for BEST
Presentation transcript:

OpModes in FTC Eric Golde

What is an opmode? The brain of your robot. Takes input from sensors, controllers, or both. Controls motors, servos to play the game. You can have as many opmodes as you want, but only one opmode runs at one time. Each opmode should be independent. Each opmode is a Java class, in its own Java file.

AUTONOMOUS VS TELEOP Autonomous and Teleop periods always use different opmodes. You might want to chose from different autonomous opmodes for different game strategies (depending on alliance partner plans, blue/red side of arena, etc.) Teleop may want different opmodes for different chassis/sensor/motor configurations.

Parts of an opmode @TeleOp() / @Autonomous() / @Disabled Registers your opmode so it shows up. Don’t forget it or you opmode will be invisible! You don’t need to explicitly register it like last year. See details @Override public void init() Gets called ONCE, when you the start button once. Use this for registering motors, servos, buttons, joysticks, …. @Override public void start() Get called ONCE, right before loop gets called. Use this to set the position of servos/turn on sensors. @Override public void loop() Gets called over and over and over again, until the stop button. This the main part of your opmode. You typically check joysticks, buttons, sensors, and then change motors/servos. @Override public void stop() Called when the opmode stops. Usually not needed, but there if you do.

Creating a basic Drive TELEOP opmode @TeleOp(name="TankDrive", group="Drive") public class TankDrive extends OpMode { DcMotor left; DcMotor right; @Override public void init() { left = hardwareMap.dcMotor.get("left"); right = hardwareMap.dcMotor.get("right"); right.setDirection(DcMotorSimple.Direction.REVERSE); } public void loop() { float leftValue = -gamepad1.left_stick_y; float rightValue = -gamepad1.right_stick_y; leftValue = Range.clip(leftValue, -1, 1); rightValue = Range.clip(rightValue, -1, 1); left.setPower(leftValue); right.setPower(rightValue);

CONTROLLERS Push Start and A button at the same time to tell driver station that joystick 1 is connected (Start and B for joystick 2). For joysticks, down is Y direction is positive. Use a negative sign to flip it to up being positive. In FTC, there is no way to detect a single button press. You can only sense if a button is up or down. But there is an easy way… boolean lastStateA = false; // Last state of A button @Override public void loop() { if (gamepad1.a && !lastStateA) { // A was pressed once. Put your code to react to this here. } lastStateA = gamepad1.a; }

SENSORS Sensors are just like motors with the hardware. Sensors can be fairly complicated, but very useful. ColorSensor can be used to sense lines on the playing field. Not sensitive enough to detect beacon color (in my experience…) You can use the phone camera as a sensor. There is a special class to use to turn the camera into a sensor (complex!). Feel free to ask us for more information. Viewphoria is very limiting

MOTORS AND SERVOS Motors: use DCMotor. Servos: use Servo. For DC Motors, use .setDirection to set the direction of motors. Don’t just switch wires around. Continuous servos and non-continuous servos use different ways to control them. Use Range.clip to prevent crashes; if you try to set too large a value.

TELEMETRY Telemetry allows you to send information from the robot controller to the driver station, in the form of text. Very useful to debug your code. Things have changed quite a bit from last year. To print a line of text to telemetry: public void writeLine (String line) { telemetry.addLine(line); updateTelemetry(telemetry); } You can also have a value that updates without printing a new line: public void updateValue (String name, Object value) { telemetry.addData(name, String.valueOf(obj)); updateTelemetry(telemetry);

autonomous opmodeS Two basic kinds: Drive pre-programmed dead reckoning. Doesn’t use any sensors. Relatively easier. Dead reckoning, but also use sensors to adjust and react to the robots surrounding. Harder. Lots of options on how much to use sensors vs. dead reckoning. For dead reckoning, you need to test on your exact robot or a very close replica. Gear ratios, wheel size, etc. will affect your code significantly. Autonomous is hard. You need to test a LOT.

Sharing code BETWEEN OPMODES Opmodes should never call other opmodes directly. Opmodes should not have static functions. You can share code by creating a “utility class” with static functions that is used by multiple opmodes. Example: telemetry. You can also share code by creating a base class that multiple opmodes extend. This is more advanced, but helps share common initialization code.

TIPS Never get frustrated Ask on the FTC forum about your question Take time to go through the FTC tutorials Test code on a replica of your robot as similar as possible. Use telemetry to report the values of variables or to figure out where you are in your code. A variable might not be what you think. The more telemetry the easier it is to debug. You can also use sound (but disable it before competition!) TEST. TEST. TEST. TEST. TEST. TEST.

QUESTIONS?