T HE F INCH R OBOT AND THE W HILE L OOP Pepper. T HE R OBOT Developed by Carnegie Mellon students to teach CS Supports many compilers, including Java.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

1chung 5 th Annual Robofest 2004 Informational Meeting Mar. 20, 2004 Chan Jin Chung Ali Khazaal Jason Lo Computer Science Lawrence Technological University.
NXTG Workshop Day 2 Programming with Touch Sensor Light Sensor Ultrasonic Sensor Repeat CJ Chung Associate Professor of Computer Science Lawrence Technological.
While Loops and If-Else Structures
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
ENGG1100 Ch6: Introduction To Engineering Design (Digital Logic) Part 2 of digital logic KH WONG ENGG1100. Ch6-Digital Logic (part2) v3h1.
Lab7: Introduction to Arduino
Final Project Web Design. Final Project Your robot will be placed in a room with the red cone. Your robot will need to find the cone in the room and run.
Begin Java Pepper. Objectives What is a program? Learn the basics of your programming tool: BlueJ Write a first Java program and see it run Make some.
Automation and Robotics
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.
Introduction to Object-Oriented Programming CS 21a: Introduction to Computing I First Semester,
How to Create a Java program CS115 Fall George Koutsogiannakis.
Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Programming in easyC.
Alice Variables Pepper. Set to Java look Edit / preferences restart.
Introduction to Sensors
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
1 ©2006 INSciTE Lab Two Task: Make the program from Lab One (Move forward 5 rotations and turn right 90 degrees) into a MyBlock.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Robotics NXT sensors Back to Light sensor: red vs blue ball.
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
CSC172 Intro Pepper. Goals Reminder of what a class is How to create and use classes How to design classes How to think in terms of objects How to comment.
Introduction to Object-Oriented Programming
Clement Allen, PhD Florida A&M University SUMMER 2006.
Copyright © Curt Hill Turtles The beginning of media computation.
How to link the robot and the computer (Bluetooth) How to turn on and off How to connect the adaptor Fluke card connection Sec Getting Started How.
Wall Encounter By Made easy by Dwayne Abuel.
ENGR 101: Robotics Lecture 4 – Making Decisions Outline  The Stall Sensor  Making Decisions  Random Number Generation References 
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
A brief introduction to javadoc and doxygen. What’s in a program file? 1. Comments 2. Code.
1 Class 1 Lecture Topic Concepts, Definitions and Examples.
11 Computers, C#, XNA, and You Session 1.1. Session Overview  Find out what computers are all about ...and what makes a great programmer  Discover.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
Using the BlueJ IDE with Mindstorms LMICSE Workshop June , 2005 Alma College.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Casne.ncl.ac.uk Taking care of the CrumbleBot Please do NOT stress the robot's motors 1.Do NOT push the robot 2.Do NOT hold the.
Introduction to Robots and the Mind - Programming with Sensors - Bert Wachsmuth & Michael Vigorito Seton Hall University.
Common Mistakes with Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Presentation Outline I. Background Information II. Design Project
LEGO Robotics Workshop
Introduction to Programming in RobotC
Exploring Computer Science Lesson 6-5
CSC111 Quick Revision.
INC 161 , CPE 100 Computer Programming
Finch Robot Class L4 How do I… ? LED color (Range 0 to 100)
Automation and Robotics
The Finch Robot and the While Loop
Introduction to javadoc
Building Java Programs
Building Java Programs
Automation and Robotics
Sensors and Logic Switches
An Introduction to Java – Part I, language basics
Exploring Computer Science Lesson 6-5
Building Java Programs
Follow The Guidelines Light Sensor
Alice Variables Pepper.
Introductory Presentation
Storing Values as Variables
Introductory Presentation
Building Java Programs
Introduction to javadoc
Truth tables: Ways to organize results of Boolean expressions.
Building Java Programs
Random Numbers while loop
LEGO Mindstorms Robot and Java
The beginning of media computation Followed by a demo
Computer Science Club 1st November 2019.
Presentation transcript:

T HE F INCH R OBOT AND THE W HILE L OOP Pepper

