Wednesday, November 9, 2011

Running a JAVA applet program

This is to test if JAVA is installed properly. A Java applet program which is compiled without using and IDE. The procedure is as follows

Applet Hello world
Running it from the console without any IDE

A. Creating a class extending the applet class
1. open your favourite editor and type in the following code
public class HWApplet extends java.applet.Applet
    public void paint(java.awt.Graphics g)
2. Save the file as

B. Creating a HTML file to run the applet

1. Open your editor and type in the following code
<APPLET code="HWApplet.class" width=350 height=200></APPLET>
2. Save it as HW.html in the same directory as the file

C. Compile the Java program
1. you can compile the Java program by going into the folder containing the file and using Javac

D. Running the Applet

1. Open your browser and make sure you have JRE installed and enabled. look here on details how to enable JAVA in your browser
2. Open the previously created HW.html file in the browser. it should display a "greetings" message

Running a JAVA applet in firefox
1. make sure you have installed the Java Runtime Environment
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts
2. In firefox -> tools -> Add-ons -> Plugins make sure the Java plugin is enabled

Installation of Netbeans IDE in Linux

Installation of NETBEANS IDE in linux
1. Download netbeans from (choose the version depending on your system)
2. After download is complete, cd to the download location you will find a script
3. open terminal, cd to the location of the .sh file and type
chmod u+x
(changes the execute permissions)
4. Then type "./" to execute the shell script
5. The installer pops up and you can specify the destination for installtion. (say ~/netbeans-ver)
6. Agree to terms and conditions and complete the installation
7. After installation is done open ~/.bashrc file in your favourite editor (.bashrc is a hidden file)
8. Add the follwing lines to the end of the file
 export PATH=$PATH:/location-to-netbeans/lib
(for example in this case where the location is ~/netbeans-ver type export PATH=$PATH:~/netbeans-ver/lib)
9. close the terminal and open it again and type "netbeans" to open the IDE.
10. It takes a few seconds to open the IDE. Have fun :)


Installation of Sun JAVA 6 in Ubuntu 11.04


There are a number of websites that explain how to install Java 6 on your Ubuntu machine. Here I have recorded the installation of JAVA in a brand new Ubuntu 11.04 machine.

You need to install JDK and JRE to get Java up and running in your system.

Installing JAVA 6 in ubuntu 11.04 Natty

1. Installing JRE - Java Runtime Environment
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

2. Installing JDK
sudo apt-get install sun-java6-jdk

Testing if installation is fine
1. open terminal
2. type "javac -version"
it displays the version of java compiler if installation is fine

Setting up the SDK for NAO in MAC

The source developer kit allows you to write your own Cpp or python script to be executed by the NAO. This post explains how to set up the SDK in Mac.

Download and Installation of NAO SDK
1.     Download SDK from -> software -> downloads
2.     Download cmake from and install
3.     Extract the SDK to a location (say: /path to/sdk/)
4.     export DYLD_LIBRARY_PATH= /path to/sdk/lib
5.     export DYLD_FRAMEWORK_PATH = /path to/sdk/lib
6.     export PYTHONPATH = /path to/sdk/lib
7.     go to /path to/sdk/modules/src/examples/helloworld/
8.     mkdir build
9.     cd build
10.  cmake –DCMAKE_TOOLCHAIN_FILE=/path to/sdk/toolchain-pc.cmake ..
11.  make
No errors must occur

-Cmake and the toolchain works properly in MAC no problems



Working with Choreographe - Hands on tutorial

Working with choreographe

 Preliminary steps
1. Open Choreographe
2. Open NAOSIM
3. Connect choreographe to local NAO as explained in previous posts,

