Mindscript Presented by Dean Thomas Matthew Horoszowski.

Slides:



Advertisements
Similar presentations
1chung Robofest 2005 RCX code Workshop Jan 29, 2005 CJ Chung.
Advertisements

Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.
Exercise 1: Install PC Software & NXT Firmware
While Loops and If-Else Structures
PbForth + sum ! By Josh Jennings Ratnakar Kamath.
Team 5220 Roboknights. Outline  Getting Started  Hardware Setup/Wiring  Software Setup/Pragmas  Programming with RobotC  Grammar/Syntax  Basic Statements.
Automation and Robotics
1 PHP Statement Constructs Server Scripting. 5-2 Basic Statement All Statements end in a semicolon. Statements are delimited from the HTML code by enclosing.
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.
Available at: – Program Optical Quad Encoders in Autonomous Mode Program optical quad encoders in autonomous mode.
EIGHTH GRADE ROBOTICS KITTATINNY REGIONAL HIGH SCHOOL MR. SHEA Introduction to Programming
Motor control drive in circles Pragmas configure motors Turning right in function of time Turning left in function of time Main program starts from here.
10 November JavaScript. Presentation Hints What do YOU think makes a good presentation Some of my suggestions Don’t write full sentences on slides Talk,
RobotC Programming for LEGO Mindstorms NXT Carnegie Mellon Dacta Lego Timothy Friez Miha Štajdohar SOURCES:
1 ©2006 INSciTE Lab Two Task: Make the program from Lab One (Move forward 5 rotations and turn right 90 degrees) into a MyBlock.
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.
Testbed: Exercises.
Loops and Switches. 1. What kind of blocks are these? 2. Name two kinds of controls that can be specified to determine how long a loop repeats. 3. Give.
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.
GIRLS Robotic Camp. Let’s Begin Meet and Greet – Camp leaders introduce themselves – Students introduce themselves.
Programming 101 The Common Palette Content provided by Connor Statham (6 th Grade Student) Formatting by Shannon Sieber.
Coding for the FIRST Tech Challenge: RobotC
Teacher/Mentor Institute Using easyC Joel Kirkland July 30-31, 2015.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Forging new generations of engineers
Using Waits, Loops and Switches WAIT please!. Waits, Loops and Switches Pre-Quiz 1. In programming, what is a loop? When is a loop useful? 2. How can.
Robotics Overview of NXT-G Actuators in Mindstorms. Touch sensor Labwork: Right turn. Touch/bump. [Explore move versus Motor Move mini & motor mini. Motor*.]
A tiny turtle robot DEI The University of Padova.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering –Intro to the Robotics –Introducing the IC –Discuss.
The George Washington University Department of ECE ECE 1010 Intro: Electrical & Computer Engineering –Introducing KIPR Link/Interface and Set-up –Continuation.
CPS120: Introduction to Computer Science Decision Making in Programs.
Motors and Sound Troubleshooting Tips. © H-CCS Problem 1 Why can’t I download my program to the RCX?
Wall Encounter By Made easy by Dwayne Abuel.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
© ABB University - 1 Revision C E x t e n d e d A u t o m a t i o n S y s t e m x A Chapter 11 Structured Text Course T314.
Sentry System Multiple Sensors
Conditions and loops Day 4 Computer Programming through Robotics CPST 410 Summer 2009.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4.
Lego MindStorm An Introduction to Blocks. Blocks Blocks are used to give instructions to your robot. There are many types of blocks You can use the blocks.
Castor Bot. Now, we will begin creating a robot Log onto your computer On your screen, click on the website labeled “castor bot” Your building instructions.
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.
JavaScript, Fourth Edition
Lesson 4: Conditional Statements Programming Solutions.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class3/Lab 2.
Programming 101 The Common Palette Content provided by Connor Statham (9 th Grade Student) Formatting by Shannon Sieber.
ROBOTC Software EV3 Robot Workshop
Mindstorm NXT-G Introduction Towson University Robotics.
Concept V2.5 Lesson 17 Objectives: After completing this lesson, the learner will be able to: –Program logic using the ST Editor. –Demonstrate an Understanding.
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.
MEH108 - Intro. To Engineering Applications KOU Electronics and Communications Engineering.
Decision Making: while loops and Boolean Logic. While Loops A while loop is a structure within ROBOTC which allows a section of code to be repeated as.
Sensor Information: while loops and Boolean Logic.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Intro to the Robotics Introducing the IC Discuss.
Programming & Scratch.
Mindstorms EV3 Programming
Robotics Programming Using Shaft Encoders
Mindstorms EV3 Programming
Movement using Shaft Encoders
Mindstorms EV3 Programming
Loops and Switches Pre-Quiz
Automation and Robotics
Module F: Presentation Understanding Robot Fundamentals
Lego EV3 Mindstorms SW Programming Blocks.
Loops and Switches How Do You Make Loops and Switches? lesson > TeachEngineering.org Center for Computational Neurobiology, University of Missouri.
Lego MINDSTORMS EV3.
LEGO Mindstorms Robot and Java
LEGO MINDSTORMS NXT PROGRAMMING
Presentation transcript:

