Skip to content

xopxe/lflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lflow

Data-flow language for reactive robotics.

Introduction

A lflow program is a collection of filter chains. Each chain is a collection of inputs, a collection of and outputs, and a filter in the middle. Each input or output is a data stream. Filters capture data from the inputs and send data on the outputs. Each output is labeled, and these labels are used to connect filter chains. You can also use constant values as inputs. Filters can generate output whenever they want, not just as a response to input data.

The language provides a set of standard filters (check for them in the lflow/filters/ folder). You can extend the language adding new filters. You can also write the Lua source code for the filter right in the filter chain specification.

To interface with actual hardware lflow uses Toribio.

File format

In a lflow file each filter chain goes on a line. A filter chain is

[inputs] > filter_spec > [outputs]

where inputs is a comma separated list of labels or constant values, and outputs is a comma separated list of labels.

You can add comments with #. There are several sample programs in the examples/ folder.

A trivial program is shown below (notice it has nothing robotic or reactive, it's just to show how a program looks):

1 > timer > tick
tick > print >

timer and print are filters. We pass the number 1 to the timer which will start emitting a number each 1 second. This number will be labeled tick. On the second line we provide this value to print that prints it (and does not generate any output).

If we want to print when 60 seconds have passed, we modify the program as follows:

1 > timer > tick
tick, 60 > equal > minute
'sec', tick > print >
'min', minute > print >

The output will be

sec	1
sec	2
sec	3
...
sec	58
sec	59
min	60
sec	60
sec	61
sec	62
...

Notice that each filter chain runs concurrently, so it is not wrong to show the "min 60" message before the "sec 60" message.

This program can be further improved into a proper clock (check the use of inlined functions):

1 > timer > tick
tick > function(s) if s%60==0 then return s/60 end end > minutes
tick > function(s) return s%60 end > seconds
'sec', seconds > print >
'min', minutes > print >

A sample reactive line follower robot (using the usb4butia controller) can be:

'gris:1', 0.1 > sensor_poll > sense_left
'gris:2', 0.1 > sensor_poll > sense_right

sense_left, '>', 200 > threshold > forward_left
sense_right, '>', 200 > threshold > forward_right

forward_left, forward_left > motores >

\# print on screen for debugging purposes
'readings:', sense_left, sense_left > print >
'actions:', forward_right, forward_right > print > 

License

Same as Lua, see COPYRIGHT.

Who?

Copyright (C) 2013 Jorge Visca, jvisca@fing.edu.uy

About

Data-flow language for reactive robotics.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages