Sample Code for Project 2

I've generated some code samples to give a starting point for Project 2. Each of the following programs generates a simple VAL program that can be transferred to the PUMA controller via the GUI.

Each program does essentially the same thing: it defines a starting point, and then generates a circular arc trajectory (in the x-y plan) for the robot to follow. The generated VAL program has two parts:

  1. generates the arc using the DRAW command; and,
  2. generates the arc by defining points, and then using the MOVE command.
If you use the program, you should see that defining points and using the MOVE command generates a much smoother motion. This is because the DRAW command requires substantial calculation by the PUMA controller; whereas, the MOVE command just interpolates between joint positions. Here are some sample codes written in various programming languages:
  1. Sample c program (save this a "arc.c").
    To compile the c program, type
    gcc -o arc arc.c -lm
    and to execute it, type
    arc r theta count
    where r, theta and count are the desired radius, arc angle and the number of subsegments which will approximate the arc, e.g.,
    arc 45 180 10
    will produce code to trace an arc of radius 45mm, tracing 180 degrees which will be approximated by 10 straight line segments. If you type
    arc 60 90 100
    the program will produce code to trace an arc of radius 60, tracing 90 degrees which will be approximated by 100 straight line segments.
  2. Sample fortran program (save this as "arc.f").
    To compile the fortran program, type
    g77 -o arc arc.f
    and to execute it, type
    arc
    and the program will read r, theta and count from the file "input.txt." If you change the file name, you have to change the fortran code. (On a SUN computer, you should use "f77" instead of "g77").
  3. Sample perl program (save this as "arc.pl").
    Perl is interpreted so it does not have to be compiled. To run it, make it an executable file by typing
    chmod +x arc.pl
    and to execute it, type
    arc.pl r theta count
    where r, theta and count are as above. Note: you only have to run the "chmod" command one time. Even if you alter the program, you don't have to run "chmod" again.
  4. Sample java program (save this as "Arc.java").
    To compile the java program, type
    javac Arc.java
    and to execute it, type
    java Arc
    and the program will read r, theta and count from the file "input.txt" and produce the file "program.txt" which contains the VAL code that can be transferred to the Puma controller via the GUI.
  5. Sample python program (save this as "arc.py"). Like Perl, python is interpreted, so you just have to do a
    chmod +x arc.py
    and then type
    arc.py
    to execute it.

Each program has the default output VAL program written to a file named "program.txt." To have the robot execute the program, you have to transfer it to the PUMA controller using the GUI (using "Transfer" under the "Program" menu option) like you did in Project 1.

Hint: both emacs and xemacs have a "mode" in which various codes are rendered in a way that makes them much easier to read, e.g., various commands, comments, etc., are rendered in different colors. To get this mode working, you have to be running emacs or xemacs (duh), and then start the appropriate "mode" for the type of programming language you are using (if you have a .emacs file in your home directory, this may be done automatically). For example, to start the "c mode", in (x)emacs type

      ESC-x c-mode
      
For fortran, perl, or whatever, replace "c" with "fortran" "perl" or whatever.

Then type

    ESC-x font-lock-mode
    
and everything should appear in a nicely readable colorized format.

Last updated: February 28, 1999.
Bill Goodwine (jgoodwin@nd.edu)