Advanced Software Concepts

Slides:



Advertisements
Similar presentations
Final and Abstract Classes
Advertisements

Object Oriented Programming with Java
Object Oriented Programming in Java. Object Oriented Programming Concepts in Java Object oriented Programming is a paradigm or organizing principle for.
Object-Oriented PHP (1)
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-oriented Programming Concepts
UML Class Diagram: class Rectangle
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Abstraction, Inheritance, and Polymorphism in Java.
Programming Languages and Paradigms Object-Oriented Programming.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
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.
FTC New Platform Programming Workshop in Android Studio
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Object Oriented Software Development
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Abstraction ADTs, Information Hiding and Encapsulation.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Topics Inheritance introduction
Classes, Interfaces and Packages
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
Industrial Group Project Introduction to Object Oriented Programming Adelina Basholli, February, 2016.
Software Construction Lab 05 Abstraction, Inheritance, and Polymorphism in Java.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Inheritance.
Programming in Java: lecture 7
Modern Programming Tools And Techniques-I
OpModes in FTC Eric Golde.
OOP: Encapsulation &Abstraction
The Movement To Objects
Systems Analysis and Design
Lecture 12 Inheritance.
Systems Analysis and Design With UML 2
Final and Abstract Classes
Inheritance and Polymorphism
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
UML Class Diagram: class Rectangle
Lecture 9 Concepts of Programming Languages
CS240: Advanced Programming Concepts
Interface.
Control Award This award is given to the Team that demonstrates innovate thinking in the control system to solve game challenges such as autonomous operation,
Week 6 Object-Oriented Programming (2): Polymorphism
Advanced Java Programming
Java Inheritance.
COP 3330 Object-oriented Programming in C++
Object-Oriented Programming
By Rajanikanth B OOP Concepts By Rajanikanth B
Review of Previous Lesson
Object-Oriented PHP (1)
Final and Abstract Classes
Chapter 11 Inheritance and Encapsulation and Polymorphism
Extending Classes Through Inheritance
UML  UML stands for Unified Modeling Language. It is a standard which is mainly used for creating object- oriented, meaningful documentation models for.
CSG2H3 Object Oriented Programming
Lecture 9 Concepts of Programming Languages
Presentation transcript:

Advanced Software Concepts 2016-2017 Rockwell Automation FTC Kickoff

Copyright © 2016 FTC Team TBD Introductions To Be Determined – TBD 6th Year FTC Team from Aurora, OH Res-Q World Champions and World Control Award Winner Around-the-Room Team Name/Number Hometown What Do You Want to Learn Today? PUBLIC Copyright © 2016 FTC Team TBD Slide 2

Copyright © 2016 FTC Team TBD Classes and Packages A class is a collection of objects of a similar type. Once a class is defined, any number of objects can be created which belong to that class. An object is an instance of a class. A package allows a developer to group related classes (and interfaces) together. PUBLIC Copyright © 2016 FTC Team TBD Slide 3

Copyright © 2016 FTC Team TBD Access Modifiers By Default: Visible to the package. Private: Visible to the class only. Protected: Visible to the package and all subclasses. Subclass is “extending” another class. Example: MyTeleopCode extends OpMode Public: Visible to the world. Static: One instance shared by all instances of class. Final: Cannot later be changed Static and Final Together to Define a Constant int ourTeamNumber = 6022; private int ourTeamNumber = 6022; protected int ourTeamNumber = 6022; public int ourTeamNumber = 6022; Modifier Class Package Subclass World public Y protected N No Modifier private final public int ourTeamNumber = 6022; static public int ourTeamNumber = 6022; static final public int CONSTANT = 1234; PUBLIC Copyright © 2016 FTC Team TBD Slide 4

Object-Oriented Programming Object-oriented programming is based on the concept of “objects”. Objects contain data in the form of fields/attributes. Objects contain code in the form of procedures/methods. An object's methods can access and often modify the attributes of the object. Programs are designed by making objects that interact with one another. A big advantage of object-oriented programming is that it enables programmers to create modules that do not need to be changed when a new type of object is added. A programmer can simply create a new object that inherits many of its features from existing objects. This makes object-oriented programs easier to modify. PUBLIC Copyright © 2016 FTC Team TBD Slide 5

Object-Oriented Programming Abstraction Implementation of an object that contains the same essential properties and actions we can find in the original object we are representing. public class ResQMountain { public static enum MountainStatus { ON_MTN, OFF_MTN; private MountainStatus() { } } public static enum MountainZone { LOW_ZONE, MID_ZONE, HIGH_ZONE; private MountainZone() { } } } PUBLIC Copyright © 2016 FTC Team TBD Slide 6

Object-Oriented Programming Encapsulation Internal representation of an object is generally hidden from view outside of the object’s definition. public class ExampleRobotDrivetrain { private DcMotor trackLeft; private DcMotor trackRight; private DcMotorController trackController; public ExampleRobotDrivetrain (DcMotor aLeftTrack, DcMotor aRightTrack, DcMotorController aController) { trackLeft = aLeftTrack; trackRight = aRightTrack; trackController = aController; trackRight.setDirection(DcMotor.Direction.REVERSE); } public int getDriveEncoder() { return Math.abs(trackRight.getCurrentPosition()); } public void resetDriveEncoders() { trackLeft.setMode(DcMotorController.RunMode.RESET_ENCODERS); trackRight.setMode(DcMotorController.RunMode.RESET_ENCODERS); } public void setPower(double aLeftPower, double aRightPower) { trackLeft.setPower(aLeftPower); trackRight.setPower(aRightPower); } } PUBLIC Copyright © 2016 FTC Team TBD Slide 7

