DOCUMENTATION

A Pyluos guide

The python library to manage a Luos systems

Installing Pyluos library


In a console, the following code will install the pyluos library using the pip packet manager:

Installing Jupyter Notebook


Jupyter Notebook can be used to program behaviors easily. We will use it to share our examples.

Once installed, it can be launched through a console:

In the browser page that opened, the New button creates a new Python file:

Note: In this picture jupyter use python 3 but you also can use python 2.7 depending on your computer configuration.

The Jupyter work-space looks like the following image. On the keyboard,  Maj+Enter executes any selected part of code.

Now you are ready to code using python.

Import Pyluos


The first thing to do is to call the pyluos library along with the Robot tool inside that library:

This line is always used while programming behaviors and should be called before any connection with the device is made.

Robot connection


Now you should be ready to use the Pyluos library and connect to your robot. To do that you have to create a robot object with your robot address as argument.

Your robot address could be an IP address (192.168.0.6 or my_robot.local for example) or a serial port (COM13 on windows or /dev/cu.usbserial-DN2YEFLN on mac …).

This line makes the connexion between the computer and the device. Python should answer with this kind of message:

Connected to "address to the device".
Sending detection signal.
Waiting for first state...
Robot setup.

Only once the connection is set it is possible to start programming behaviors.

List available modules of your robot


The following line of code refers to the listing of all the modules available in your robot.

For example if we have an RGB led and a button ou our system we should have:

[<Button alias="button_mod" id=2 state=OFF>,

<LED alias="rgb_led_mod" id=3 state=[0, 0, 0]>]

We can get the module type, the alias (name), the id and the state of each module.

Note: Communication modules are not shown in the module listing and you should never have to access it.

Get and set modules informations


Once you have detected your module you can use there information like variables.

To access values you have to address them in the robot object following this rules :

 

Get and set modules informations


Once you have detected your module you can use there information like variables.

To access values you have to address them in the robot object following this rules :

For example :

Don’t forget, if you use ipython or jupyther notebook you can use auto-completion using the Tab key to find every available objects.

Change a module name


The name of any module can be changed following this code. To list each module and its associated alias, refer to Listing the modules in a device section.

For example:

Note: Please restart your robot  and reconnect to it after this operation.

Note: To get back to the module default name set the “” name.