qulog/examples/ev3 contains support using the foreign function capabilities of Qu-Prolog and a very simple TeleoR program trev3.qlg that responds to being touched by backing away from the touch.
For embedded agents we need to define two system declared actions: poll_sensors and control_device.
In the program we have
The responsibility of poll_sensors is to get the list of all the current sensor values as percepts. In this case we return touched percepts by using the foreign function interface to get the touch sensor values.
The responsibility of control_device is to stop the old actions and to start the new actions.
To start the agent we use start_embedded_agent passing in the time between polls of the sensors as, for example
This means that the agent will poll the sensors (by calling poll_sensors) every 0.1 seconds