Object-Oriented Programming Inheritance Classes can inherit attributes and behavior from pre-existing classes called base classes, also known as superclasses. public class TrackCleaning extends OpMode { private RobotTracks robotTracks; @Override public void init() { robotTracks = new RobotTracks(hardwareMap.dcMotor.get("trackLeft"), hardwareMap.dcMotor.get("trackRight"), hardwareMap.dcMotorController.get("drivetrainController")); } @Override public void loop() { robotTracks.setPower(0.5, 0.5); } @Override public void stop() { robotTracks.stop(); } } public abstract class OpMode { public Gamepad gamepad1 = null; public Gamepad gamepad2 = null; public Telemetry telemetry = new Telemetry(); public HardwareMap hardwareMap = null; public double time = 0.0D; private long a = 0L; public OpMode() { this.a = System.nanoTime(); } public abstract void init(); public void init_loop() { } public void start() { } public abstract void loop(); public void stop() { } } PUBLIC Copyright © 2016 FTC Team TBD Slide 8

Object-Oriented Programming Polymorphism Ability of an object to take on many forms. Class can have multiple inheritance. Deer d = new Deer(); Animal a = d; Vegetarian v = d; Object o = d; //All the reference variables d, a, v, o refer to the same Deer object in the heap. //Example from www.tutorialspoint.com because I haven’t really used polymorphism in robotics code. PUBLIC Copyright © 2016 FTC Team TBD Slide 9

Copyright © 2016 FTC Team TBD State Machines Not a physical machine!  Can be implemented in an opmode through a switch. In only one state at a time (known as the current state). Changes from one state to another when initiated by a triggering event or condition. Allows for autonomous programs to be programmed using the standard opmode (rather than the often buggy linear opmode). public void loop() { switch(stateMachineFlow) { case 0: //Initial expand and servo delay. robotOrientation.zAxisRotationZero(); robotCaster.positionDeployed(); robotTracks.resetDriveEncoders(); runtime.reset(); stateMachineFlow++; break; case 1: //Half of lowering track guards. robotTrackFlaps.positionUp(); robotOrientation.zAxisRotationZero(); if(runtime.time() >= 0.25) stateMachineFlow++; //Time to ensure that flaps drop. break; //Skipping over steps just to keep this presentation consolidated. case 10: //Climb the mountain. robotTracks.runWithoutEncoderPWM(); robotTracks.setPower(-1, -1); robotMtnLock.updateChurroCount(runtime.time()); if(robotTracks.isStalling()) stateMachineFlow = -1; if(robotMtnLock.getChurroCount() >= mtnChurrosToClimb) stateMachineFlow++; break; default: //Autonomous complete! #YEET robotTracks.stop(); robotSweeper.stop(); robotWinch.stop(); break; } } PUBLIC Copyright © 2016 FTC Team TBD Slide 10

Copyright © 2016 FTC Team TBD Using Motor Encoders Measures how far a motor has turned. Useful for autonomous programming. More reliable than timing. Can be positive or negative. someMotor.getCurrentPosition(); Two motors on the same controller can also take advantage of PWM control. Keeps motors running in sync with each other. someMotor.setMode(DcMotorController.RunMode.RUN_WITH_ENCODERS); Can also be used to code a stall detection system. PUBLIC Copyright © 2016 FTC Team TBD Slide 11

Copyright © 2016 FTC Team TBD Using Gyroscopes Measures rate of rotation. Through integration, can be used to measure how big of an angle the robot has turned. More accurate turns. Modern Robotics sensor and Moto-G2 have 3-axis gyroscopes. Modern robotics has built-in integration, which allows for greater accuracy and easier implementation. PUBLIC Copyright © 2016 FTC Team TBD Slide 12

Copyright © 2016 FTC Team TBD Using Touch Sensors Can be used as limit switches. Prevents movement of a motor in one direction if a touch sensor is pressed so that a mechanism is not damaged and/or motion does not continue. PUBLIC Copyright © 2016 FTC Team TBD Slide 13

Copyright © 2016 FTC Team TBD Using Other Sensors In general, using sensors is a good thing! Sensors give more data to robot, which leads to more accurate decisions. JavaDocs are a great source of help for interfacing with sensors. Don’t be afraid to try new sensor systems. Last season, we used magnetic, light, color, accelerometer, etc… PUBLIC Copyright © 2016 FTC Team TBD Slide 14

Copyright © 2016 FTC Team TBD Documenting Code Show structure using UML diagrams. Show algorithms and routines through flowcharts. Describe what code does and how it improves performance. For engineering notebook examples and resources that help with UML and flowcharts, visit www.tbdftc.com. PUBLIC Copyright © 2016 FTC Team TBD Slide 15

Any Questions? Thank You and Good Luck!

Programming Exercises/Challenges Feel Free to Collaborate and Ask for Help