1 / 12

Crash course in robot programming 20.02.2007 Sizarta Sarshar

C. Crash course in robot programming 20.02.2007 Sizarta Sarshar. Next two hours. C Programming The C reference Traps and pitfalls Eyebot Programming RoBios software Eyebot library Code samples Tigergutt. The C Programming Language. The C reference guide web link

xannon
Download Presentation

Crash course in robot programming 20.02.2007 Sizarta Sarshar

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C Crash course in robot programming 20.02.2007 Sizarta Sarshar

  2. Next two hours • C Programming • The C reference • Traps and pitfalls • Eyebot Programming • RoBios software • Eyebot library • Code samples • Tigergutt

  3. The C Programming Language • The C reference guide • web link • The operator precedence • web link

  4. Traps and Pitfalls “C makes it easy to shoot yourself in the foot” - B. Stroustrup “The C language is like a carving knife: simple, sharp, and extremely useful in skilled hands. Like any sharp tool, C can injure people who do not know how to handle it” - A. Koenig

  5. Traps and Pitfalls • The faults are grouped in: • Lexical • Syntactic • Semantic pitfalls • Portability pitfalls • Linkage • Library functions • The preprocessor

  6. Lexical and syntactic faults y = x/*p /* p points at the divisor */; a=-1; a = -1; while (c=getc(in) != EOF) while ((c=getc(in)) != EOF) putc(c,out); putc(c,out); switch (color) { case 1: printf ("red"); case 2: printf ("yellow"); case 3: printf ("blue"); } case SUBTRACT: opnd2 = -opnd2; /* no break */ case ADD: . . .

  7. Semantic pitfalls i = 0; while (i < n) // There is no guarantee that the adress of y[i] y[i] = x[i++]; // will be evaluated before i is incremented i = 0; while (i < n) { y[i] = x[i]; i++; } double s; double s, sqrt(); s = sqrt (2); s = sqrt(2.0); printf ("%g\n", s); printf ("%g\n", s); if (a + b < 0) if ((int) ((unsigned) a + (unsigned) b) < 0) complain(); complain();

  8. Library functions #include <stdio.h> main() { char c; while ((c = getchar()) != EOF) putchar (c); } #include <stdio.h> main() { int c; char buf[BUFSIZ]; setbuf (stdout, buf); while ((c = getchar()) != EOF) putchar (c); }

  9. Eyebot Programming • RoBios software • Download and install • Compiler • Use the shell script gcc68 for compiling a C program. It is accessed from the RoBios console. Compiling only: • gcc68 −c filename.c • Compiling and generating an output file for download to the Eyebot controller: • gcc68 filename.c • The result is stored in a file named a.out. In order to use custom output names you may use the following: • gcc68 filename.c −o filename.out • If the code makes use of the math library, add the extension -lm. • gcc68 filename.c −o filename.out −lm

  10. Eyebot Programming • Send the file from the host (PC) using RoBios console transhex: • transhex filename.out • In order to start up a program automatically at startup, call your downloaded program startup.hex and save it in a ROM slot.

  11. Tigergutt Web link

  12. The End

More Related