# Learning and Planning Based on Merged Experience from Multiple Situations for a Service Robot
## 2 Learning and Planning Methods
### Planning Based on Activity Schema with Merging Optimization and Partially Backtracking Techniques
#### 2.4.1 Planning Based on Activity Schema with Merging Optimization
The abstract operator sequences of \(ma_{1}\), \(ma_{2}\) and \(ma_{3}\) are presented from left to right. Each abstract operator is represented by a rectangular box, in which “\(\alpha\)” is its abbreviation. The green part indicates a sequence in \(ma_{2}\) that differs from \(ma_{1}\). The orange part indicates a sequence in \(ma_{3}\) that differs from \(ma_{1}\). Figure 3: (**a**) Sub-scenario 1: learn how to serve coffee without any obstacle; (**b**) sub-scenario 2: learn how to deal with the obstacle, which is a person in this example; (**c**) sub-scenario 3: learn how to deal with the obstacle, which is an extension table in this example. Of note, \(ma_{1}\), \(ma_{2}\) and \(ma_{3}\) have been integrated into \(ma\) owing to the middle layer of the abstract method. The initial three-layer structure of \(ma\) is learned from the first sub-scenario, and its abstract method sequence is recorded as \(AM^{\prime}\) (line 8 in Listing 1). The sequence of abstract methods \(AM2\) extracted from sub-scenario 2 is noted as follows: [drive(part1, pmaec1), grasp(mug1, rarm1), drive(pmaec1, pmast1), wait_unblock(mast1), put(mug1, pawrtl)]. Clearly, \(AM^{\prime}\subset AM2\), so the complement of set \(AM^{\prime}\) in set \(AM2\), wait_unblock(mast1), is extracted as a free abstract method and generalized as wait_unblock- (?manArea) (lines 15-17 in Listing 1). Given that the sequence of abstract methods extracted from sub-scenario 3 did not contain the same sequence as \(AM^{\prime}\), it was created as a new branch of \(ma\) under the preconditions \(F(AM)\) (lines 10-12 in Listing 1), and preconditions of the other branch were adjusted (line 6 in Listing 1). #### 3.1.2 Planning Based on Activity Schema with Abstract Methods

To assess the performance of the planning algorithm based on activity schema with abstract methods, two types of obstacles, a table and a person, were both added to sub-scenario 4. The position of the table was the same as the scenario of learning, but the position of the person changed to the other

Figure 5: Structure of an activity schema with abstract methods \(ma\). Dotted arrows indicate preconditions, and solid arrows indicate the order of execution. The middle rectangles represent the abstract methods. For the meaning of other rectangles and colours, refer to Figure 4.

side of Table 1. The robot was not aware of the presence of obstacles at the beginning. The execution process of the plan generated by SBOP and SBP is presented in Figure 6.

Initially, a plan was generated following Algorithm 2. When the action with the highest percentage of verified features in _a17_ (move(pmast1, mast1)) was to be performed, the robot found that mant1 was occupied by a table, and the robot cannot complete the action. The failed execution of the action was published to the working memory, and when the planner received the fault information, replanning was activated to recover from the failure. _failedParent_, the parent nodes of the failed action in the task tree, was translated to the corresponding abstract method put(mug1, pawrt1) in the activity schema, and no such branch whose preconditions were applicable in state \(S\) was identified. Then, the parent node of _failedParent_ continued to be translated to the corresponding abstract method, [drive(part1,pmaec1), grasp(mug1,rarm1), drive(pmaec1,pmast1), put(mug1, pawrt1)] (as shown in List 1), and the robot checked that the preconditions or condition 1 in List 1 were not applicable in state \(S\). Then, the parent node, serve_a_coffee (guest1), continued to be checked, and preconditions of the second branch or condition 2 were applicable in state \(S\). The first abstract operator _a36_ (move(pmaec1, pmant1)), whose feature with qualitative timestamps \"at_goal\" was satisfied under the second branch, was identified. So far, the best recovery position for the plan has been identified.