Mindscript Presented by Dean Thomas Matthew Horoszowski

Overview Created by Lego Some syntactically similarities to C/C++ Allows the use of header files Not to be confused with the open source Mindscript project

Program Layout program programname { program body } Inside the program body we have compiler directives and declarations followed by: macro macroname (parameterlist) { command stack } main { command stack } watcher watchername monitor eventlist { command stack } [restart on event] task taskname { command stack } fragment (x, y) { command stack } comment (x, y) “Any literal string all on one line”

Watchers and Tasks watcher watchername monitor eventlist { command stack } [restart on event] task taskname { command stack } start watchername stop watchername start taskname stop taskname start main stop main stop tasks Watcher and task are both thread definitions Watchers are just tasks that wait for events to be triggered Main is just another task Start and stop are used to control the flow of tasks

Macros macro macroname (parameterlist) { commands } parameterlist Comma separated list of the parameters of the macro Macros are called by name. Macros can be downloaded to RAM subroutines or the macro code can be expanded inline. The compiler will optimize to reduce code size. Example: program flashBeep { var note = 50 macro flash(times, freq) { repeat times {tone freq for 10} } macro beeps {sound 3 sound 5 sound 1} main { forever {flash(2, note) beeps note += 5} }

Conditionals if value relop value { commands } [ else { commands } ] if value is [not] range { commands } [ else { commands } ] select value { when val1 { Commands } when val2 { Commands }... when valN { Commands } [ else { Commands } ] } If statements are the common conditional statement Select statements use when to separate different cases

Loops while value relop value { commands } while value is [not] range { commands } repeat repeatnumber|random a [to b] { commands } repeat { commands } until eventlist forever { commands } There are 3 kinds of loops: while, repeat, and forever while is a loop that continues until the given condition is met repeat is a loop that continues for a certain number of iterations forever is a loop that continues indefinitely

Wait wait time|random time1 [to time2] wait until eventlist wait can be used to count time time is in 100 ths of a second wait can also block until an event is triggered

Events event eventname when value relop value fire eventlist trigger eventlist monitor eventlist { commands } [retry, abort, restart, stop] on event repeat { commands } until eventlist wait until eventlist if eventlist { commands } [ else { commands } ] // Only inside watcher stack fire triggers an event immideatly trigger tests the condition for each event in the eventlist and throw events if the condition is true Monitor watches for an event during a block of code Repeate untill will is like monitor but loops until event is triggered Wait until will block untill any of the events in the list are triggered If event checks to see if a event is being triggered and responds accordingly

Access Control priority prt try { commands } [retry, abort, restart, stop] on fail prt Number or constant (1-8, 1: High priority) Priority sets the importance of the current task Try will attempt a series of commands that make use of system resources, and respond with a fail if priority is too low to access them right now

Sensors sensor sensorname on port port number (1, 2 or 3 for RCX input ports) sensorname is type sensorname as mode sensorname is type as mode type Unknown, switch, temperature, light, rotation mode raw, boolean, transition, periodic, percent, celsius, fahrenheit, angle clear sensorname Sensor is used to decalare access to a hardware sensor Is determins the type of sensor As declares the mode of data used by the sensor Clear simply releases a sensor binding

Motors output name on port on ports on ports for time|random t1 [to t2] off ports float ports forward ports, fd ports // Short form of forward backward ports, bk ports // Short form of backward direction fdports, bkports, dir fdports, bkports // Combined fd and bk command reverse ports power ports pwr|random pwr1 [to pwr2] global (command) Output declares motors On, off, etc… used to control the motors Global + command is used to access all the motors at once

Sound sound on sound off sound soundnumber tone freq for time clear sound soundnumber Constant giving System sound number freq Constant or variable giving tone frequency ( ) time Literal expression giving tone duration in 0.01 seconds up to 2.55 sec. Sound on and off used to control power to sound Sound soundnumber used to declare what to issue Tone for used to play a certain frewuency for a certain amount of time Clear sound flushes the sound buffer

Variables var name {= value} // Allocates a global variable local name {= value} Name = value clear Variable1 Both local and global variables exist Arithmetic operators: + - * / Logical operators: & | Ordering done left to right, with () taking precedence Assignment operators can also be used: += -= *= /= &= |=

Utility Commands slot slotnumber // select program slot n (RCX: 1..5) boot rom // put RCX in boot mode ready to receive firmware boot firmware // unlocks the firmware sleep // turn off PBrick now clear sleep // resets the PBricks sleep timer sleep after timeout // turn off PBrick after t minutes randomize // re-seeds the random number generator display name[:decpoint] // selects a value to continuously monitor on the LCD watch hh:mm // set internal PBrick watch

Layout and Comments White space, comments & case are ignored. Multi-line comments (or comments within code) start with /* and end with */. Single line comments start with // - everything up to the end of line is ignored. Example: // This is a single line comment main { repeat /* this is a short comment */ 2 { // this is ignored sound 3 wait 100 /* This comment extends over two lines */ }

Example Program 1 program Avoider { #include const BACKTIME = 100 // 1 second const TURNTIME = 50 // 0.5 second const DANCETIME = 10 // 0.1 second const AVOIDLIMIT = 4 // 5 strikes and you’re out const TICKTIME = 10 // 1 second sensor LeftTouch on 1 sensor RightTouch on 3 timer Timer1 counter AvoidCount event LeftPressed when LeftTouch.pressed event RightPressed when RightTouch.pressed event DontBugMe when AvoidCount > AVOIDLIMIT event Tick when Timer1 = TICKTIME

Example Program 2 main { bbs_GlobalReset([A B C]) priority 8 clear timer1 start Heartbeat start AvoidTouch start TooMuch display AvoidCount try { forever { bb_Forward(A,C,1000) } } retry on fail } watcher AvoidTouch monitor leftPressed, rightPressed { priority 3 try { AvoidCount += 1 sound 3 if leftPressed { bb_Backward (A, C, BACKTIME) bb_SpinLeft (A, C, TURNTIME) } else { bb_Backward (A, C, BACKTIME) bb_SpinRight(A, C, TURNTIME) } } stop on fail } restart on event

Example Program 3 watcher TooMuch monitor DontBugMe { priority 2 try { sound 6 bb_Dance(A, C, 1, DANCETIME) clear AvoidCount } stop on fail } restart on event watcher Heartbeat monitor tick { priority 7 clear Timer1 try { tone 36 for 5 wait 10 tone 36 for 5 } abort on fail } restart on event }

Advantages Made by Lego Mindstorms SDK includes all necessary documentation Full use of the bricks firmware Closely coupled to the firmware’s design

Disadvantages Very limited Not many on-line resources Limited number of subroutines and tasks Works in Windows only

Links Lego Mindscript Homepage - t.asp t.asp Smart Parts Tutorials - Parts/04000.htm Parts/04000.htm