Nao:      Cross GCC for OS X

Making Nao balance and walk well

Nao is an awesome little robot with all the motor skills and sensors that you can expect from a serious robot project in 2012.

My goal is to create a sense of balance for the little (60cm) biped that can scale up to much larger robots as well. For this, the robot needs to use its sensors to know its position in space and what surface is below him. It can then position its joints so that the center of gravity is inside the polygon that touches the ground.

In a second step, I will add inverse kinematics and points of interest that Nao wants to reach with its foot, hand, or head, while still maintaining balance.

The third step will be the introduction of dynamics. This doubles the number of parameters required for calculation and will be a huge step. Talking about steps: at this point, Nao should be able to convert any sequence of foot positions into a fully balanced walk on any surfece.

Downloading what we need (v1.12.3)

Using Choregraphe is out of the question for this task. We need to read sensors and update joints every 10ms. And the only way to do that is with a native library inside Nao's head. So here we go:

I am using Ubuntu 11.10 as a base for native development. I prefer OS X, but Aldebaran has not released a cross compiler for OS X (yet?).

Are you ready? Start you terminal and let's go!

  • log in and go to
  • download Choregraphe 1.12.3 Linux x32 - we will need it much later to launch our library
  • download QiBuild 1.12.3 - it's for folks like me who don't like cmake
  • download NAOQI C++ SDK 1.12 Linux x32 - there is sample code in here and other goodies
  • download NAOQI C++ Cross Toolchain 1.12.3 x32 for NAO 4 - it contains the compiler for the V4 Nao head (or use the V3 files, as needed)
  • install CMake 2.8 on your machine
  • Ubuntu uses sudo apt-get install cmake to install 2.8.5
  • install Python 2.7 on your machine
  • Ubuntu 11.10 comes with 2.7.2, so no reason to upgrade

Installing the SDK and cross compiler

Unpack your loot:

  • find a good location for all your stuff. I use $HOME/dev/NAO/
  • cd
  • mkdir dev
  • mkdir dev/NAO
  • cd dev/NAO
  • uncompress your resources
  • tar xvfz ~/Downloads/choregraphe-suite-1.12.3-linux32.tar.gz and rename it to
  • tar xvfz ~/Downloads/naoqi-sdk-1.12.3-linux32.tar.gz and rename it to sdk
  • tar xvfz ~/Downloads/nao-atom-cross-toolchain-1.12.3.tar.gz and rename it to atom-toolchain (replace atom with geode for V3 heads)
  • unzip ~/Downloads/
Install qiBuild:
  • cd quibuild-1.12.3
  • sudo ./
  • if you use tcsh, rehash
  • cd ..
Now we configure qiBuild:
  • cd sdk/doc/examples
  • qibuild init --interactive and choose
    - 1 Unix Makefiles
    - 2 Eclipse
    - Yes (Worktree)
    - toolchain opennao-atom
    - No (uniqe build tree - unless you really use Eclipse)
    - No (uniqe SDK - unless you use Eclipse)
  • you can change from Atom to Geode and back using qitoolchain create opennao-atom ~/dev/NAO/geode-toolchain/toolchain.xml --default assuming you have both toolchains installed
Let's try a simple example first:
  • cd motion/movehead/
  • qibuild configure
  • qibuild make
You should now have a program compiled for the Atom processor in the directory build-opennao-atom/sdk/bin/movehead. It's about 80kB in size.

Running the movehead test program on your Nao

Prepare Nao for native local applications and libraries. You need to do this only once.

  • Log into Nao:
  • ssh nao@nao.local (or whatever the name of your robot is. The default password is nao)
  • cd naoqi
  • mkdir bin
  • mkdir lib
  • Leave this terminal window open. We will need it again in a minute. This is our life line directly into Nao's brain.
Now we need to copy our binary from our Linux machine into Nao. Open another terminal window:
  • cd ~/dev/NAO/sdk/doc/examples/cpp/motion/movehead/ (phew)
  • rcp build-opennao-geode/sdk/bin/movehead nao@nao.local:/home/nao/naoqi/bin (all in one line!)
Go back to the Nao terminal and check if the file arrived fine:
  • ls -asl bin
  • if it is here, we can try it out right away:
  • bin/movehead launches the new trick immediatly. Remember, we are logged into Nao, and he can see himself in the network with his local IP
Did he slowly shake his head? If so, congratulations! You are prepared for huge things ahead of you!

The next chapter

Yes, I know I could have compiled movehead for my computer. I could then save me the effort of cross compiling and copying the binary over. I would not even need to log into Nao. Calling movehead with the right IP would work from any computer.

But this is only the first test. On the next page, I will compile a native local library and make that accessible to Choregraphe.

PS: If you like the headmove so much, you can tell Nao to do it every time it launches. Use your favourite text editor in Nao's terminal. Your choice is nano or vi:

  • vi preferences/autoload.ini
  • Insert this new line /home/nao/naoqi/bin/movehead below [program]
  • write the file and quit the editor
  • nao restart relaunches naoqi, and after the obligatory oGnaGnuck, movehead will be the first of Nao's bag of tricks.
PPS: If you want to install a local module (for example 'fastgetsetdcm'), you must copy it to Nao and add the module with full path to autoload.ini . Then restart naoqi with 'nao restart'.

     - Matthias