a1tD0000006kkKIIAY

Course: Introduction to Programming with NAO
9: Programming Logic

  • 6-8 grade
  • Beginner

Lesson Description:

In this lesson, the students will make Nao robot ask a question and listen for the answer by using Switch Case and Speech Recognition boxes in Choregraphe.

image description

Lesson Modules


Teaching Tips:

Before Class
Room Setup
Follow the Room Setup Instructions.
Load Choregraphe Program
Find the Choregraphe sample program that corresponds to this lesson. Make sure it runs on one of the robots. 
Wash Hands
Have all students wash their hands before entering the class. 

Introduce the Lesson
Problem of the Day (5 minutes)
Have a student read the problem of the day. Discuss what it means. Today the students will have Nao ask the audience a question during the story. The robot will then change the path of the story based on the audience response. 
Sample Program (5 minutes)
Run the sample program and have the students complete the Robot Story! activity.
Designate one student to respond to the robot. The only possible responses to the question are Yes or No. The student should wait until the robot beeps and the lights around the ears start moving before answering the question. This behavior indicates that the robot is listening for a response.
You may want to run the program twice to show the students that the ending does change based on what you say to the robot. 

Before Class
Wash Hands
Wash your hands before entering the class. 

About the Lesson
Problem of the Day 
Read the problem of the day. The problem of the day is "How can you make NAO ask you a question and listen for the answer?" You will discuss what it means with your teacher.
Sample Program 
Watch the sample program that your teacher shows you carefully. Then complete the Robot Story! activity on the next page. 



Robot Story


Listen to NAO tell his story then answer the questions on this page.

Where were the two ending choices?

Which ending did you choose?

What do you think would have happened had you chosen the other option?

Now, draw a picture of your favorite ending on a piece of paper!


Teaching Tips:

Your Story! (5 minutes)
Have the students fill out the Your Story! questions. Students should write multiple endings for their story that depend on the response to a particular question. The responses do not have to be “yes” or “no”, but should be limited to one or two words each (i.e. “not blue” is OK, but “He should choose the one that is not blue” is not OK). 

Your Story!


Fill out the questions below. You should write multiple endings to your story that are based on the response to a particular question. The responses do not have to be "yes" or "no",  but should be limited to one or two words each (i.e. “not blue” is OK, but “He should choose the one that is not blue” is not OK). 

Now add the two endings in to story.

ENDING 1

Draw the ending 1 on a piece of paper.

Describe the ending of your story in 5 words.

NAO will say...

 

ENDING 2

Draw the ending 2 on a piece of  paper.

Describe the ending of your story in 5 words.

NAO will say...


How will you switch between the two possible endings you’ve created? (There’s a hint in that sentence)

We know you will need:

  1. Some way for Nao to recognize what you are saying
  2. A conditional (based on what Nao hears you say) that determines the action she will take
  3. Different code paths for Nao to take after each option

It may be helpful to think about it like a choose your own adventure book.


Page 1

You are sitting in a dimly lit tavern eating hot wings. A group of villagers approach you, looking frightened. “Help!” an old woman cries my poor kitty has been stolen by a werewolf!”

            To agree to help the villagers find the kitten, turn to page 5.

            To tell everyone to leave you alone, turn to page 8.

                        Page 5

The villagers tell you they saw the wolf flee into the dark forest at the edge of the village.

To run toward the forest, turn to page 11.

To go collect some supplies, turn to page 12.

To chaqnge your mind and return to the tavern, turn to page 14.

Page 11

You are standing on the edge of a dark forest. A wolf howls in the distance, and you feel a chill go down your spine. Could it be the werewolf?

To investigate the forest, turn to page 16.

To return to the general store for a flashlight, turn to page 20.

To walk back towards home, turn to page 21.

 

Seems pretty simple, right? But just like in real life, decisions build on each other, and the options you have for the second decision depends on the decision you made for the first!

As you write the rest of your story with Nao, you need a way to keep track of past decisions and help him respond in the correct way. How can we “choose our own adventure” with Nao? Using programming logic!


You have heard these two logical operators used in plain English:

AND – if X is true and Y is true, the result is true

OR – if X or Y (or both) is true, the result is true


These logical operators are a little strange

NAND – if X is true and Y is true, the result is false

NOR – if X is false and Y is false, the result is true


You can use this logic to make your own adventure with Nao more customizable.

Try rewriting your story to use 3 of these new logical operators.


Teaching Tips:

Demonstrate New Content (10 minutes)
Show the students how to use the Switch Case box. Then have them read through the Making a Choice! module student view.

Read the reference to make Nao listen for the correct responses.


Student Implementation (25 minutes)
Have students work on adding the Speech Reco box and their multiple endings to their story in Choregraphe. When they are done, they should move on to the Reflect and Revise! module. Walk around to check that students are on task and making progress with their stories. 

Making a Choice!



You are going to have Nao ask where the characters should go in your story. Depending on your choice, Nao will change what he says. Here is how you program this in Choregraphe.


1. Ask The Question.
Drag out an animated say from the box library. Have Nao ask the question. Plan your question in the space below.

Nao will ask...

 


2. Listen For The Response.

Drag a Speech Reco box out from the box library. Read the reference to make Nao listen for the correct responses.

What are the possible responses you want Nao to listen for?

 


3. Change The Flow.


 

Drag out a Switch Case box from the box library. Connect it to the Speech Reco box as in the picture.
Type the same options from your Speech Reco box into your Switch Case box. Make sure to use quotation marks around each case!


Teaching Tips:

Silent Journaling (5 minutes)
Have students fill out the Reflect! activity. They should work silently for a few minutes.

Group Discussion (5 minutes)
After they have journaled, discuss their responses as a group. 



AFTER CLASS


Store Student Files
Put the student files on a thumb drive or store them in some way so that the students can continue working on their project in the next lesson. 

Pack Up Hardware
Pack the robots and computers according to the packing instructions

REFLECT and REVISE!


Test your code on the real robot. Remember, the Speech Reco box will not work on the virtual robot. After testing, answer these questions.

Test your code on the real robot.

What did you change about your code?

What effects did it have on the program?

Did it work as you expected?
  • Not at all
  • Not really
  • Kind of
  • Pretty much
  • Totally

 



Silent Journaling 

Fill out the following questions. You should work silently for a few minutes.

What will change next about your story?


Group Discussion 
After you have journaled, discuss your response with your group. 





AFTER CLASS

 

Store Your Files
Store your file(s) on a thumb drive or in some way. Follow your teacher's instruction so that you can continue working on your project in the next lesson. 

Pack Up Hardware
Your teacher will pack the robots and computers according to the packing instructions. Follow your teacher's instruction for packing up the hardware.