Skip to main content

Part 2: take the control

1. Introduction​

This is the remote control part of this tutorial, for you to control the Matrix πŸ’Š: The service gate running on your board allows you to take control through a computer of any service loaded on your device.

2. Set up your development environment​

We will use Python to control your board running Luos engine with a library called pyluos.

In order to install it, run the following command in the terminal:

pip install pyluos
caution

As you need to use a pip command in your terminal, make sure to have a working pip environment.

warning

Depending on your version of Python, you may need to use the command pip3 instead of pip.

caution

If you already have Pyluos installed on your computer, please make sure it is up to date by using this prompt in your terminal: pip install pyluos --upgrade

3. Connecting and controlling your device​

Pyluos provides a set of application programming interfaces (APIs). To control your device, connect the same board you flashed in Part 1 and run the following command in the terminal:

pyluos-shell

This command will find the serial port of your device and mount it into a β€œdevice” object.

For example:

**$ pyluos-shell**
Searching for a gate available
Testing /dev/cu.usbserial-D308N885
Testing /dev/cu.usbmodem13102
Connected to "/dev/cu.usbmodem13102".
Sending detection signal.
Waiting for routing table...
Device setup.

Hit Ctrl-D to exit this interpreter.

Your luos device have been successfully mounted into a "device" object:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ β•­node 1 /!\ Not certified ┃
┃ β”‚ Type Alias ID ┃
┃ β”œ> State led 2 ┃
┃ β”œ> Pipe Pipe 3 ┃
┃ β”œ> Gate gate 1 ┃
┃ β•°> Unknown blinker 4 ┃
β•”>┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
caution

In some cases, you may encounter an error message at this point. Most of the time, this is related to IPython. Installation or performing a new installation solves the problem. Type the command pip install ipython in the terminal.

The device object is an object representation of your actual device displayed by pyluos-shell.

Now that you have opened an IPython session, you are able to execute Python commands line by line. By doing so, you can interact with your actual device directly into the pyluos-shell interface.

In the device object, there are multiple services. Each of those services will have special capabilities depending on their type.

For example, try to execute these lines one by one:

  1. Set up the blinking timing to 250ms (you should see the LED blink faster):
device.blinker.time=0.25
  1. Pause the blinking of the LED:
device.blinker.pause()
  1. Turn on the LED:
device.led.state=True
  1. Turn off the LED:
device.led.state=False
  1. Restart the blinking of the LED:
device.blinker.play()
info

You can always check the list of the commands available for all services using your tab key:

luos_img

See Pyluos documentation for more information.

Test your skills​

Next steps​

With your development environment installed in Part 1, you have now taken the control of a Luos app running on your MCU, with Python. The next part of this section deals with creating your first Luos network.

The author: Nicolas Rabault

CEO at Luos
Nicolas Rabault

Former roboticist, research engineer in real-time embedded systems and founder of Pollen Robotics, Nicolas Rabault is CEO of Luos. Nicolas dedicated his life to develop tools making embedded subsets work together and simplifying reusability.

Related content


    Get started Repository