Search code examples
nao-robotpepper

Can I use NAOqi 2.5 (C++/Python SDK) features on a NAOqi 2.9 (QiSDK) robot (Pepper)?


I have the Pepper robot running NAOqi 2.9, which is meant to use the QiSDK for its Android tablet. Things have been going well, but the photo capture rate is surprisingly slow (at most 2 fps), so I've got to use the C++ (or Python) SDKs available for NAOqi 2.5 for this particular task.

I've been trying to get it to work for a few days with no success. I have setup both the C++ and Python SDKs up and running, but the problem I'm facing is connection to the robot.

I've run the simple following code (using the robot's IP) found on the official website here

from naoqi import ALProxy
tts = ALProxy("ALTextToSpeech", "<IP of your robot>", 9559)
tts.say("Hello, world!")

and I'm getting the following output stream after the second line

The connection problem occurs running either C++ on Ubuntu, or Python on Windows.

I can connect to the robot via SSH, FTP, QiSDK in Android Studio, but not in any way through the NAOqi 2.5 SDKs for C++ or Python. Since QiSDK was most probably build on top of the C++ SDK, there surely has to be a way to make this to work.

Any information will help immeasurably.


Solution

  • Edit

    There's another way, you can use the qi Python library inside Pepper's head, in order to use services, such as ALTextToSpeech or ALMotion, with a simple example here. One could also only use SSH to start a Python server, which would give access to these functionalities through endpoints.

    import qi
    
    app = qi.Application()
    app.start()
    session = app.session
    tts = session.service("ALTextToSpeech")
    tts.say("Hello Word")
    

    If you run the above snippet inside Pepper's head it produces the expected output(saying Hello world). There are almost all the services that are documented here. You can also list them all by calling .services() on the session object

    End of Edit

    I finally found a way to hack into it. If you connect to the robot via SSH you can use the qicli binary. Its documentation is here

    qicli info lists all services available, for example ALVideoDevice or ALMotion

    qicli info ALMotion displays the available methods of that service

    qicli info ALMotion.setAngles displays info about that method's parameters

    qicli call ALMotion.setAngles HeadYaw 0.7 0.3 calls the function in the module with given parameters

    So one could write a wrapper to this binary and call it programmatically via SSH, it seems like a lot of work for this kind of task but I haven't found anything else.

    I've got Python's Paramiko library to work:

    import paramiko
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(hostname='ip-of-robot', username='nao', password='your-pass')
    
    stdin, stdout, stderr = client.exec_command('pwd')
    print(stdout.read())
    
    client.exec_command('qicli call ALMotion.setAngles HeadYaw -0.7 0.2')
    
    client.close()    
    

    I've also tried .NET's SSH.NET library, with little to no success.