A Teleo-Reactive Architecture for Fast, Reactive

0 downloads 0 Views 262KB Size Report
implementation issues of the architecture when applying it to RoboCup ... mechanisms is their quick response to changes in the sensory input. The sec- ond group ... used to formulate the conditions. effect(ai ) returns the effect in terms of pred-.
A Teleo-Reactive Architecture for Fast, Reactive and Robust Control of Mobile Robots Gerhard Gubisch, Gerald Steinbauer, Martin Weiglhofer, and Franz Wotawa⋆ Institute for Software Technology, Graz University of Technology Inffeldgasse 16b/II, A-8010 Graz, Austria {gubisch,steinbauer,weiglhofer,wotawa}@ist.tugraz.at

Abstract. One of the elementary tasks of an autonomous mobile robot is the execution of different behavior patterns in order to fulfill a given task. The complexity of this problem is especially high if the robot operates in a dynamic, unpredictable environment and requires the parallel control of multiple actuators. In this paper we present a novel architecture for robust and fast mobile robot control. The architecture is based on Teleo-Reactive Programs. We discuss the benefits and drawbacks of such programs, extend the basic definition for the parallel control of multiple actuators, and propose a new language and a compiler for extended Teleo-Reactive Programs. These tools simplify the creation of new behavior patterns and increase the runtime performance. Finally, we discuss implementation issues of the architecture when applying it to RoboCup Middle-Size soccer robots. Key words: autonomous agents, control architecture, teleo-reactive programs, parallel actions, teleo-reactive program compilation

1

Introduction

The execution of different behavior patterns in order to achieve a given task is one of the fundamental prerequisites of an autonomous mobile robot. Once a robot has derived a plan to achieve its task, some mechanism is needed to execute the plan. Such a mechanism has to be flexible in order to allow the execution of different plans, sub-plans or behavior patterns. This requires an appropriate description or programming language. In addition, the mechanism has to be robust against failure. Even in situations which are new to the robot, the execution of behavior patterns should not fail. There is a great number of proposed mechanisms to organize, structure and describe the task execution of autonomous robots. On the highest level these mechanisms can be divided into three major groups: (1) the reactive paradigm, (2) the deliberative paradigm and (3) the hybrid paradigm. Mechanisms of the first group commonly use sets of simple reactive behavior and setup more complex behavior patterns by blending these simple ones. The advantage of these ⋆

Authors are listed in alphabetical order.

mechanisms is their quick response to changes in the sensory input. The second group uses planning and reasoning capabilities in order to derive sequential plans. Mechanisms of this group are able to handle very complex tasks but suffer from performance issues when deriving appropriate plans. The last group merges the advantages of the first two. It provides fast reaction on sensory input and the capability to plan in domains of greater complexity. In this paper we present a framework to organize and execute behavior patterns in a flexible and robust way using the hybrid paradigm. The organization of the reactive part is based on Teleo-Reactive (TR) Programs proposed by Nilsson [1]. TR-Programs are ordered lists of condition-action pairs, which ensure robustness in dynamic environments. Because basic TR-Programs are not able to deal with parallel actions, we introduce extended TR-Programs. Such TR-Programs serve as actions for a higher-level planning module. In order to improve the runtime performance and ease the use of extended TR-Programs we define a description language for the TR-Programs. Furthermore we show how a compiler can convert an extended TR-Program into native C++ code. This paper continues as follows: In the next section we discuss TR-Programs and introduce extended TR-Programs. In Section 3 we present the design of the proposed framework, our language for extended TR-Programs and a compiler for converting extended TR-Programs to C++. Section 4 discusses an implementation of the framework for our RoboCup Middle-Size soccer robots. Section 5 shows an overview of related research. Finally, we draw our conclusions in Section 6.

2

Teleo-Reactive Programs

Teleo-Reactive Programs are a formalism to control mobile robots in dynamic environments. They address the problem of plan execution in a real world environment. In such dynamic environments the effect of an executed action may be changed or canceled by exogenous events. Thus, the execution of a plan will fail if the control software of the robot relies on the successful execution of an action. Teleo-Reactive Programs provide a solution to this problem. According to [1] a Teleo-Reactive Sequence is an ordered set of production rules, where Ki denotes a first order logic condition and ai denotes an executable action: K1 → a1 , . . . , Ki → ai , . . . , Km → am . Formally a Teleo-Reactive Program can be defined as follows: Definition 1 (Teleo-Reactive Sequence) A Teleo-Reactive Sequence τ is a finite ordered list of m condition-action pairs (Ki , ai ) with i ∈ {1, . . . , m} and ai ∈ A where A = Adisc ∪ Adura ∪ T S is the union of the disjoint sets of discrete actions Adisc , durative actions Adura and all Teleo-Reactive Sequences T S: τ = h(K1 , a1 ) , . . . , (Ki , ai ) , . . . , (Km , am )i

