NAO.NET

 

NAO.NET is a .NET library for controlling NAO robot.

In NAO robot V5, Aldebaran deprecated the .NET library so it is not supported anymore.

So we decided to develop NAO.NET library to work completely with NAO robot and .NET with easier way

Also 100% compatible with python codes provided by Aldebaran robotics. So you will find it very easy to use, call Aldebaran examples and create more features witch is compatible with .NET environment,

This will allow you to concern for your projects without knowledge or care about python at all,

At the same time you can call all python programs made for NAO robot directly from your .NET code.

It works like intermediate layer between Python code generated by any Aldebaran python code and .NET environment.

So you can easily control your NAO robot using your C# or even VB.NET code.

NAO.NET can send commands to the robot, Wait until the command executed.

Also get NAO robot current values for all motors and memory values to check the actual value after executing the command.

NAO.NET execution :

 

This project contains:

Connection:

This DLL is the main Connection between your C# or VB.NET code and python source code.

So you can interact with NAO robot from this connection library.

This library is Threads based which means you can call many functions once like (open Right Hand) and (open left hand) so the robot will open both hands together , or open one hand and close the other at the same time.

When you call any Connection method it do the following:

Calling procedure:

  • Create a new Thread

This thread for run this method independently (so you can call many methods together).

But in this case please take care of the commands type because it can hurt the robot.

For example: you cannot make the robot set down and stand up at the same time.

  • Send the command:

Send the command and parameter to Python engine which execute the command with given parameters.

  • Feedback:

If you enable the Feedback option, you can retrieve the actual value for the effected values after call this method,

For example if you are moving the head to (X= 1, Y= 1), then you can get value similar like: 0.9999, depending on your NAO robot motor health, heat…

Enabling feedback option will make the robot little slower because it communicate with the robot throw XML file. So your program have to wait until the robot send xml to your program, but it is very useful to make sure for the execution result and make another action depend on that values.

 

Example Windows form Application

NAO.NET image

This windows form Application works like example for you to help you to apply and see the result.

NAO.NET program topology :

NAO.NET topology

Configuration File:

Configuration file is a pre-defined values to make it easier to use the NAO.NET library

Set the configuration file location:

Set configuration file main values:

Simple values to change depend on your program is:

Python working directory:

The folder which your python code is stored on.

RobotIP: NAO RobotIP.

Port: NAO Robot port number.

configuration files :

python file for python:

 clsStatics.clsStatics

and for .NET :

 

Using the NAO.NET

The easiest way to use the library is define an instance of the connection.

Call any method like:

MoveHead(X, Y) where

X = the x angle for the head,

Y is the Y angle for the robot head to move.

This code is equal MoveTo.py in the robot code and the parameters for the angle.

Then optionally to can read the robot values after move.

code use Example :

myProcess.StartInfo.FileName = fileName; //This is python File Name
myProcess.StartInfo.CreateNoWindow = true;
myProcess.EnableRaisingEvents = true;
myProcess.Exited += new EventHandler(myProcess_Exited);
myProcess.Start();

Expert .NET developers:

Threads

Optimal way it to create a thread before call the methods because this will allow you to create a progress bar, update the user interface or make more than one action once.

Example:

 

Python native source code:

We are developing many python source files for you so you can easily just call the methods from the library without any knowledge about the python code programming because this is the target for this library.

Just you have to install python and NAOqi.

That’s all.

This tutorials I write for this target.

How to install Python. (To let the library compile the commands for NAO)

How to install NAOqi from Aldebaran (To run the code in the NAO robot.)

Or ask us for add some more features for you as help?

 

Note:

If you feel that you need more methods to be included in the NAO.NET library, you can contact us to help you.

 

  • For professional python developers :

One of the good features in this library, it is open source from the side of Python code,

Which means you can add your own source, download any code from Aldebaran.com

 

So if you want to add python source code you downloaded or developed to the library

You have to follow some standards:

You can consider it as template you have to follow to let the python file work fine from your NAO.NET

  • main Function

The main function have to have the ability to get the parameters from the shell command (argv)

For example: in the moveHead the parameters are: (RobotIP, X, Y).

  • Actual method:

The main function send these parameters to the actual method you want to execute and pass the parameters to it.

Note:

All Aldebaran examples are native code (no functions, to make it easier to use) but to have to modify them to allow you to call it from the NAO.NET library.

Example :

if __name__ == "__main__":
   robotIP = clsStatics.clsStatics.RobotIP
   PORT = clsStatics.clsStatics.RobotPort
   Hand = "RHand"
   Angle = 1
   if len(sys.argv) > 1: 
        robotIP = sys.argv[1]
        clsFile.clsFile.logInFile(str(robotIP))
        Hand =  sys.argv[2]
        clsFile.clsFile.logInFile(str(Hand))
        Angle= float(sys.argv[3])
        clsFile.clsFile.logInFile(str(Angle))

HandMove(robotIP,PORT,Hand,Angle)
  • Return value

Return value from the “main” function is very important part because NAO.NET use it for getting the feedback from this python if it executed correctly, no errors, detect finished the execution

  • Xml writer

Xml Writer is important if you want to enable the robot to give the NAO.NET library, its actual data from the robot after execute the program.

E = lxml.builder.ElementMaker()
ROOT = E.root
DOC = E.doc
XMLHeadYaw = E.HeadYaw
XMLHeadPitch = E.HeadPitch
XMLLHand = E.LHand
XMLRHand = E.RHand

the_doc = ROOT(
        DOC(
            XMLHeadYaw('', value=str(HeadYaw)),
            XMLHeadPitch('', value=str(HeadPitch)),
            XMLLHand('', value=str(LHand)),
            XMLRHand('', value=str(RHand)),
            )   
        )

Congratulations.

Your python code is ready to be included in the NAO.NET library.

 

Project files :

project V1 files:

Demo program:

NAO.NET program

source code:

NAO.NET source code

 

article on CodeProject :

code project pageCodeproject - NAO.NET project page

Aldebaran page:

https://community.ald.softbankrobotics.com/en/content/naonet

 

Leave a Reply

Your email address will not be published. Required fields are marked *