140 likes | 336 Views
ROBOTC Technical Talk. Timothy Friez Carnegie Mellon/Robomatter January 28 th , 2014. ROBOTC Overview. A complete ‘C’ programming language for robotics. Developed for Teaching, Powerful enough for Hobbyists/Professionals Developed in Microsoft Visual C++ 2008 and IAR Embedded Workbench
E N D
ROBOTC Technical Talk Timothy Friez Carnegie Mellon/Robomatter January 28th, 2014
ROBOTC Overview • A complete ‘C’ programming language for robotics. • Developed for Teaching, Powerful enough for Hobbyists/Professionals • Developed in Microsoft Visual C++ 2008 and IAR Embedded Workbench • I’ll answer the question now: NO MAC SUPPORT • Works great under Bootcamp, Parallels or VM Ware Fusion. • MAC support is desired, but hasn’t made a business/development case yet. • Extremely easy to use for both beginners and advanced users • Most “robot functions” are a single line commands.
ROBOTC Language • Single Programming Language / Multiple Platforms • Mindstorms – NXT (soon to support EV3) • Innovation FIRST – VEX PIC, VEX Cortex, and VEX IQ • Arduino - Arduino Uno, Mega, Mega 2560 controllers • Developed for Education (High School/College) • Students learn in a friendly environment about C-Based programming • Friendlier Compiler, GUI Device Configuration, Code Templates • Focus is for new programmers to C, but powerful to make experienced programmers feel comfortable.
ROBOTC as a Language • Language extensions for robotics • Built-in variables for robotics devices – motors, sensors, joysticks • Example: One line command to drive motors • NXT - motor[motorA] = 100; //Turn Motor A @ 100% • User “friendly” compiler • Auto-correct from popular programming errors • Letter case errors in variable names: “playSound” for “PlaySound”. • Compiler is NOT CASE Sensitive – This is by design!
Development Environment • Normal-style source code editor • Syntax highlighting and formatting • Code completion • Integrated help/support • Compiler, linker and program downloader – integrated and combined • No command line tools required (or available…) • Interactive Run-Time Debugger • Allows monitoring of tasks (threads), variables, devices such as motors and sensors. • User friendly • “Basic”, “Expert” and “Super User” mode to adjust features and menus • 100+ programming examples in the “Sample Code” Library
Interactive Real-time Run-Time Debugger • Run/Stop, Suspend/Resume programs from PC • Single step through program execution, one line at a time. • Unlimited user defined breakpoints • Read / write / display the contents of any user variable. • Consciously view the status of all devices in at run-time from your PC. • Zero additional coding required, enabled by default!
ROBOTC vs. “Other” Languages • #1 Reminder: You are creating code to be run of a 256kb ARM Processor – not a desktop! • Variables and Memory • The NXT Supports… • Integers, Longs, Floats, Bytes, Bool, Chars and Strings (String are limited to 20 characters – use Char[] for longer strings) • The NXT has room for 15,000 bytes of variables • Adding “const” in front of a variable will make that variable a constant. • This will prevent the variable from being changed by the program • Constants do not take up any memory on the NXT • New for ROBOTC 3.5 – Support for Pointers/Recursion (standard ANSI C-style) • ROBOTC is a procedural language – there are no classes. You can use a “struct” as an alternative for variables.
Functions and Tasks • You can create functions (up to 255) • Standard C programming style for declaration • void functionName(int parameters, float otherParameters) • Utilize library (.h) files to organize your code • You can create “tasks” too – Up to 20 tasks per program. • task myTask() – Create a Task (no parameters) • startTask(myTask) – Starts the Task • stopTask(myTask) – Ends the Task • Key thing to remember: Single processor, single thread at a time. • The internal task manager will run other tasks when idle time is available • Create idle time in a task by using the “wait1Msec(time)” command • Main structure in ROBOTC is “task main()”, not “void main()”
ROBOTC vs. “Other” Languages • Libraries and Workspaces • ROBOTC is built around a 1-program model – no workspace files. • ROBOTC automatically includes all of the headers behind the scenes • Stuff like math libraries, string support, standard language libraries are already included. • You can create your own external libraries and do a “#include” to bring them into your program. • Advanced C Data Structures • New for ROBOTC 3.5 - Pointer Support (* and &) • void testFunct(int &tempVar) • Structs and Typedefs are supported • Standard ANSI-C support in most cases.
ROBOTC vs. “Other” Languages • LCD Capabilities • You have full control of the LCD – Take a look at the help documentation / samples. You can turn individual pixels on or off, or use some of the drawing libraries already built into ROBOTC. • Advanced Ideas with NXT • I2C Support – Big 3rd party sensor library or roll your own • http://botbench.com/blog/robotc-driver-suite/ • File I/O • See Sample Programs – You can write to text files and use the NXT File Management utility to download the file to your PC • Bit Shifting and Comparators operators are available • Arrays – ROBOTC supports up to 2-dimention arrays.
ROBOTC.net Community Forums www.robotc.net/forums Over 3500+ active users Most questions can be answered here ROBOTC Technical Support support@robotc.net – Ticketing System Or e-mail Tim (tfriez@cmu.edu) or John (jwatson@robotc.net) directly Help Documentation / Function Reference Built-In and Online at www.robotc.net Video based curriculum Answers questions about how to use hardware and gives beginning programming tutorials http://tinyurl.com/RCNXTTraining Support and Curriculum
ROBOTC Licensing • You’re entitled to a free copy of ROBOTC thanks to this class • Download from http://www.robotc.net/download/nxt/ • Use the following licensing information: • ROBOTC for MINDSTORMS • License ID: 60905893 • Password: Howie2014 • You may need the LEGO USB Driver as well • This is typically included in the installer package and automatically installed. • http://www.robotc.net/files/NXT_USB_Driver_120.zip