Aldebaran documentation What's new in NAOqi 2.4.3?

qi.Application API


Application initializes the qi framework, it extract –qi-* commandline arguments and initialise various options accordingly. It also provides facilities to connect the main session. This ease the creation of console applications that connects to a session or want to be standalone.

You can pass the following arguments to your application to control the session:

  • –qi-url : address of the session to connect to
  • –qi-listen-url : address on which the session will listen
  • –qi-standalone : make a standalone session (use –qi-listen-url to set the listen url)

By default the session url is set to “tcp://” and the listen url to “tcp://”.

If raw is specified there wont be a session embedded into the application and you are free to create and connect a session yourself if needed.

if autoExit is set to True, a session disconnection will quit the program. Set autoExit to False to inhibit this behavior. By default autoExit is True.

Application will parse your arguments and catch –qi-* arguments.

For a normal application you have to call start to let the Session embedded into the application connect. If you want to handle –help yourself you can do that before the application starts avoiding a useless connection to the session.


class qi.Application
__init__(args=None, autoExit=True, url=None, raw=False)
  • args – the list of arguments (if None sys.argv is used)
  • autoExit – By default the Application quit on session disconnection, set to False to avoid this behavior (default to True)
  • url – The default value to use for qi-url (default to tcp://
  • raw – If set to True this does not include a Session into the Application. (advanced user only)

initialise the Application


start the Application. Once start is called, your Application is fully working. The session is connected and available.


stop the Application. (unblock an application previously launched with run)


block until stop is called. This calls start if it was not already called.


return the current session.


Url given to the session to connect to.


class qi.ApplicationSession

Deprecated since version 2.0.1.

Use qi.Application instead.


Simple example that lists all ALMemory keys:

import qi
import sys
from pprint import pprint

if __name__ == "__main__":
    app = qi.Application(sys.argv)

    # start the eventloop

    almemory = app.session.service("ALMemory")


    #no needed because we want to exit once getDataListName returns

If you put the content of this script in a file, then you can:

#connect to tcp://
$ python

#connect to tcp://
$ python --qi-url=tcp://

Simple example that exports a service:

import qi
import sys

class Foo:

    def bar(self):

if __name__ == "__main__":
    app = qi.Application(sys.argv)

    # start the session

    app.session.registerService("foo", Foo())   # will exit when the connection is over

If you put the content of this script in a file, then you can:

#connect to tcp://
$ python

#connect to tcp://
$ python --qi-url=tcp://

#run a standalone session
$ python --qi-standalone

#run a standalone session on tcp://
$ python --qi-standalone --qi-listen-url="tcp://"

#let's use qicli to introspect the service
$ qicli info foo --qi-url=tcp://