T HE R OBOT Developed by Carnegie Mellon students to teach CS Supports many compilers, including Java Web site: Why – Illustrate while and do /while loops with physical example Why 2: See how hardware and physical actions can be controlled with code Lab group practice Extra: One robot available for creating game Will need to learn methods May need to debug issues Will it help you learn for the final?

H ARDWARE Input Sensors Obstacles Light Accelerometer (how fast is it going) Temperature Output Wheels turn LED lights Speaker Power Long USB Cord

I NSTALLING Download Java package from ng,%20and%20Running%20Programs%20for%20 Finch/bluej ng,%20and%20Running%20Programs%20for%20 Finch/bluej Place it in the folder you want to use Unzip it Open sample project in sourceFiles bluej.pkg Create your own package inside sample project (or add jar file finch.jar to bluej via preferences Or add finch.jar to the +libs folder inside SourceFiles)

M AKE A F INCH C ONTROLLER Bring in the knowledge: import edu.cmu.ri.createlab.terk.robot.finch.Finch; Create a finch object that knows finch commands: Finch myFinch = new Finch(); Always end with quit and exit: myFinch.quit(); System.exit(0);

C ONTROLLING COMMANDS Set Finch Beak Color: myFinch.setLED(red,green,blue); // 0 to 255 Make Finch Speak: myFinch.saySomething("The Finch will say this."); Make Finch Move: myFinch.setWheelVelocities(left,right,time) // -255 to 255 & time is in milliseconds // negative number rolls backwards // hold the cord or it may have difficulty

S IMPLE PROGRAM – package Pepper; import edu.cmu.ri.createlab.terk.robot.finch.Finch; public class FinchSimple { public static void main(final String[] args) { // Instantiating the Finch object Finch myFinch = new Finch(); myFinch.setWheelVelocities(255,255,1000); myFinch.saySomething(“I am now All Done"); // Always end your program myFinch.quit(); System.exit(0); }

G ET F INCH S ENSE I NFORMATION Obstacles: All true/false isObstacle () isObstacle isObstacleLeftSide () isObstacleLeftSide isObstacleRightSide () isObstacleRightSide Light: All true/false, but using light level threshold. Returns true if less than the threshold isRightLightSensor (10) isRightLightSensor isLeftLightSensor (10) isLeftLightSensor In dark, it will be true up to about 4 In light, it will be true up to about 40 Ex: if (myFinch.isRightLightSensor(10) == true) { System.out.println(“It is light out”);} else {System.out.println(“It is dark out”);}

M AKE IT DO AN ACTION WHILE A CONDITION IS TRUE Keep moving forward until it senses an obstacle while ( myFinch.isObstacle() == false ){ myFinch.setWheelVelocities(255,255,200); } // then back up myFinch.setWheelVelocities(-255,-255,1000);

A NOTHER - M AKE IT DO AN ACTION WHILE A CONDITION IS TRUE Spin until the lights turn off while (myFinch.isRightLightSensor(10) == true){ myFinch.setWheelVelocities(255,-255,1000); } // when the lights are out, this will be false // when the lights are on, this will be true // could say spin while lights are on // WILL NOT SPIN AT ALL IF LIGHTS OFF

D O W HILE Spin at least once, and then keep spinning until the lights turn off do { myFinch.setWheelVelocities(255,-255,1000); } while (myFinch.isRightLightSensor(10) == true); // run with lights off – see one spin first

G ET ORIENTATION INFO Orientation: All true/false isFinchLevel () isFinchLevel isFinchUpsideDown () isFinchUpsideDown isBeakDown () isBeakDown isBeakUp () isBeakUp isLeftWingDown () isLeftWingDown isRightWingDown () isRightWingDown

Y OUR T AKEAWAY Difference between while and do while Creating an object of a class gives your program powerful tools A sense of how hardware can be controlled by code Perhaps a desire to code your game using this little robot

Y OUR T URN Probably not needed, but see finch.jar in preferences Download java finch package 0Running%20Programs%20for%20Finch/bluej 0Running%20Programs%20for%20Finch/bluej New class Import above class: import edu.cmu.ri.createlab.terk.robot.finch.Finch; Inside main method, create a finch object Finch myFinch = new Finch(); Close your finch at the end of main myFinch.quit(); System.exit(0); Add code to make it move right and test. Then make it do something until it hits a wall.