CSC 161 Schedule Readings Labs & Projects Homework Deadlines Resources

Using the Scribbler 2 with MyroC

Today we introduce how to program the Scribbler 2 robot in using the MyroC library, demonstrating how to integrate the eSpeak package to vocalize commands.

Introducing the Scribbler 2

First, you should read the S2 start-up guide, pp. 3–6 (one is with each robot) to familiarize yourself with the general logistics of using the robot.

Programming the Scribbler 2 with MyroC

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 signatures 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 Scribbler2/MyroC Programs

From the lab on Linux basics, the following lines should already be placed in your .bashrc file:

# make the libraries known to the execution environment
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/walker/Myro/lib"

export LD_LIBRARY_PATH

Assuming the program is called scribblerlab.c, you could compile the program using the following line in your terminal window:

gcc -I/home/walker/Myro/include/MyroC -L/home/walker/Myro/lib -lMyroC -lbluetooth -ljpeg -o scribblerlab scribblerlab.c

The MyroC interacts directly with a bluetooth package for Bluetooth communication in Linux. This requires the additional parameter -lbluetooth, which instructs the linker to include these libraries in the final program. In addition, some Scribbler operations include image processing, requiring the linking parameter -ljpeg.

This line is clearly too long and awkward to type for compiling each MyroC/eSpeak program. Thankfully, if you have placed a copy of the Makefile, (as described in the lab on linux basics) in the same directory, you can simply use make

make scribblerlab
Commentary: Look at the Makefile you copied to your directory during the lab on Linux basics.

Once the program has been compiled (with compiled name scribblerlab):

Examples

Read over the longer examples, earsHangLow.c and spirit-song.c

You should also briefly review the MyroC.h header file to see what functions you will eventually be able to use with the robot.