How to Control a Robot Kickoff 2011. Why, How, Where? Sense, think, act Robot, laptop, your brain GameRobot Human Game State Score External Sensors Internal.

Slides:



Advertisements
Similar presentations
Classes And Objects II. Recall the LightSwitch Class class LightSwitch { boolean on = true; boolean isOn() { return on; } void switch() { on = !on; }
Advertisements

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.
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Introduction to Arrays Chapter What is an array? An array is an ordered collection that stores many elements of the same type within one variable.
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
ITC 240: Web Application Programming
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
Loops – While, Do, For Repetition Statements Introduction to Arrays
Aalborg Media Lab 23-Jun-15 Software Design Lecture 6 “Conditionals and Loops”
1 Lecture Today’s topic Arrays Reading for this Lecture: –Chaper 11.
Introduction to Computers and Programming Class 6 Introduction to C Professor Avi Rosenfeld.
Learning C really fast A power point for Jay. RobotC vs C RobotC is slightly different than C We will cover standard C Then RobotC differences.
Understanding class definitions Looking inside classes.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Java Unit 9: Arrays Declaring and Processing Arrays.
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.
Java for Robots How to program an NXT robot with a Java Brain Bert G. Wachsmuth Seton Hall University.
chipKit Sense Switch & Control LED
Multiple Choice Solutions True/False a c b e d   T F.
Unit 5 – “Watch Out!”. Introduction New Topics Case Structures New Functions Less? Comparison Function Ultrasonic Sensor.
Lec 19 Array Intro. Agenda Arrays—what are they Declaring Arrays Constructing Arrays Accessing Array cells.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Arrays (Part 1) Computer Science Erwin High School Fall 2014.
Arrays Chapter 8. What if we need to store test scores for all students in our class. We could store each test score as a unique variable: int score1.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
Session Three Review & Conditional Control Flow. Java File Hierarchy Projects Packages Classes Methods.
Code The Arduino Environment.
Question 1a) What is printed by the following Java program? int s; int r; int i; int [] x = {4, 8, 2, -9, 6}; s = 1; r = 0; i = x.length - 1; while (i.
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.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6: Transition to Java Programming with Alice and Java First Edition.
Today’s Agenda  HW #2 Out  Replay Semaphore and Lock  Advanced Locking Advanced Topics in Software Engineering 1.
CS 139-Programming Fundamentals Lecture 11B - Arrays Adapted from a presentation by Dr. Rahman Fall 2014.
Repetition. Loops Allows the same set of instructions to be used over and over again Starts with the keyword loop and ends with end loop. This will create.
Review TEST 2 Chapters 4,5,7. QUESTION For which type of operands does the == operator always work correctly: (a) int, (b) double, or (c) String?
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Programming with LabVIEW Intro to programming and.
11 PART 2 ARRAYS. 22 PROCESSING ARRAY ELEMENTS Reassigning Array Reference Variables The third statement in the segment below copies the address stored.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Data Structures Arrays and Lists Part 2 More List Operations.
Midterm Review Tami Meredith. Primitive Data Types byte, short, int, long Values without a decimal point,..., -1, 0, 1, 2,... float, double Values with.
Vector program patterns Vectors contain many elements, so loops are common. Counted processing // Print the first 3 elements. for (int i = 0; i < 3; i++)
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
Loops. Review Control Structure – making decisions if-statement Program Design Understand what you want to do Design your solution Write and test your.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS 1 Copyright: 2015 Illinois Institute of Technology_ George Koutsogiannakis.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 4 Making Decisions.
CC213 Programming Applications Week #2 2 Control Structures Control structures –control the flow of execution in a program or function. Three basic control.
Introduction to Robots and the Mind - Programming with Sensors - Bert Wachsmuth & Michael Vigorito Seton Hall University.
Python Programming Module 4 Sensors and Loops Python Programming, 2/e1.
Sensor Information: while loops and Boolean Logic.
Basic concepts of C++ Presented by Prof. Satyajit De
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Java for Beginners University Greenwich Computing At School DASCO
Chapter 3: Decisions and Loops
JavaScript.
Java Programming by Ramiro Rocha.
Chapter 4 – Control Structures Part 1
1 Code
LRobot Game.
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
Code Refresher Test #1 Topics:
Relational Operators.
While Loops and If-Else Structures
Objectives: Graph (and write) inequalities on a number line.
While Loops and If-Else Structures
While Loops And If-Else Structures
Presentation transcript:

How to Control a Robot Kickoff 2011

Why, How, Where? Sense, think, act Robot, laptop, your brain GameRobot Human Game State Score External Sensors Internal Sensors Robot’s Actions Robot’s Software Human Senses Drivers Brain User Interface

Moving in a Circle public void UserControlledCode() { while (true) { if (robot.isAutonomous == false) { lock (studentLock) { if (true) { //Ignore leftMotor.motorSpeed = 100; rightMotor.motorSpeed = -50; } Robot’s Actions Robot’s Software

Types and Variables Declare: double x; Assign: x = 3.5; Use: i nt y = x; z = 8 - y + x; x = x + y; = is assignment (not equals) C#: Value type vs. Reference type C# is case sensitive

Avoiding Obstacles Button = new InputPort((Cpu.Pin)FEZ_Pin.Digi tal.IO4, true, Port.ResistorMode.PullUp); if (Button.Read()) { leftMotor.motorSpeed = -60; rightMotor.motorSpeed = -30; Thread.Sleep(1000); }

More Avoiding Obstacles External Sensors Robot’s Actions Robot’s Software

Program Flow Decision Consequences Should I fire the balls? Fire the Balls More Code Code Should I fire the balls? Fire the Balls More Code Code Reload the Shooter

Program Flow if (isFiring) {shooter.shoot()} else {shooter.reload()} if (condition1) {consequent1} else if (condition2) {cosequent2} else {alternative} Use to change behavior depending on input

Tank Drive //-100<=motorSpeed<=100 //0<=Joystick values<=255 leftMotor.motorSpeed = ((double)(robot.UIAnalogVals[1] - 128) * 100 / (double)128); rightMotor.motorSpeed = ((double)(robot.UIAnalogVals[3] - 128) * 100 / (double)128);

More Tank Drive External Sensors Robot’s Actions Robot’s Software Human Senses Drivers Brain User Interface

Using Objects Cat john = new Cat(10); int johnsMass = john.Eat(5); john.Purr(); john.name = "Johnny"; john.name = "John"; Console.WriteLine(john.name); Console.WriteLine(johnsMass);

More Objects To create: new Type(arguments,...); Field or Property: variableName.member Methods: variableName.member(argument,...)

Robotic Objects Declare Objects here public class StudentCode { // Variables private Robot robot; private SimpleMotorController rightMotor; private InputPort Button; //More code

More Robotic Objects Instantiate Objects here public StudentCode(Robot robot) { Button = new InputPort((Cpu.Pin)FEZ_Pin.Digital. IO4, true, Port.ResistorMode.PullUp); leftMotor = new SimpleMotorController(robot, "COM1", 13); rightMotor.motorBrake = 0;

Arrays To Create: int[] myArray = new int[5]; To access elements: variableName[index]; Size: myArray.Length myArray[0] = 12; Arrays are 0 indexed myArray[] myArray[0] myArray[1] myArray[2] myArray[3] myArray[4]

Relational and Equality Operators Equality x == y Inequality x != y Less than x < y Less than or equal to x <= y Greater than x > y Greater than or equal to x >= y Turn numbers into booleans

Boolean Operators Exercise: (!(12-3 > 8) && (3*5 == 15)) || ( !(17 < 18) || true) if ( (time <= 30) && !(mode == 2) ) { driveForward(); } And true && true Or true || false Not !true

Tracing a Polygon int i = 0; while (i < 5) { leftMotor.motorSpeed = 50; rightMotor.motorSpeed = 50; Thread.Sleep(1000); leftMotor.motorSpeed = -50; Thread.Sleep(500); i++; }

Tracing a Polygon for (int i = 0; i < 5; i++) { leftMotor.motorSpeed = 50; rightMotor.motorSpeed = 50; Thread.Sleep(1000); leftMotor.motorSpeed = -50; Thread.Sleep(500); }

Loops initialize while (condition) { body postBody } for (initialize; condition; postbody) { body }

User Controlled Code public void UserControlledCode() { if (robot.isAutonomous == false) { lock (studentLock) { //All code for the teleoperated period goes here. It is in an infinite while loop so it is continuously executed. }