Using the API

Principle

We will be using here specialized proxies. These give access to Aldebaran modules: they are easy to use, and their API is fully documented. For example, you can find specialized proxies to ALMotion, ALMemory, ALLeds etc.

The first step is to use Aldebaran includes. All these proxies have a specific header file that must be included, with the following form:

#include <alproxies/specializedproxyname.h>

These proxies are documented here: NAOqi modules APIs.

For example, the following includes could be used:

#include <alerror/alerror.h>
#include <alproxies/altexttospeechproxy.h>

The first include is for error handling (to catch any Aldebaran exception), the other corresponds to the specialized proxy.

Using the API incorrectly could lead to errors. To prevent your executable from crashing, you have to catch exceptions generated by them.

try {
  // Some code containing Aldebaran API.
}
catch (const AL::ALError& e) {
  // Catch the error
  std::cerr << "Caught exception: " << e.what() << std::endl;
}

To create a specialized proxy, use the corresponding constructor, giving the robot IP address in argument (the port has a default value of 9559, so do not change it unless you have a good reason).

AL::ALTextToSpeechProxy ttsProxy = AL::ALTextToSpeechProxy(robotIP);

The proxy then behaves as any class object, with methods and arguments, which will have some effect on the robot.

Troubleshooting

Compilation

If you get a compilation error coming from a function call on a specialized proxy, check the corresponding C++ API here: NAOqi modules APIs.

Network

SOAP 1.1 fault: SOAP-ENV:Client [no subcode]
"Host not found"
Detail: get host by name failed in tcp_connect()

The program tries to create a proxy to a non-reachable IP address.