Introduction to Robots and the Mind - Proportional Controller - Bert Wachsmuth & Michael Vigorito Seton Hall University.

Slides:



Advertisements
Similar presentations
Case study 1: Calculate the approximation of Pi
Advertisements

COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions.
Chapter 1 - An Introduction to Computers and Problem Solving
Programming in Visual Basic
Introduction to Programming Using simple games to convey introductory concepts MERLOT International Conference 2004 Tracey Jensen Assistant Professor,
Problem Solving and Program Design in C (5th Edition) by Jeri R. Hanly and Elliot B. Koffman Chapter 4 (Conditional Statements) © CPCS
CISC220 Spring 2010 James Atlas Lecture 06: Linked Lists (2), Big O Notation.
Program Design and Development
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 3 Programming and Software.
C++ for Engineers and Scientists Third Edition
13-1 Introduction to Quadratic Equations  CA Standards 14.0 and 21.0  Quadratic Equations in Standard Form.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
Java for Robots How to program an NXT robot with a Java Brain Bert G. Wachsmuth Seton Hall University.
Chapter 13 Recursion. Topics Simple Recursion Recursion with a Return Value Recursion with Two Base Cases Binary Search Revisited Animation Using Recursion.
Algorithms In general algorithms is a name given to a defined set of steps used to complete a task. For example to make a cup of tea you would fill the.
M180: Data Structures & Algorithms in Java
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 3.
Four Fundamental Pieces Instruction Control Structure Function Expression.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 11 Conditional.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
1 ELEC 206 Chapter 3 Control Structures 5-Step Problem Solving Methodology 1. State the problem clearly. 2. Describe the input and output. 3. Work a.
Algorithm Design.
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
1 Program Planning and Design Important stages before actual program is written.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
24 Background Building 25 Computing Terminology, and Speed/Velocity Module 4 Notes: Sensing, Or Operator, Conditional Logic 28 Module 4 Algorithms,
1 Chapter 3: Loops and Logic. 2 Control Statements If statement Example NumberCheck.java Relational operators (, >=, ==, !=) Using code blocks with If.
Introduction to Computer Sciences References: [1] Fortran 95/2003 for Scientists and Engineers (3e) by Stephen J. Chapman. [2] Using Fortran 90 by Chester.
Introduction to Robots and the Mind Bert Wachsmuth & Michael Vigorito Seton Hall University.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
Chapter 3 Decisions Three control structures Algorithms Pseudocode Flowcharts If…then …else Nested if statements Code blocks { } multi statement blocks.
CISC220 Spring 2010 James Atlas Lecture 07: Big O Notation.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Introduction to Robots and the Mind - Programming with Sensors - Bert Wachsmuth & Michael Vigorito Seton Hall University.
Control Structure  What is control Structure?  Types of Controls  Use the control structure in VBScript.  Example Summery.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Introduction to Robots and the Mind - Sensors - Bert Wachsmuth & Michael Vigorito Seton Hall University.
Windows Programming Lecture 03. Pointers and Arrays.
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
Understand Problem Solving Tools to Design Programming Solutions
C++ Basic Syntax – Homework Exercises
Lecture 06: Linked Lists (2), Big O Notation
Chapter 4 (Conditional Statements)
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Engineering Problem Solving with C++, Etter/Ingber
Transition to Code Upsorn Praphamontripong CS 1110
Introduction to Robots and the Mind - Path Integration -
Understand Problem Solving Tools to Design Programming Solutions
Chapter 5 Decisions. Chapter 5 Decisions ssential uestion: How are Boolean expressions or operators used in everyday life?
Factoring if/else code
Chapter 4 – Control Structures Part 1
Programming Fundamentals
Introduction to Computer Science - Alice
Introduction to Robots and the Mind - Methods -
Building Java Programs
Introduction to Data Structures
Chapter 4-1 The Foundations of Physical Science
An Introduction to VEX IQ Programming with Modkit
Robotics and EVT - line follower -
Unit 3 Test: Friday.
Algorithm and Ambiguity
Building Java Programs
ICT Programming Lesson 3:
4.4 Different Forms of Quadratic Expressions
ICT Gaming Lesson 2.
Introduction to Programming
Sum this up for me Let’s write a method to calculate the sum from 1 to some n public static int sum1(int n) { int sum = 0; for (int i = 1; i
Loops CGS3416 Spring 2019 Lecture 7.
Chapter 13 Control Structures
Presentation transcript:

Introduction to Robots and the Mind - Proportional Controller - Bert Wachsmuth & Michael Vigorito Seton Hall University

Last Time: Loops while loops while (condition_is_true) { // do this } for loops: for (type var=init_value; condition_is_true; change_var) { // do this }

Loop examples while (Button.ENTER.isUp()) { System.out.println(getDistance()); Delay.msDelay(1000); } int count = 0; while (count < 4) { drive(60); turn(90); count = count + 1; }

Common loop problems int count = 0; while (count < 100) { System.out.println(“Do not cheat in class”); } while (Button.ENTER.isUp()); { System.out.println(“D=“ + getDistance()); } Tricky mistakes that are not flagged by the compiler. Run-time error as opposed to compile-time error.

Last Time: Conditionals Simple if statement: if (condition_is_true) { // do this } if statement with alternative: if (condition_is_true) { // do this } else { // do that }

Conditional examples if (getDistance() < 25) { rightMotor.stop(); leftMotor.stop(); } if (getDistance() < 25) { rightMotor.setSpeed(200); leftMotor.setSpeed(200); } else { rightMotor.setSpeed(800); leftMotor.setSpeed(800); }

Multiple if statement if (condition1_is_true) { // do code 1 } else if (condition2_is_true) { // do code 2 }... else if (conditionN_is_true) { // do code block N } [ else { // do optional code block }]

Multiple decision example int dist = getDistance(); if (dist < 10) { avoidObstacle(); } else if (dist < 20) { slowdown(); } else { forward(); }

Common error with multiple if int dist = getDistance(); if (dist < 20) { slowdown(); } else is (dist < 10) { avoidObstacle(); } else { forward(); } Logical mistake!

Self-driving car algorithm

Algorithm vs Formula  A math formula represents a relationship between expressions whereas  An algorithm describes steps to solve a task, i.e. an algorithm is goal-oriented

Quadratic equation Algorithm

Test and refine algorithm

Self-driving car algorithm  An algorithm is a sequence of well-defined steps that collectively solve a task Self driving car algorithm 1: 1. Drive forward but maintain distance Self driving car algorithm 2: 1. Drive forward 2. Maintain distance

Refine algorithm 1. Drive forward –If you are too close to car in front, stop –If you are too far away from the car in front, go while (Button.ENTER.isUp()) { double distance = getDistance(); if (distance < 0.1) { motorLeft.stop(true); motorRight.stop(); } else { motorLeft.forward(); motorRight.forward(); } }

Refine algorithm  Drive forward –If you are vey close to lead car, set speed to zero –If you are a medium distance from lead car, set speed to ‘slow’ –If you are far away from lead car, set speed to ‘fast’ while (Button.ESCAPE.isUp()) { double distance = getDistance(); double speed = getSpeed(distance); motorLeft.setSpeed((int)speed); motorRight.setSpeed((int)speed); motorLeft.forward(); motorRight.forward(); }

Refine Algorithm public static double getSpeed(double distance) { if (distance < 0.05) { return 0.0; } else if (distance < 0.15) { return 300.0; } else { return 600.0; }

Refine algorithm