1.     In the box library, choose templates – animation box. Drag and drop it on the flow diagram area
2.     Double click on the animation box, timeline pops out
3.     The time line has a number of frames. Frames are similar to the movie frames, which are played one after the other to show movement on screen.
4.     Key frames are frames that indicate a particular important position that we are interested in. other frames in the intermediate show the transition between key frames.
5.     Click on a frame at any index other than index 1 (say index 5). A blue line shows that frame is the key frame.
6.     You can specify a particular position for a limb by clicking on the limb from the 3D NAO.
7.     The motion window is displayed. Change the position of the limb according to your requirement.
8.     Click again on the timeline at an index greater than the previously chosen index (say index 20).
9.     Click on the limb and change its position again as mentioned in steps 6 and 7.
10.  Now click on the  “Play” icon in the motion timeline to see the animation in the NAO 3D window.
11.  You can delete a key frame by right clicking on the key frame and clicking delete.
12.  It is similar to adobe flash frame animation.


Virtual Simulation using NAOSIM

NAOSIM is used to simulate the NAO in a virtual environment. Make sure NAOSIM, CHOREOGRAPHE, NAOQI are installed.

1.     Launch CHOREOGRAPHE
2.     Launch NAOSIM
3.     In NAOSIM click on the start button (the play button) to start the virtual NAO
4.     In CHOREOGRAPHE, click connect and select the local NAO which has the name of the computer

Handling objects in NAOSIM
1.     Open the NAOSIM window
2.     Click on view – objects
3.     Select an object and click on the location where you want the object to be placed.
4.     You can rotate, move and resize the object using the icons that are present on the NAOSIM toolbar
5.     To delete an either select the object and press delete key (Fn+backspace in Mac) or go to view – explorer and select the object and press the delete key (Fn+bakcspace in Mac).

Testing behavior in NAOSIM
1.     Create a behavior in CHOREOGRAPHE  (example endless walk inside motion in the box library)
2.     Start the simulation
3.     You can see NAO performing the behavior in the NAOSIM window
4.     To stop the simulation, click on the stop button in the CHOREOGRAPHE window and not the NAOSIM.
5.     If you click on the stop button in the NAOSIM window, the connection with CHOREOGRAPHE gets terminated and you need to connect again.
6.     You can see what NAO is seeing using view – camera

Errors: Some times NAOSIM shows an blank window as shown in fig.

This is due to zooming in too close or a bug in NAOSIM, you can work around it by
1.     Click view – explorer
2.     Click on an item in the list
3.     Press F key
4.     The window focus is on the item selected which fixed the issue

Using Choreographe to program the NAO

·      After CHOREOGRAPHE is installed, open it from the applications folder
·      Connect to the NAO robot, (after checking out whether it is connected to the network using its IP address as described in previous post), using the connect icon
·      Enable the “Use fixed IP/Hostname” check box and type in the IP address of the NAO robot (press the center button of NAO and he will tell you his IP address)
·      After a connection is established, you will see the NAO in the NAO 3D window of CHOREOGRAPHE simulating the original NAO
·      You can program commands on the program window and have NAO execute them using the play button.
Documentation for CHOREOGRAPHE -


Setting up NAO for the first time

You need a wireless router to connect to the NAO for the first time and to set up a wireless connection in NAO. The steps are as follows.

 Installation of three software from the CD

Mandatory Step (Before a wireless connection is set up):
·      You need to connect NAO to a wired connection in order to set up a wireless connection.
·      Connect the NAO robot to a port on the router and your laptop on another port.
·      Turn the robot on.
·      Press the center button. If the robot is connected, it will say an IP address.
·      Open the web browser and type the IP address
·      A login page will be displayed. Use “nao” for both the username and password.
·      Alternatively you can use “bonjour” app that comes with safari (MAC) to connect to nao (open safari -> bookmarks -> show all book marks and click on “bonjour” in the left pane)
·      Once wired connection is setup, you can click on the network tab to setup a wireless connection.
·      The next time NAO automatically connects to the known wireless connection.

Beginning NAO


I got a new NAO to play with. I am recording the steps I followed in order to set it up and get it running. The following series is from a beginners perspective on working with the NAO robot. Hope someone out there finds it useful.

I am using a MAC for NAO though the softwares are available for Windows, Mac and Linux. For linux, the cross compilers etc have been tested with Ubuntu 10.10 (Meerkat). The cross compilers do not work with 11.04. So if you are using Linux use Ubuntu 10.10 for the "less" time consuming approach.

Have fun,