# 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
If not, the parent node of _failedParent_ will continue to be translated and checked (line 11). If an _amf_! exists, the children nodes of the branch _amf_! will be added to the node _failedParent_ in the task tree (line 13). If _presubi_ exists, the first abstract operator \(\omega\)_vf_ whose feature with qualitative timestamps \"at_goal\" (refer to [2]) is satisfied under \(sub_{i}\) should be identified, and the children nodes of _failedParent_ in the task tree will be replaced by the nodes of the branch \(sub_{i}\theta\) after \(\omega\)_!_ (line 16). After that, the plan solution can be found according to SBOP. Figure 2 presents the basic principle. ```
replanning_pb(\(S\), failedAction)
1:\(|\) solution \(\leftarrow\) False
2:\(|\) failedTask \(\leftarrow\) Action2 Task (failedAction)
3:\(|\) failedParent \(\leftarrow\) failedTask.up
4:\(|\) while solution = Falsedo
5:\(|\)\(|\) am = abstract (_finalParent_)
6:\(|\) check \(\leftarrow\) whether there exist _presubi_ in _am_ applicable in a state \(S\)
7:\(|\) if check is false then
8:\(|\)\(|\) check \(\leftarrow\) whether there exist _amf_! in _AMF_ applicable in a state \(S\)
9:\(|\)\(|\) if check is false then
10:\(|\)\(|\)\(|\) iffailedParent is the root of _tasktree_ then return failure
11:\(|\)\(|\)\(|\) failedParent \(\leftarrow\) failedParent.up; return
12:\(|\)\(|\) else
13:\(|\)\(|\) tasktree.add_children(amf_! ); go to line17
14:\(|\)\(|\) else
15:\(|\)\(|\) find the abstract operator \(\omega\)_vf_ whose feature is satisfied under \(sub_{i}\)
16:\(|\)\(|\)\(|\) tasktree.delete_children(_failedParent_); tasktree.add_children(_sub_!_@ after \(\omega\)_!_@)
17:\(|\)\(|\) state(activenedo) \(\leftarrow\) 2; activenedo \(\leftarrow\) head(sub_i)
18:\(|\)\(|\) search the plan solution according to SBOP until to state(_ma_) =1
19:\(|\)\(|\) solution = True; return
20:\(|\) translate planttree to planttree (AC) and optimize the planttree (AC)
```

**Algorithm 3** Replanning Based on Partially Backtracking

## 3 Demonstration and Evaluation

The proposed approach is demonstrated in two different scenarios: \"deal with obstacles in serving a coffee to a guest\" for learning and planning based on activity schema with partially backtracking technique, and \"collect and deliver drink boxes to a counter\" for merging optimization of a plan. ### Demonstration 1: Simulation in Scenario \"Deal with Obstacles in Serving a Coffee to a Guest\"

#### 3.1.1 Learning Abstract Methods and Robot Activity Schema

To allow the user to provide instructions to the robot, we use a command-line interface that supports the following three types of commands: \"achieve\" is used to specify a task to be performed,

Figure 2: Basic principle of replanning based on partial backtracking. Red nodes are the failed actions. Red solid arrows represent the directions of a search; red dotted arrows are the function abstracts. \"abort\" is used to abort the requested task by the user, and \"teach_task\" is used to teach the robot a new task. Before performing or learning a new task, the operators and methods such as drive_robot, put_object, grasp_object and so on have been defined in JSHOP2 syntax. We employed three sub-scenarios on the PR2 platform in a simulated restaurant environment to teach the \"serve-a-coffee\" task [25; 26]. In the first sub-scenario, we teach the robot to serve a coffee to a guest from the right without any obstacle as shown in Figure 3a. In the second sub-scenario, an obstacle is present, which is a person in the manipulation area blocking the path to the south of Table 1; the robot was taught to wait for a while until the person leaves the region (as shown in Figure 3b). In the third sub-scenario, another type of obstacle, namely an extension table, blocks the manipulation area. The robot was taught to detour to the other side of Table 1 and place the coffee to the left of the guest (as shown in Figure 3c). The key components of \(ma\) are shown in Figure 6.

Figure 4: The activity schemas learned from the three sub-scenarios.