NAO

NAO Tips Vol. 2

Tip 3: What is Python code? 

When working with Nao in Chorégraphe it is great to remember that every base Box is made of Python Code that you can read and edit. You can also create your own Python box using the Python template in the standard box library.  Python is a specially designed programming language for teaching and learning. If you have learnt another programming language the hard way it is abundantly clear that Python is a wonderful language. Conventional programming languages tend to yell at you for the simplest of mistakes and the error messages are painfully hard to translate. Python on the other hand, is kind. If you have an error Python will tell you exactly what you did wrong and often how to fix it. As the boxes in Chorégraphe are made of python code it supports an incremental approach to learning programming. You can create your own code that to do something simple, then connect that to other boxes in Choregraphe to make some very interesting things happen. For example, the code to tell if a number is odd or even is shown below. This code allows an exercise app in Chorégraphe to alternate arms as it counts the reps.

If you would like to know more about programming in Python a good place to start is the Python documentation: https://docs.python.org/2/library/index.html. Here you will find every command available in Python. In the next issue we will be doing a deep dive into writing your own python module to get Nao to say the day of the week. 

Teaching the Australian Digital Technologies curriculum with a NAO humanoid robot

This post has been created to show you a series of examples of how a NAO humanoid robot and its programming software, ‘Choréographe’, can be used to teach elements of the new Digital Technologies curriculum at each level.

Foundation to Year 2

Follow, describe and represent a sequence of steps and decisions (algorithms) needed to solve simple problems (ACTDIP004).

 Example with NAO:

Students could program a NAO robot to introduce itself to their class. Students could program the following sequence using the drag-and-drop interface in ‘Choréographe’ and then have the robot perform the sequence.

Above:   Drag-and-drop programming with NAO’s software ‘Choréograpghe’ which features a virtual robot that allows students to test their programs without a physical robot. Choréographe can also use ‘Python' code. 

Above: Drag-and-drop programming with NAO’s software ‘Choréograpghe’ which features a virtual robot that allows students to test their programs without a physical robot. Choréographe can also use ‘Python' code. 

First NAO is programmed to stand up, then NAO waves to the class, and finally NAO will say: “hello my name is NAO and I am a humanoid robot”

Years 3 - 4

Define simple problems, and describe and follow a sequence of steps and decisions (algorithms) needed to solve them [ACTDIP010].

Example with NAO: 

Jane needs to find out the favourite colours of her fellow students. Jane can program NAO in the following way to survey her class.  

NAO will first ask: “what is your favorite colour”? Then a speech recognition box is activated. If the robot hears “Red” it will respond, “Me too”! If the robot hears "Blue", it will reply, “I don’t mind Blue” and if the robot hears "Yellow", it will respond “Eww I don’t like Yellow very much”.

Jane can create a table to record the results of her survey.

Years 5 - 6

Design, modify and follow simple algorithms represented diagrammatically and in English involving sequences of steps, branching, and iteration (repetition) [ACTDIP019].

Example with NAO:

Susan has designed a math quiz game using a NAO robot. 

Susan has programmed the robot to ask a series of Math questions and then listen for answers. When the robot hears a correct answer it will take a step forward and when it hears an incorrect answer it will take a step backwards. Correct answers will prompt the robot to move onto a new question whereas incorrect answers will prompt the robot to repeat a question. This exercise covers sequencing, branching, and iteration (repetition).

Years 7 - 8

Design algorithms represented diagrammatically and in English; and trace algorithms to predict output for a given input and to identify errors [ACTDIP029].

Example with NAO:

Students can design an algorithm to solve a maze using a NAO robot.

Provided that the maze is ‘simply connected’ – meaning that all of the walls are connected together or to the boundary of the maze - the ‘right-hand-rule’ can be used to solve the maze.

Accordingly, the following three 'right-hand-rules' can be used:

1.      If a wall is NOT detected to the right, turn 90 degrees right and then walk forward

2.      If a wall is detected to the right, but no wall is detected in front, walk forward

3.      If a wall is detected to the right and a wall is detected in front, then turn 90 degree to the left

Students can use python code within Choréographe to express this algorithm:

Once the student has designed their algorithm they can upload it to a NAO robot and place the robot within a maze for testing. 

Brainary Interactive Choregrape NAO 5.png

Years 9 - 10

Design algorithms represented diagrammatically and in structured English and validate algorithms and programs through tracing and test cases [ACTDIP040].

Example with NAO:

Students can design an algorithm to take coffee orders.

Firstly the robot is programmed to ask, ‘would you like a coffee?’ If the respondent answers ‘no’, the robot replies, ‘no worries’. If the respondent answers ‘yes’, the robot will then ask, ‘would you like sugar?’

If the respondent answers ‘no’, the robot will respond, ‘okay thank you for your order’.

If the respondent answers ‘yes’, the robot then asks, ‘how many sugars would you like?’ then the robot will say, ‘okay thank you for your order’.