tr_eg.qlg


This is a HTML rendering of tr_eg.qlg that is close to what you would see if using emacs with the .qlg mode or by using the supplied quled editor.
%% Copyright 2014 Keith Clark, Peter Robinson
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%%     http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.


%% A simple TR program to experiment with logging and the TR shell

def dir ::= left | right | centre 

percept see(num, dir), holding()

def robotic_action ::= 
        move(num) | turn(dir) | grab() | release()     

%% We interpret holding true and see(0, centre) not true to mean that
%% the grippers are closed but not actually holding an object

tel get_object()
get_object() {
    holding() & see(0, centre)       ~> ()
    not holding()  & see(0, centre)  ~> grab()
    not holding()                    ~> get_to()
    true                             ~> release() 
    }

tel get_to()
get_to() {
    see(0, centre)       ~> ()
    see(0, Dir)          ~> turn(Dir)
    see(_, centre)       ~> move(6)
    see(_, Dir)          ~> move(4) , turn(Dir)
    true                 ~> turn(left)
    }


%% For experimenting with this program using robot_shell
%% first start the robot shell in one terminal as follows
%% robot_shell.py robo
%% In another terminal run the teleor interpreter
%% teleor -Aagent
%% and in the interpreter
%% consult tr_eg.
%% go().
%% Now enter percepts in the robot shell 

act go() 
go() ~>
    start_agent(robo@localhost, all) ; 
    start_named_task(get_object(),collector)
               

%% For running the percepts updating version
%% robot_shell.py -w robo
%% In another terminal run the teleor interpreter
%% teleor -Aagent
%% and in the interpreter
%% consult tr_eg.
%% go_updates().
%% Now enter percepts in the robot shell  

act go_updates() 
go_updates() ~>
    start_agent(robo@localhost, updates) ; 
    start_named_task(get_object(), collector)