CSC 161 Grinnell College Spring, 2012
 
Imperative Problem Solving and Data Structures
 
 

scribblerlab.c: A first C program using the Scribbler 2 robot

When a C program is used to control a Scribbler 2 robot, processing follows four main steps:

  1. The program references the MyroC library, which contains numerous operations for the Scribbler 2 robot.

  2. The workstation establishes a wireless connection with the robot, using the command: rConnect("/dev/rfcomm0");

  3. 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

  4. 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

Compiling and Running Programs

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):