RoboCatz.com
About FLL | Navigation | Playbook | Strategy | Models | Techniques | RobotC | Programming | Robot News |

Playbook: Debug Messages

What is the robot doing?
What is it thinking?
What is it seeing?
What are the values for different variables?
Did it get to a certain part of the program?
Is it stuck in a loop?
Did it make it out of that loop?
Did it freeze?
What function is it executing now?

These are all questions that a programmer asks at some time.

The answers come only from Debugging. By placing debugging messages in your program, you can get information from the robot and computer. They can tell you what they are seeing, thinking, and doing.

Play a Sound File

// Playing a sound file
task main() {
  // blah blah blah
  playSoundFile("Confirm");

  // blah blah blah
  playSoundFile("Oops");

}
The robot has built in sound files that can be heard when you play them using the playSoundfile() function. Just put the name of the sound file in double-quotes. Below are just some of the sound files that are in the robot and can be played. Note that spelling and capitalization are important. If you misspell the name of the sound file, the robot will not play it.

Activate, Backwards, Black, Blip 1, Boing, Boo, Bravo, Cat purr, Color, Confirm, Connect, Detected, Dog bark 1, Down, Eight, Error, Five, Four, Go, Good job, Green, Hello, Laser, Left, Nine, One, Oops, Ouch, Red, Right, Six, Sorry, Start, Stop, T-rex roar, Thank you, Two, Uh-oh, Yellow, Zero

Set the LED Color

The EV3 brick has a LED built in that has three colors (red, green, orange) and four states: off, solid, blinking, flashing.

// Show different colors of the LED
task main() {
  // blah blah blah
  setLEDColor(ledRed);
  sleep(1000);

  // blah blah blah
  setLEDColor(ledGreenFlash);
  sleep(1000);

  // blah blah blah
  setLEDColor(ledOrangeBlink);
  sleep(1000);

  // blah blah blah
  setLEDColor(ledOff);

}
In the above example you may have noticed the sleep() function was included after the setLEDColor() function. This was done so that the color would be displayed for 1 second (or 1000 milliseconds). You can change the number if you want it displayed for a longer or shorter period of time.

Display a message on the LCD panel

Displaying messages on the LCD screen is easy. Just be careful about where you are telling the robot to put the message. You have to specify a row indicating where the message should be placed.

// Show some messages on the LCD screen
task main() {
  // blah blah blah

  displayBigTextLine(1, "Hello World");
  displayBigTextLine(3, "I am alive");

  // blah blah blah
  displayBigTextLine(5, "Houston,");
  displayBigTextLine(7, "We have a");
  displayBigTextLine(9, " problem...");

}
Note that the LCD panel is not very big. You probably can only write about 20 letters on any one line. Don't write a book in your debug messages to the LCD screen.

Write to the debugWriteStream()

The debugWriteStream() is a special debug window in the RobotC IDE that allows you to write much more complex and longer debugging messages. Because it is a window in the computer, it does not have the same space limitations that the LCD had.

// Write a message to the debugWriteStream()
task main() {
  writeDebugStreamLine("\n=================\n");
  writeDebugStreamLine("Starting the program\n");

  // blah blah blah
  writeDebugStreamLine("\n=================\n");
  writeDebugStreamLine("I am in followLine()\n");

  // the "\n" characters used above will insert a new line

  // blah blah blah
}
To view the debugWriteStream(), open the debugger windows menu item in the "robot" menu of the RobotC IDE.

Make the Robot Speak

Making the robot speak is just as easy as playing a sound file. But you have to make sure the speech engine is loaded.

// Load the Speech Engine
#include "SpeechEngine.c";

task main() {
  // blah blah blah
  say("Starting the program");

  // blah blah blah
  say("I am in follow line");

}

Exercise

Exercise 1: Write a small program that utilizes each of the debugging methods described here. Play a sound file, control the LED, write to the LCD panel, write to the debugWriteStream window, make the robot speak an error mssage.