2008 SBPLI/FIRST Programming Workshop Tom Boehm Patchogue Medford High School, Team 329 Motorola Inc. Mark McLeod Hauppauge High School Team 358 Northrop.

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.
Variables and Functions ROBOTC Software. Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal.
ECS 15 if and random. Topic  Testing user input using if statements  Truth and falsehood in Python  Getting random numbers.
Automation and Robotics
VEX and Robot C Chris Patterson Presented by Modified by J. Andazola.
Autonomy using Encoders Intro to Robotics. Goal Our new task is to navigate a labyrinth. But this time we will NOT use motor commands in conjunction with.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Computer Science 1620 Loops.
RobotC Programming for LEGO Mindstorms NXT Carnegie Mellon Dacta Lego Timothy Friez Miha Štajdohar SOURCES:
IR SENSORS AND ENCODERS. LCDs Timothy Friez Class # 2.
Jennifer Goodall, Nick Webb, Katy DeCorah
1 ©2006 INSciTE Lab Two Task: Make the program from Lab One (Move forward 5 rotations and turn right 90 degrees) into a MyBlock.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Testbed: Exercises.
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.
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Looping Exercises Deciding Which Loop to Use At this.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 2.
LabVIEW Program and Data Flow Review LabVIEW Robotics Fundamentals.
For Loops. Challenge: Racer ● Simulate a race that says “Now on lap X” for 10 laps. ● Make X vary, so it says 1, then 2, then 3 ● Use only one output.
Chapter 4: Looping. Resource: Starting Out with C++, Third Edition, Tony Gaddis 5.1 The Increment and Decrement Operators ++ and -- are operators that.
Programming Concepts (Part B) ENGR 10 Introduction to Engineering 1 Hsu/Youssefi.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Programming the CheapBot-14. Start the Editor Set the Mode.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Chapter 12: How Long Can This Go On?
Engineering 1020 Introduction to Programming Peter King Winter 2010.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Documentation and Comments. What’s a comment? A comment is a simple form of documentation. Documentation is text that you the programmer write to explain.
EasyC Programming Workshop January 30, 2008 Hauppauge High School SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
Overview of Project 3 Slides are available at : Updated 1/28 Due Date for project has been extended to next Friday 2/6.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
Introduction to Loops For Loops. Motivation for Using Loops So far, everything we’ve done in MATLAB, you could probably do by hand: Mathematical operations.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class3/Lab 2.
Programming - Motion Intro to Robotics. Motors and Sensors Setup The first thing we need to do is tell ROBOTC that we have motors on our robot. Choose.
BEGINNER FLL PROGRAMMING WORKSHOP BY DROIDS ROBOTICS & EV3LESSONS.
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 5 Looping.
VEX and Robot C Chris Patterson Frisco ISD CTE Center Presented by.
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Vex Robotics program three: using motors and sensors together.
Today… Python Keywords. Iteration (or “Loops”!) Winter 2016CISC101 - Prof. McLeod1.
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.
1 ©2006 INSciTE Lab Three Task: Move forward for 2 feet, turn right 90º repeat to complete a square path. End up exactly where you started.
Python Programming Module 4 Sensors and Loops Python Programming, 2/e1.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Harpeth Hall Jan 2016 Introduction to Arduino Prepared for Harpeth Hall Winterim January 2016.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
Introduction to Programming in RobotC
INTRODUCTION TO ROBOTICS Part 5: Programming
Week of 12/12/16 Test Review.
Robotics Programming Using Shaft Encoders
Project Overview Introduction Clawbot Build Design Modification
Review If you want to display a floating-point number in a particular format use The DecimalFormat Class printf A loop is… a control structure that causes.
Chapter 5: Repetition Structures
Movement using Shaft Encoders
Automation and Robotics
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 5.
FLUENCY WITH INFORMATION TECNOLOGY
Python While Loops.
Presentation transcript:

2008 SBPLI/FIRST Programming Workshop Tom Boehm Patchogue Medford High School, Team 329 Motorola Inc. Mark McLeod Hauppauge High School Team 358 Northrop Grumman Corp.

Goals Well, duh, we want to actually make these robots DO something. Well, duh, we want to actually make these robots DO something. Learn about some basic programming language elements. Learn about some basic programming language elements. Learn about the structure of a ‘C’ program. Learn about the structure of a ‘C’ program. Learn about programming the robot controller. Learn about programming the robot controller. Learn about how this will all be different from what we actually see in January. Learn about how this will all be different from what we actually see in January. Find out how to get more information. Find out how to get more information.

