1. Teaching Method and Flexible Tools
MATERIALS FOR STUDENTS
ACTIVITIES GROUP 6 –
(SECONDARY LEVEL)
This project has been funded with support from the European Commission. This
publication reflects the views only of the author, and the Commission cannot be
held responsible for any use which may be made of the information contained
therein
2. Programming Nao,
a humanoid robot
Speech, Motion, Parallel processing, Loops, Subprograms
Boštjan Resinovič, School Center Celje
3. Nao
humanoid robot made by Aldebaran
(now Softbank)
movement
face and object detection and
recognition
speech synthesis and recognition in
multiple languages
web interaction
can be programmed in a dedicated
visual programing language
Choregraphe and in several text
based languages (Python, C++, …)
4. Installing Choregraphe
you can download the trial version at
https://developer.softbankrobotics.com/us-en/downloads/nao-v5-v4
you can register as a developer and receive a free lifelong license at
https://community.ald.softbankrobotics.com/en/developerprogram
1. Sign in, Create new account, logout
2. login at the above URL again, fill in the questionnaire (if it doesn‘t show up, click
Join)
3. choose Resources and then Software, select NAO as your robot and download
Choregraphe (carefull, if you don‘t select NAO, the version for Pepper, a different
robot, will be downloaded)
4. install Choregraphe using the licence number you received by email when you
joined the Developer (step 2)
5. Using Choregraphe
Choregraphe automatically connects to a VIRTUAL ROBOT if you don‘t have a real
one, so you will be able to do A LOT of things with Nao even if you don‘t have one
at all!
6. Using Choregraphe
Commands are represented by boxes.
Boxes are located in the Box Libraries (left bottom panel).
Programs are written by placing boxes in the main panel (central panel) and
connecting them with lines indicating the program flow.
Commands are executed from left to right (boxes have inputs on the left and
outputs on the right).
Programs are triggered by clicking on the green arrow in the tool bar and
stopped by clicking the red square in the tool bar (or when they‘re finished).
The robot‘s (a real or virtual one‘s) movement is animated in the Robot View
(right bottom panel).
The robot‘s speech and user input are available through the Dialog (bottom
right panel).
If any of the panels are not visible, they can be shown through the View
menu.
7. Let‘s do some squats
Let‘s try to program the robot to do some squats and count them.
Motivation:
learn to work with a humanoid robot and simultaneously learn lessons in computer
programming
working with Nao is fun, so programming can be fun as well
Goals:
learn some basic commands to make the robot speak and move
make the robot do more than one thing at the same time (parallelism)
perform actions multiple times (loops)
place some code in a custom box (subprograms)
8. Basics – speech and motion
Let‘s start with doing only one squat.
Write and run the following program:
the robot should fist stand up if necessary
the language is set to English (click on the wrench)
the robot says: „Ok, doing my one and only squat.“ (double click on the Say box, choose
English and write the text)
the robot does a squat (crouch with the Rest box and Stand Up again)
at the end it says „That was hard. I've had enough!“
Observe the Dialog and the Robot View panels.
9. Parallelism
Let‘s move the first Say box so the robot will do a squat and speak at the same
time.
Run the program and observe the Dialog and the Robot View panels.
What happened and why?
10. Parallelism
The second Say box is triggered as soon as the first signal reaches it.
Saying „Ok, doing my one and only squat.“ takes much less time then doing a squat.
So the robot says „That was hard. I've had enough!“ before the squat is completed!
Immediately after that the program ends and the robot still hasn‘t finished doing the
squat!
In parallel processing SYNCHRONIZATION is often needed!
11. Parallelism
Let‘s add the Wait For Signals box to synchronize the speech and movement
of the robot.
Run the program and observe the Dialog and the Robot View panels.
12. Repetition (loops)
In order to repeat actions several times loops are used in programming
languages.
In Choregraphe we can use the Counter box:
two inputs (squares on the left of the box)
the upper one increases the counter by one,
the lower one reinitializes the counter
two outputs (squares on the right of the box)
the upper one outputs the current number,
the lower one is triggered when the loop ends (the current number exceeds the final value)
parameters (accessible by clicking the wrench)
initial and final value
step
example: initial=4, final=10, step=2 => we count like this: 4, 6, 8, 10
13. Repetition (loops)
Let‘s write a program in which the robot will do five squats and count them.
the robot says „Hello, I will do five squats.“
the robot does a squat in a loop that will repeat five times
the Counter controls the number of repetitions (initial=1, final=5, step=1)
the current number from the counter is passed to the Say Text box and it stimulates the
robot‘s motion
after a squat is done and the number pronounced the Wait For Signals returns the control
to the Counter box which determines whether to do another repetition or finish
when the counting is finished (the robot has done five squats), the robot says
„That was hard. I've had enough!“
15. Subprograms
Let‘s create a new custom box Squat&Count which
represents a subprogram containing the complete code for a squat
hides the details and thus increases readability
offers usage of the new box many times (even in other programs)
Select the four boxes, right click and select Convert to box
16. Subprograms
The final code now contains everything it had before but some of the code is
in a subprogram (nested in a new box).
The subprogram‘s code can be seen by double clicking the Squat&Count box.
Clicking the root box brings us back to the main program (top level of code).