Repeating Blocks of Code (updated 9/20/05 7:35pm) Reference NQC Tutorial pp 9-12.

Slides:



Advertisements
Similar presentations
Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.
Advertisements

Full Speed Ahead Introductory Presentation. Opening Activity Choose one of the objects to the right and in ten or more steps explain how it goes from.
EducateNXT The Corridor Challenge The Corridor Challenge requires programming of a robot to negotiate obstacles and the corridor walls in order to reach.
Jason Howard. Agenda I. How to download robotc II. What is tele-op used for? III. How to build a basic tele-op program IV. Getting the robot to drive.
BEGINNER EV3 PROGRAMMING LESSON By: Droids Robotics Topics Covered: Turning.
Automation and Robotics
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.
LEGO Robotics Lecture 1: Getting acquainted with your robotic environment.
NQC: Control Structures: Branching Last updated 10/6/05 10:00am References: Baum Chapter 3 pp NQC Tutorial pp Baum Appendix D pg 368.
Sending, Receiving and Processing Messages NQC Tutorial pp
2. Textual user interface NQC (Not quite C)  C-like programs translated into CRX-bytecode  Composed of: 1.Global variables 2.Task blocks 3.Inline functions.
LEGO Mindstorms RIS 2.0 Programming: NQC Code B.A. Juliano and R.S. Renner September 2004 California State University, Chico Intelligent Systems Laboratory.
Debugging (updated 9/20/06 12:48pm) It doesn’t work…. What do I do????
Using Variables Variables form a very important aspect of every programming language. Variables are memory locations in which we can store a value. We.
Inline Functions Sometimes you need the same piece of code at multiple places in your task. Inline functions are copied at each place they are used. In.
Tasks An NQC program consists of at most 10 tasks. Each task has a name. One task must have the name main, and this task will be executed. The other tasks.
Preprocessor Directives (last modified 9/19/05 2:47pm) Statements beginning with # are directives to the preprocessor. –They DO NOT end with ; –Before.
Introduction to TouchDevelop
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
LEGO Mindstorms NXT Programming We will be using the Common Palette for our Robots This is how you download your program onto the brick Drag and drop a.
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
Getting Started! Lego Mindstorms Program NXT 2.0.
Available at: Lesson 3.6 – Program Line Follower in Autonomous Mode Program Line Follower in Autonomous Mode.
Fall Week 3 CSCI-141 Scott C. Johnson.  Say we want to draw the following figure ◦ How would we go about doing this?
An introduction to Logo Mike Warriner Engineering Director, Google Note: This course is not an endorsement of Logo by Google. All views in this document.
Technical Writing for Robotic Coding!.  du/products/teaching_robotc_cort ex/fundamentals/introtoprogramm ing/thinking/videos/fundamentals.
Wall Encounter By Made easy by Dwayne Abuel.
2008 SBPLI/FIRST Programming Workshop Tom Boehm Patchogue Medford High School, Team 329 Motorola Inc. Mark McLeod Hauppauge High School Team 358 Northrop.
Programming – Remote Control Statements Intro to Robotics.
Click here Click Here Click here Match the words to the pictures Start Game Start Game Start Game Start Game How to Play How to Play How to Play How to.
Title Slide Progress Report Name. Goal Goal Statement – ex. design/create/fabricate … - should be clear and short Needs/Problems – clear and short Space.
Robot Programming. Programming Behaviors Behaviors describe the actions and decisions of your robot.
Program Flow LabVIEW Robotics Fundamentals. Unintuition You know what this program does… So what does this one do? Inserted code.
Vex Robotics Program four: reversing and turning.
By Droids Robotics INTERMEDIATE PROGRAMMING LESSON BRICK BUTTONS AS SENSORS.
Available at: – Program Functions to Accept Values Program Functions to Accept Values.
1 ©2006 INSciTE Common Blocks. 2 ©2006 INSciTE Common Blocks Common blocks are full featured actions Like English statements Move Wait for an action Display.
Tutorials NXT-G / EV3 Programming. Tutorials NXT-GEV3.
BEGINNER FLL PROGRAMMING WORKSHOP BY DROIDS ROBOTICS & EV3LESSONS.
Square Plant Stand. TOOL: Radial Arm Saw NEXT STEP: Surface Planer RESULTS: Rough size pieces for 4 Legs. 33” long PROJECT Square Plant Stand PART Legs.
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.
EV3 Programming: Moving and Turning CONFIDENTIAL © 2014 Cymer, LLC.
Bot Shop Jane Taylor Dee Wallace Robot C For Vex.
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.
Robotics and Programming Finch Robot. What is Programming?  Programming is the process of developing a command or series of commands for a computer to.
LOGICFUSION’S HANDS-ON ROBOTICS EV3 LEVEL 2! Welcome to.
By Sanjay and Arvind Seshan
By Sanjay and Arvind Seshan
BEGINNER PROGRAMMING LESSON
BEGINNER PROGRAMMING LESSON
Programming Part 2 Mod Kit
Introductory Presentation
Programming - Motion Intro to Robotics.
BEGINNER PROGRAMMING LESSON
Learning Outcomes Understand While Loop
Sensors Training.
Automation and Robotics
INTERMEDIATE PROGRAMMING LESSON
INTERMEDIATE PROGRAMMING LESSON
BEGINNER PROGRAMMING LESSON
Line Following Behavior
Storing Values as Variables
DC motor.
BEGINNER PROGRAMMING LESSON
Repeating Actions (Loops)
INTERMEDIATE PROGRAMMING LESSON
Using a Drawing Robot to Make Angles (Using Rotations)
An Introduction to VEX IQ Programming with Modkit
Preprocessor Directives
Oregon Robotics Tournament and Outreach Program
Presentation transcript:

Repeating Blocks of Code (updated 9/20/05 7:35pm) Reference NQC Tutorial pp 9-12

Making Turns You can make your robot turn by reversing the direction of one of the two motors. Here is an example. We have no way to how many degrees the robot will turn. We can try different wait times until we approximate (let’s say) 90 degrees. task main() { OnFwd(OUT_A+OUT_C); Wait(100); OnRev(OUT_C); Wait(85); Off(OUT_A+OUT_C); }

Let us now try to write a program that makes the robot drive in a square. Going in a square means: driving forwards, turning 90 degrees, driving forwards again, turning 90 degrees, etc. We could repeat the above piece of code four times but this can be done a lot easier with the repeat statement. #define MOVE_TIME 100 #define TURN_TIME 85 task main() { repeat(4) { OnFwd(OUT_A+OUT_C); Wait(MOVE_TIME); OnRev(OUT_C); Wait(TURN_TIME); } Off(OUT_A+OUT_C); }

What happens in this program? /* 10 SQUARES by Mark Overmars This program makes the robot run 10 squares */ #define MOVE_TIME 100 // Time for a straight move #define TURN_TIME 85 // Time for turning 90 deg. task main() { repeat(10) // Make 10 squares { repeat(4) { OnFwd(OUT_A+OUT_C); Wait(MOVE_TIME); OnRev(OUT_C); Wait(TURN_TIME); } Off(OUT_A+OUT_C); // Now turn the motors off }