JavaWorkshop Part 3. Instead of going over previous years’ code. We will rewrite 2014’s code using the SimpleRobot Template But first let’s get thru OOP.

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

Python Objects and Classes
Java Workshop. Quick java review Goal: We want the application to tell us what the nth fibonacci number is. Components needed to achieve the goal: A Scanner.
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.
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
Chapter 8 Inheritance Part 2. © 2004 Pearson Addison-Wesley. All rights reserved8-2 Outline Creating Subclasses Overriding Methods Class Hierarchies Inheritance.
Inheritance Inheritance Reserved word protected Reserved word super
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
CS 106 Introduction to Computer Science I 11 / 26 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
IR SENSORS AND ENCODERS. LCDs Timothy Friez Class # 2.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
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.
Multiple Choice Solutions True/False a c b e d   T F.
1 Using Classes Object-Oriented Programming Using C++ Second Edition 5.
Using Classes Object-Oriented Programming Using C++ Second Edition 5.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
Chapter 4 Objects and Classes.
ROBOTC for VEX On-Site Professional Development
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
1 CSC 221: Computer Programming I Spring 2010 interaction & design  modular design: roulette game  constants, static fields  % operator, string equals.
Continuous February 16, Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?
Week 6 - Wednesday.  What did we talk about last time?  Exam 1 post-mortem  Recursive running time.
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
1 Introduction Modules  Most computer programs solve much larger problem than the examples in last sessions.  The problem is more manageable and easy.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
FRC Robot Programming 1.PID Continued 2.Downloading and Deploying Code 3.Program a 2012 Robot from Spec Basic code For FIRST Robotics.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Programming in Java CSCI-2220 Object Oriented Programming.
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.
1 Chapter Four Creating and Using Classes. 2 Objectives Learn about class concepts How to create a class from which objects can be instantiated Learn.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
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.
1 COSC2007 Data Structures II Chapter 9 Class Relationships.
Interfaces Chapter 9. 9 Creating Interfaces An interface is a contract. Every class that implements the interface must provide the interface’s defined.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Lecture 8: Object Oriented Programming. What is a Programming Object? An object is an instance of a class. A class is a template for an object. Everything's.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
CS 5JA Introduction to Java Pop Quiz Define/Explain encapsulation. In object-oriented programming, encapsulation refers to the grouping of data and the.
Week 12 - Wednesday.  What did we talk about last time?  Hunters and prey.
Week 12 - Monday.  What did we talk about last time?  Defining classes  Class practice  Lab 11.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
Java Programming, Second Edition Chapter Three Using Methods, Classes, and Objects.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
This In Java, the keyword this allows an object to refer to itself. Or, in other words, this refers to the current object – the object whose method or.
Object Oriented Programming. Constructors  Constructors are like special methods that are called implicitly as soon as an object is instantiated (i.e.
Basic Steps in Programming
OpModes in FTC Eric Golde.
Abstract classes and interfaces
OOP: Encapsulation &Abstraction
Classes and OOP.
Agenda Warmup AP Exam Review: Litvin A2
More About Objects and Methods
Abstract classes and interfaces
Interface.
Lesson 4: Overall Review and Assessment
Object-Oriented Programming Using C++ Second Edition
Interfaces.
Training 11/11/16 Robot Code (WPILib).
CIS 199 Final Review.
Abstract classes and interfaces
Chap 2. Identifiers, Keywords, and Types
Topics OOP Review Inheritance Review Abstract Classes
四時讀書樂 (春) ~ 翁森 山光照檻水繞廊,舞雩歸詠春風香。 好鳥枝頭亦朋友,落花水面皆文章。 蹉跎莫遣韶光老,人生唯有讀書好。
CSG2H3 Object Oriented Programming
Presentation transcript:

JavaWorkshop Part 3

Instead of going over previous years’ code. We will rewrite 2014’s code using the SimpleRobot Template But first let’s get thru OOP 101

ObjectOriented Programming CLASS! A class is just a blueprint of the object will create that we

It can impor t another methods from class Name of the class Also tells you what related to itis It can have member variables It MUST have constructor, a sometimes more than one It can have member functions

Extends: is-a relationship. A joystick is a GenericHID A joystick can do everythingaGenericHID can. Implements: has relationship A joystick has all the functions interface of IInputOutput

Privatefunctions Public functions

Publicvs.Private Public keyword means it can be accessed with dot operator outside of the class Private keyword means it can only be accessed WITHIN the class. Cannot be accessed with dot operator

Constants Constants are often declared with public static final in some cases just static final

Instantiation To create an instant of an object using blueprint. the class You must ask the program to create an object with the keyword “new” Once it’s instantiated, you will refer to your object by its name, not the name of the blueprint

O Howtoinstantiateanobject SchoollowellHighSchool = newSchool(697); Typeofobject MAGIC WORD T MAKENEW THINGS!! Nameof object Constructorwith argument

Make a new project and name it 2014Team4159Recode Name the class Main

Outline of what physical componentswehave Drive Train 6 Talons, 2 sides Pneumatics Shifting solenoid Pickup soleniods Pickup 1 Talon Sensors Gyro 2 Encoders Joysticks 2 driving 1 secondary

Outline of desired functions Autonomous Roborealm interface to allow the “cheat” Multiple modes for autoinsmartdashboard drive straight dump ball Teleop Tank drive, shifting Pickup, both the motor andraise/lower

Since this program is relatively big, it’s best to keep everything organized and as modularized as possible. So we will create an IO class to store all of our connections to the physical world.

Just a bit more gardening to make it look even more organized

Now fill the stuff in with the pinout sheet. I’ll leave that to you guys However, you must use public static final as type since you don’t want these things to change under any circumstances

Now we need to call the IO class at the beginning of the main code so we can instantiate the physical components. DO NOT INSTANTIATE THE IO CLASS

Now time for some classes for our individual components of the robot Drive we will write our own custom drive functions to incorporate the gyro Pickup

Drive

Pickup

Teleop Since teleop is simpler, lets write what we want to do in teleop first the codefor Drive(shifting) Pickup control(motor spin + raise/lower)

Button actions DriveStick: 2/3 => low/high gear ShooterStick:4/5 => lower/raisepickup ShooterStick:3/Trigger => spinspickup Set refresh rateat 20ms

Autonomous We have to use SmartDashboard to select the specific type of autonomous mode we’re doing Make another class, name it DashboardManager Assume Roborealm gives a number of how many “signals” it sees. When it sees more than 0, it will return the boolean “shootReady” to true Variable named BLOB_COUNT

AutonomousModeActions To prevent Main.java from getting messy and unreadable, we will create another class named AutonomousModeActions This class will store all the actions of the robot for each cases during autonomous

DashboardManager We have 4 predefined actionswecantake Low goal blind auto = 1 Low goal detection auto= 2= 2 Drive only auto = 3 No Drive auto = 4

Add those 4 variables as constants into the AutonomousModeActions class Now write those 4 methods

DashboardManager Now we can setup a radio button list in SmartDashboard for each mode. Assign the int associated with each mode to the radio button.

Autonomous Now going back to Main.java, we need to tell robot what do to during Autonomous mode the First need to stop all the motors just to make sure we’re not moving use “getAutonomousMode” function you just wrote to get which mode of autonomous the driver selected

Since the mode selected will be returned as an int, use a switch to determine which mode you’re in and call the appropriate function in AutonomousModeActions class

We are DONE!!!! Now clean and build the program to make sure there’s no bug.