Last modified on 14 December 2010, at 21:10

Programming AI with Leaf/Q&A

Leaf Selected Questions and AnswersEdit

Q: Can you change the names in the scripts to other names like Fred or Dave and will that change his feelings?

A: Yes. But his feelings also change over time as you interact with him.


Q: I have leaf up and running on my desktop. Leaf says Ana is his favorite person. If I replace all of the places 'Ana' is in program will another name, will that change Leaf's favorite person?

A: Yes and no. If I say "Leaf this is Bruce", then he knows me because I've put in scripts in my name (search Leaf.lisp for Bruce and you'll see). And if after identifying yourself you interact with Leaf for a while, he'll remember how you made him feel. He also remembers when he last saw you. So, if he had a good experience - or if he just hasn't seen you in a while - he'll start to want to see you.... and he'll tell you you're his favorite person. Try saying "Leaf this is Ana" - I'll bet he says he's surprised! Anyway, that's the idea - so now yes you can change the name from Ana to Dave or whoever you want... but remember Leaf's feelings change so he won't like anyone who isn't nice to him! And don't forget to add "this is Dave" to the speech.xml file. --Bruce

Q: What phases I can ask?

A: You will find the list of phrases that you can ask Leaf in the main control loop in Leaf.lisp. Also, You can add phrases there (if you do, you'll also have to add them in speech.xml). --Bruce.

Q: How much torque be enough for a wheeled version of Leaf?

A: What matters in the end is how much force the motor can apply to the ground to push the robot forward. This is a function of the basic motor torque, the gear reductions and wheel diameter.

 My basic motor which provides about 25 oz-in of torque at   stall, provides almost 900 oz-in to the wheel. Since the wheel has a radius of 4 inches,  the wheel can apply 225 oz of force to the ground (or 14 pounds).  With two wheels providing a maximum of 28 pounds of force and an 80 pound robot, (My robot) Rocky can climb about a 20 degree slope, although very slowly, and has plenty of torque for moving around on a flat floor or rugs.
 Generally it is better to use a large gear reduction since it is easier to control the wheels accurately if the motor makes a lot of turns compared to the wheel.  Just make sure you don't use so much gear reduction that the robot is not capable of moving very fast at the motors' top speed.   

Q: How fast should Leaf go?

A: I consider around 2 feet per second maximum to be a reasonable (maximum) speed since it gives you a good chance to catch up to an out of control robot before it hits something. Most Leaf robots are pretty heavy and could do some damage if they hit something (or someone) going fast.

Q: How does the emotion engine work in the leaf software architecture ?

A: Leaf has a number of different emotions - happy, sad, hungry, bored, etc. And they change continuously depending on circumstances, environment and activities - if you interact with him, he'll likely be happy, if his battery is low, he'll be hungry, etc.

He then uses his emotional state to help him decide what he's going to do next.  If he's bored, he might pick an activity at random.  If he's tired, he might take a nap.  And so on.
He also remembers his feelings in association with the people he's been interacting with.  So, let's say he's talking to me.  And he's happy.  He'll remember that for the next time we run into each other.   But if the association wasn't so good, well he might not be too pleased to see you again!
The point is that Leaf is meant to be autonomous - he's meant to have his own "personality".  He isn't meant to be just a voice controlled toy robot - oh you can put him in "command mode" and he'll follow your voice orders, but don't expect him to like it!  Anyway, his emotions are his motivation to do things (or not) - and serve then to give him a basic "personality". --Bruce.

Q: Are there any phrases in the leaf software that I shouldn't change?

A: The actual statements are meaningless except for us humans, its the emotional tags (the values that are set that really influence the way leaf reacts.


Q: How do i change the (CSLU) animated face of leaf?

A: Right click on the face. --Bruce.


Q: Why does Leaf say "goodbye" and shutdown for no apparently good reason?

A: If Leaf encounters a fatal error, he'll say "goodbye" and shutdown. The only time I've seen this happen is if he's looking for some piece of code that isn't properly loaded or running. -Bruce.

Q: How do I use wav files to respond to questions in place of the computer voice.

A: You put your wav files in the LeafSounds folder. Now create a shortcut in Leaf.lisp (look near the beginning of the code listings) that looks something like this:

(defconstant burp "c:/Program Files/Leaf/LeafSoun ds/burp.wav" )

Now if you want Leaf to make a sound just use this kind of statement:

(PlayWav burp)

So anywhere I've used sapi-tts to have Leaf talk, you could use a PlayWav instead to make a sound. -Bruce


Q: When making a shortcut, does the shortcut name have to match the file name exactly?

A: Yes. -Bruce


Q: Do I need a shortcut for every wav file instance?

A: Yes. -Bruce


Q: Does a text phrase need to be written for every question leaf is to understand and is this how I add more questions leaf will understand?

A: Yes. We haven't really developed natural language processing. In the meantime, Leaf "understands" by simply matching text phrases you've previously entered. And, when adding phrases to the control loop, and don't forget to also add them to the speech.xml file. -Bruce


Q: How do I point leaf to the matching response/responses to a text phrase?

A: Once a phrase is heard and matched to a phrase you've entered into the control loop, you call a script you've written to do whatever you want it to do. -Bruce


Q: Can I customize leaf so that instead of using Microsoft's TTS, he plays pre-recorded sound files of such robots as the Lost in Space Robot(B9), or Robby the Robot, or R2D2 or C3P0 or Wall-E?

A: Yes. A few of the B9 owners have (my) customized Leaf software that does that using pre-recorded wav files. It's not hard, but it is quite time consuming programming in every question and answer that you want your Leaf/B9/Wall-e to answer. -Thomas Messerschmidt

Q: What does "OSLA" stand for?

A: OSLA (Objects Situations Location (and) Actions)is the top level "parent" node in a portion of Leaf's programming that I programmed in Lisp's Object Oriented code known as CLOS. The "children" are Objects (i.e. things), Situations (Leaf's internal emotions and "state"), Location (where he is at the moment) and Actions (activities that he can choose to do)...I left it in there so anyone with an interest in such things could look at it and use it as an example... --Dr. Bruce.

Q: How do I play MP3 files with Leaf?

A: Here is some sample code that will let you play MP3 files:

(defconstant mysong "C:/MyLeafMP3s/mysong.mp3")

(defun PlayMP3 (mysong )  ;

 (sys:call-system mysong :wait nil)
 )
Note that you will need the full path to your mp3 file and that you must not have any spaces in the directory name or the file name. Your default MP3 player must be WMP. I'm not sure what will happen with others. I noticed that the first time it may clip off the beginning of the file. Also, it does not close WMP.

Q: How do I use Roborealm to navigate leaf through doorways using its "gates" function?

Q: How do I hook up and use Microsoft's Kinect sensors?

Q: How do I get leaf to identify items in his environment?

A: This has been done with Roborealm software.

Q: How do I navigate with Roborealm and fiducials?

Q: How do I use Leaf's chatbot code that Bruce wrote?

Q: Did Anyone Ever get the leaf chatbot to work? A: Yes.The trick is to use the LeafInterfaces.lisp folder and the Leaf.lisp folder and the speech.xml that comes with the chat program.

Q: What are the latest files and versions for Leaf?


Q: How do I set up and use Leaf's face recognition? A: This has already been explained in the Make Your own Leaf section.


Q: How do I get Leaf to pull and read data from such places as Wiki?


Q: How do I get Leaf to read my email to me from the Web?


Q: How do I get Leaf to read the latest news, weather and sports? A: This has already been explained in this wiki.


Q: How do I keep Leaf from running into walls or down stairs? A: Install the sharp IR sensors for either bumpers or cliff detectors. Also, you can install Ultrasonic sensors. Also, you can use actual bumper switches.


Q: How do I use the X10 to turn on and off lights in my house?