Definition 2 (Teleo-Reactive Program) A Teleo-Reactive Program is a TeleoReactive Sequence with variables. When the sequence is called, the variables are bound to either constant values or to entities that are computed continuously. The execution of such a sequence is simple. The interpreter scans the production rules from left to right. It chooses an action for execution if the according condition is the first one which is satisfied. TR-Sequences can be organized hierarchically, i.e. the actions ai of a TR-Sequence can be Teleo-Reactive Sequences themselves. The primitive actions of a TR-Sequence can be either discrete or durative. A durative action ai is executed continuously as long as Ki remains the first true condition in the list. In contrast to that, a discrete action is called once, as soon as the first true condition in the list is the action’s condition. Assume, that S holds the initial truth values of the predicates which are used to formulate the conditions. effect(ai ) returns the effect in terms of predicate truth values when executing action ai . A ⊕ B = B ∪ {l|l ∈ A ∧ ¬l ∈ / B} represents a state update operator and Φ(Ki , S) = (∀j t. For example action a2 runs simultaneously with action a1 between t1 and t2 in Figure 1. One practical example of such a setting is a robot equipped with a gripper operating

Fig. 1. Example of the simultaneous action problem.

in a ware-house environment. The task of the robot is to pick up packages from a moving conveyor belt. While the robot waits for the package it pre-positions its gripper (action a1 ). If the package appears on the conveyor belt the robot starts moving parallel to the package (action a2 ) and simultaneously grabbing the object of interest. When the packages has been taken, the gripper can be frozen (time t2 ) while the robot drives towards it final position (action a2 ). Another problematic setting is, if action aj should be started at time t1 and stopped at t2 while action ai is active all the time (e.g. a3 and a4 in Figure 1). That is, for example if a soccer robot should dribble (action a3 ) and kick (action a4 ). If the robot stops dribbling in order to prepare kicking, the ball will roll away from the robot. Thus, the robot has to kick while it concurrently dribbles. 2.1

Extended Teleo-Reactive Programs

To address the problem of simultaneous action execution we extend the basic definition of a TR-Programs. Therefore, we introduce an additional operator that can be used within the action parts of a TR-Sequence. Definition 3 (Parallel Composition Operator) Given two actions ai and aj with i 6= j, then the composition with the ||-operator ai ||aj is again a valid action denoting the parallel execution of the two actions. The parallel execution of actions ai and aj still has to satisfy the regression property. In the following we will write Ai to denote either a single action ai or a parallel composition of n actions ai1 ||ai2 || . . . ||ain . We use lower case letters ai for single actions. A denotes the set of all actions. Definition 4 (Extended Teleo-Reactive Sequence) An extended Teleo-Reactive Sequence τe is a finite ordered list of m condition-action pairs (Ki , Ai ) where Ai = ai ∧ ai ∈ A or Ai = ai1 || . . . ||ain with ∀j=1...n aij ∈ A. The semantics of an extended Teleo-Reactive Sequence is given by J Ke . Definition 5 An extended Teleo-Reactive Program is an extended Teleo-Reactive Sequence with variables. When the sequence is called, the variables are bound to either constant values or to entities that are computed continuously.

The use of the ||-operator extends the semantics J K for a Teleo-Reactive Sequence τe to the semantics J Ke as follows: Jτe Ke (S) = Jh(K1 , A1 ) , . . . , (Km , Am )iKe (J(Ki , Ai )Ke (S)) if Φ(Ki , S) [ J(Ki , ai )K(S) J(Ki , Ai )Ke (S) = ai ∈Ai

Note, that any basic Teleo-Reactive Program can be interpreted by J Ke . Thus, the set of all basic Teleo-Reactive Programs T RP is a subset of all extended Teleo-Reactive Programs T RP ext , i.e., T RP ⊂ T RP ext . An extended Teleo-Reactive Program encoding the action sequence of Figure 1 looks like following: Ke → a3 , Kd → a3 ||a4 , Kc → a3 , Kb → a2 , Ka → a1 ||a2 , true → a1 Extended TR-Programs are appropriate for the description of the behavior of a robot for a wide range of tasks. But there are two issues that have to be solved when applying TR-Programs for mobile robot control. First, for complex high level tasks some deliberative component is needed in order to enable the robot to fulfil the task. TR-Programs are valuable for the execution of the behavior but the gap to the deliberative component has to be filled. Second, the execution of Teleo-Reactive Programs must be fast such that reactions to changes in the environment are taken into account immediately. We will now introduce a framework for mobile robot control, which addresses these two issues.

3

Organization and Specification of Behaviors

Fig. 2. Schematic overview of the proposed framework.

Figure 2 shows an overview of our architecture for robust control of mobile robots. The central elements within this architecture are extended Teleo-Reactive Programs that are translated to native C++ code. During the runtime a high

level planning module selects the currently best Teleo-Reactive Program for a given situation from a list of predefined TR-Programs. Thus, the Teleo-Reactive Programs are actions for a high level planning module. The Teleo-Reactive compiler uses predicates, actions and algorithms, and translates a given extended Teleo-Reactive Program into C++. This code is compiled by a standard C++-Compiler into executable object code and linked into the robot control software. The translation of extended TR-Programs from a native language to object code has two major advantages. First, it simplifies the process of writing a extended Teleo-Reactive Program where the programmer does not have to care about complex features of modern programming languages. Second, we have experienced a significant improvement in the run-time performance when executing compiled Teleo-Reactive Programs instead of interpreting Teleo-Reactive Programs. The reasoning within the TR-Program happens over values from the configuration, over data from the world model and over parameters retrieved from the planning module. Every durative action is implemented in a separate flow of control, i.e., a separate thread. The action-interfaces used by the TR compiler communicate with that thread by sending start commands and stop commands with parameters. Beside the advantage of having several actions executed simultaneously, this separation of actions has an additional benefit: Because there is only one instance of every action, the action can remember previous parameter values and can benefit from the history of parameters. 3.1

Teleo-Reactive Program/C++ Transformation

Algorithm 3 translates any non-hierarchical extended Teleo-Reactive Program into a C++ program. An example is illustrated in Figure 4. As Figure 4 shows, function S transform(h(K1 , A1 ) , . . . , (Km , Am )i) A := i=1,...,m Ai ; writeln "void main() { while(true) evaluate(); }" writeln "void evaluate() {" for i = 1 to m do writeln "if (Ki ) {" for all aj ∈ A \ Ai do writeln "aj .stop();" done for all ak ∈ Ai do writeln "ak .start();" done writeln "return; }" done writeln "}" Fig. 3. Algorithm for the translation of extended Teleo-Reactive Programs into C++.

the resulting C++ code consists of two functions. The main loop calls the evaluate function continuously. The evaluate function contains a list of if-then statements. Each condition-action pair corresponds to one if-then-statement.

The condition of a (Ki , Ai )-tuple forms the condition in the if-clause. The thenbranch is built by starting and stopping the actions of Ai (functions start() and stop()). These functions start and stop durative actions in a separate thread. Note, that the functions are called multiple times, where the parameters to those functions may be changed. Thus, start functions should start the thread only if it is not running yet. If the thread is already running, the functions should only exchange the old parameters with the new ones. For discrete actions, the start function runs the action once and refuses execution if called multiple times until the stop function has been invoked. The resulting C++ program does not interrupt durative actions and start them immediately again, which would break a continuous execution. Thus the C++ program starts an action ai for a conditionaction pair (Ki , Ai ) if ai ∈ Ai . An action aj is stopped in the then-branch of a condition-action pair (Kk , Ak ) iff aj 6∈ Ak .From the semantical point of view, Scored → nil, InRange(Goal) → DribbleTo(Goal) || Kick(), true → DribbleTo(Goal) void main() { while(true) evaluate(); } void evaluate() { if(Scored.eval()){DribbleTo.stop();Kick.stop();return;} if(InRange.eval(Goal)){DribbleTo.start(Goal);Kick.start();return;} if(true){DribbleTo.start(Goal);Kick.stop();return;} }

Fig. 4. Translation of an extended Teleo-Reactive Program for a scoring behavior (top) into C++ code (bottom).

the two versions of TR-Programs in Figure 4 are equivalent. Both versions of the TR-Program will execute Ai if (∀j