But First, a Little Vocabulary Lesson. You gotta talk the talk… See the handout. There are lots of them to become familiar with, and lots more that I haven’t put down. Memorize all of them, there will be a test on them next week… See the handout. There are lots of them to become familiar with, and lots more that I haven’t put down. Memorize all of them, there will be a test on them next week…

Simple Programming Structure A single line of code that does SOMETHING, is usually called a statement. A single line of code that does SOMETHING, is usually called a statement. A group a statements collected together to perform a specific set of actions is typically called a function. A group a statements collected together to perform a specific set of actions is typically called a function. A group of functions that are collected together are called a program. A group of functions that are collected together are called a program.

Statements Try to make them very simple: int i, j, k; j = -50; i = 15 + j; k = 22; Try to make them very simple: int i, j, k; j = -50; i = 15 + j; k = 22; But they can get very complex: k = (i * 23) + (j * k * ) / (j >5) ? 23 : 12; /* This is a comment. It does not execute. k = */ But they can get very complex: k = (i * 23) + (j * k * ) / (j >5) ? 23 : 12; /* This is a comment. It does not execute. k = */

OK, so now what? That’s all well and good, but how do we make decisions? That’s all well and good, but how do we make decisions? We use conditional expressions. if (j > 5) then do something else do some other thing. if (j > 5) k = j + 1; else k = 0; We use conditional expressions. if (j > 5) then do something else do some other thing. if (j > 5) k = j + 1; else k = 0; There are many comparison operations, >, =,, =, <=, ==, !=, etc.

What if we need to do something more than once? Loops! They usually have the form: Initialize some loop condition. While (this condition is true) Do this set of stuff. Modify the loop condition. Loops! They usually have the form: Initialize some loop condition. While (this condition is true) Do this set of stuff. Modify the loop condition. For example: j = 0; while ( j < 5 ) { k = k + j; j = j + 1; } For example: j = 0; while ( j < 5 ) { k = k + j; j = j + 1; }

Loops are Cool Loops are used to count, repeat actions, or wait for something to occur.Counting loops are so commonplace, in ‘C’ they are given their own keyword: ‘for’: for ( j = 0; j < 5 ; j = j + 1;) k = k + j; // This does the same thing as last page. Loops are used to count, repeat actions, or wait for something to occur.Counting loops are so commonplace, in ‘C’ they are given their own keyword: ‘for’: for ( j = 0; j < 5 ; j = j + 1;) k = k + j; // This does the same thing as last page.

Functions A function is a set of statements that can be executed the same way over and over again, without a loop, and without re-writing the same code over and over again. A function is a set of statements that can be executed the same way over and over again, without a loop, and without re-writing the same code over and over again. Benefits: Benefits: –Once you get it working, it will always work that way no matter where you call it. –You do not have to retype the same code over again, possibly mistyping it. –It makes the whole program easier to understand. –If you do it right, maybe you can use it again next year.

Peripherals A peripheral is something that is attached to the microcomputer that performs a specialized function. A peripheral is something that is attached to the microcomputer that performs a specialized function. Examples: Examples: –Digital Port Pins: Can be 0 or 1, True or False, High or Low, On or Off, etc. Can be either an input or an output. Used for monitoring and control. –Motor PWM: Used to provide variable power to a motor to control motor speed and direction. –Gear tooth sensor: Counts gear teeth as they whiz by. Can be used to determine distance. –Gyroscope: Can be used to measure a heading. –Accelerometer: Can be used to measure forces acting on the robot. –Digital cameras, Wireless network cards, USB ports, Serial ports, Pneumatic actuators, and many, many more…

A Simple Program… Let’s just make this robot move forward, stop, turn around and move backward again… Let’s just make this robot move forward, stop, turn around and move backward again…

Now we’ll control it… Let’s see how we can control it with the remote control… Let’s see how we can control it with the remote control…

Now let’s combine them… This simple program will have the robot be operator controlled. It will also use a bumper to detect an object (by hitting it) and automatically reverse away from it and then go back to operator control. This simple program will have the robot be operator controlled. It will also use a bumper to detect an object (by hitting it) and automatically reverse away from it and then go back to operator control.

Now you try it… Look at the sample program on your laptops… Look at the sample program on your laptops… –Operator control with object avoidance –Autonomous square by counter. –Autonomous square by timing. –Speed incrementing and decrementing.

Try This: Modify the program given to make the robot run in a circle. Modify the program given to make the robot run in a circle. Run an oval. Run an oval. Run a figure eight. Run a figure eight. User the bumper to select between the three. User the bumper to select between the three.