| CSC 161 | Grinnell College | Spring, 2012 |
| Imperative Problem Solving and Data Structures | ||
When a C program is used to control a Scribbler 2 robot, processing follows four main steps:
The program references the MyroC library, which contains
numerous operations for the Scribbler 2 robot.
The workstation establishes a wireless connection with the robot, using
the command: rConnect("/dev/rfcomm0");
Processing with the robot continues, using commands from
the MyroC library.
For consistency in naming, all robot commands start with "r",
such as rConnect, rBeep, and rDisconnect
The workstation stops its wireless connect with the robot, using
the command: rDisconnect();.
These steps are illustrated in the following program; steps for compiling and running the code follow the program listing.
/* This program illustrates how to connect to the Scribbler robot, beep, and disconnect.
*/
#include "MyroC.h" // include the library for Scribbler commands
int
main()
{
rConnect("/dev/rfcomm0"); // connect to Scribbler
rBeep(1,550); // beep for 1 second at a frequency of 550 Hz.
rDisconnect(); // disconnect from Scribbler
return 0; // return, indicating no errors have occurred
} // main
From the third lab on Linux basics,
the following lines should be placed at the bottom of your .bashrc file:
### MYRO LIBRARIES ###
## Myro C -- When using libMyroC.so ##
# include the location of the MyroC header #
C_INCLUDE_PATH="$C_INCLUDE_PATH:/home/walker/Myro/include/MyroC"
# include the location of the MyroC shared library object file #
LIBRARY_PATH="$LIBRARY_PATH:/home/walker/Myro/lib"
# make the libraries know to the execution environment #
LD_LIBRARY_PATH="$LS_LIBRARY_PATH:/home/walker/Myro/lib"
export C_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH
######################
Assuming the program is called scribblerlab.c, compile the
program using the following line in your terminal window:
gcc -lMyroC -o scribblerlab scribblerlab.c
Once the program has been compiled (with compiled
name scribblerlab):
Be sure the Scribbler 2 robot is turned on, with its lights on.
(If the program does not respond to subsequent commands, either turn it off
and back on again, or press the "reset" button near the IPRE fluke card.)
Run the program in your terminal window just as you would any C program:
./scribblerlab