Last updated: 5:30PM 1/10/98
Notes on Allegro, Truckworld, and LISP
From review session 1/8/98
These aren't quite done, but hopefully they can already answer some questions.
Here's an overview of what we talked about in the review session along
with some details that people may have had trouble remembering:
-
Mapping drives
-
Both the truckworld code and Allegro itself are on network shares.
These are file systems connected to the NT network which you can access
remotely. To make these easier to use, you can tell the computer to pretend
that one of its drive letters is the same as that share: that's mapping
a drive.
-
When you log on to the computers in the PC labs, drive U should be mapped
to the share containing truckworld (and the other course code).
-
Double-click the "My Computer" Icon.
-
You should see a list of drives including U drive, and U drive should be
mapped to "\\ifilesrv1\courses" (ifilesrv1 = instructional file server
#1).
-
If U drive is mapped to \\ifilesrv1\courses, you're all set. Otherwise,
right click on the "My Computer" icon and choose "Map network drive...".
-
In the pull-down menu for "Drive" select U drive.
-
In the "Path" text box, type "\\ifilesrv1\courses".
-
Check the "Reconnect at Logon" box (so you don't have to do this again)
and hit the OK button.
-
Double-check with steps 1-3 that your U drive is now mapped.
-
Now, to run Allegro, you should normally just navigate the Start menu to
"Programs\Server Apps\Lisp\Allegro CL", but apparently some of the computers
do not have Lisp in the Server Apps menu. If that's the case, do the following:
-
Make sure that drive W is mapped to "\\ifilesrv1\tools" by the same steps
as for the U drive above.
-
Open the directory W:\Allegro.
-
Run the Lisp.exe program.
-
It will tell you that it has a missing or corrupted image file and to choose
a new one. Select the "allegro.img" file (or navigate to the truckworld.img
file if you want).
-
Running Allegro: image files, loading files, and getting help
-
You should be able to get Allegro started (see the previous section if
you have trouble). Once you do, you'll want to load the truckworld image.
This is simply a file that sets up the Allegro system with all the definitions
in the truckworld. To load it:
-
From the File\Images menu, choose "Load Image...".
-
Navigate to U:\cse473\truckworld. You may need to map the U drive (see
above). Also, if the U drive does not show up in the drop-down drive list,
you might try just typing "U:\*.lsp" into the File text box.
-
Select the truckworld.img file and hit OK.
-
Now, Allegro will disappear for a few seconds, then return looking as if
you just started it fresh. That's what's supposed to happen!
-
Try typing "(run-demo)" at the prompt. It should start a truckworld.
-
To use the "command-demo.lsp" file or your own LISP files, you will need
to load them into Allegro (they will not be included in the image file).
Just hit the load button (it looks like a truck carrying boxes) and navigate
to the appropriate file. The toploop will show you the results of the load
including any errors or warnings. Try to make your files load clean (without
any errors or even warnings).
-
To write your own functions and code, make a new file (by selecting "File\New"
or by clicking the blank page icon), type your code into the new window,
and save the results either locally or (better yet) to "Z:\username\"
where you replace username with your own login id. Then, load the
file into Allegro as described above.
-
There are a number of ways to get help in Allegro. Here's the two most
useful.
-
When you type a function (or variable) name and hit space, look at the
bottom of the Allegro window. You should see some information about the
function including its argument list. Note: &optional means the remaining
arguments are optional. &key means the remaining arguments are keywords
(like :command-processor). &rest means that all further arguments passed
in will be bundled up into one (sort of like with printf in C). An argument
and value in parentheses means the argument has that value as its default;
i.e., (num-reps 1) means the argument named num-reps (perhaps
the number of repetitions) will default to 1 if it isn't supplied explicitly.
-
The Allegro manual is extremely helpful. Access it either by positioning
the cursor on the word you want help on and typing Ctrl-Shift-H
or by choosing Manual Contents or Manual Entry from the Help menu.
-
Running the truckworld: quirks and commands
-
With the interactive command processor for the truckworld (you get it by
just executing "(run-demo)", and it gives you a TRUCKWORLD> prompt),
make sure to type your commands just as they appear in the truckworld guide.
That is, enclosed in parantheses but without a leading quote (') or back-tick
(`).
-
Remember that the "arm-grasp" command does not need a third argument (it
puts the object into the first free space in the arm), but the "arm-ungrasp",
"arm-pour", "arm-set", and "arm-read" commands do need the third argument.
For the first two, usually 0 is the argument you want (to indicate the
0th position in the arm's bay). For the latter two, usually
you'll want nil as the third argument (to indicate the object at the arm's
position rather than anything in the arm's bay).
-
Try to leave the arms empty and folded after each command; that way, your
commands can assume the arms start empty and folded.
-
To figure out where an arm is, find the bracket representing the arm (looks
like -[ ). If it's next to the arm bay, the arm is folded. If the
arm looks like -|> (that's a poor approximation, but basically if it looks
like a triangle) that means it's inside whatever object the icon
appears next to.
-
Use the "bye" command to quit. Use it just like any other truckworld command
(e.g., "arm-move" or "change-speed").
-
LISP: quote, quasi-quote, and useful functions
-
There were a number of questions about the quote (') and the quasi-quote/back-quote
(`). The quote essentially means that whatever expression (single symbol
or parenthisis delineated list) follows it is data and should not
be evaluated. The quasi-quote means that most of what follows is
data. Nothing in the expression is evaluated except sub-expressions preceeded
by a comma (,).
-
For example:
-
After executing the code:
-
The following evaluations hold:
-
x
=> 3
-
'x
=> X
-
'(x y)
=> (X Y)
-
`(x ,y)
=> (X 4)
-
Finally, here's a brief list of functions worth looking up either in a
LISP book or in the Allegro online manual:
-
first, second, third, ...
-
rest
-
cons, list
-
member
-
assoc
-
mapcar