# High-Level Smart Decision Making of a Robot Based on Ontology in a Search and Rescue Scenario
## 3 Methods
### Task Planning Algorithm Based on Ontology  
Figure 8 interprets the representation method of atomic actions defined as the smallest granular actions which can be directly executed by a robot. Atomic actions are made up of execution preconditions and action effects. The former will have an effect on the robot and the state of the environment, such as deleting or adding some states.  
Figure 8: The representation method of atomic actions.  
Figure 7: The structure of JESS.  
For a given high-level task, the program can adopt a specific search algorithm on the basis of the initial state of the robot and environment, which aims to match the preconditions and action effects of atomic actions and obtain the atomic action sequence of the specific task. When the robot performs a task for the first time, it will query and match the ontology layer by layer according to the current initial state and reason about the final atomic action sequence. The atomic action sequence contains the time sequence of action execution and is a complete representation of high-level input tasks. Then, the system will update the knowledge in the task ontology and write the complete representation of the high-level task into the definition of the task in the ontology. When the robot needs to perform the task next time, it can directly query the definition of the task to get the atomic action sequence corresponding to the task without querying and matching again. This improves the efficiency of task execution.  
We proposed an ontology-based task planning algorithm whose example reflecting algorithm idea is shown in Figure 9. The robot knows that [PERSON] is a victim and the current initial state. Besides, the robot can know the location, ability and state of robot tb1 by querying the ontology. Then, it is easy to see that the current initial state matches the preconditions of the search work. Thus, the robot first performs the subtask of _search [PERSON]_. According to the subtask of _search [PERSON]_, the robot matches the preconditions and states, and we can choose different search strategies to collect information about the victims. After obtaining [PERSON]'s information, it will update the current state by deleting the old state or adding a new one. Then, the robot performs the rescue task, as shown in Figure 8. The current state of the environment matches the precondition of the atomic action _Free Victim_, which means that the atomic action _Free Victim_ can be executed first. After the _Free Victim_ is executed, the environment state is updated. At this time, the environment state matches the atomic action _PickUp victim_, so the atomic action _PickUp victim_ can be executed. By parity of reasoning, we can get a sequence of atomic actions: _CenterSearch tb1 Jack_, _CrossSearch tb1 Jack_, _Free Jack_, _PickUp Jack_, _GetOut Jack_, and _PutDown Jack_. The atomic actions are shown with the blue block in Figure 9.  
The proposed algorithm 1 is shown as the pseudo-code below. Its input are the initial states, the task \(t\) reasoned by JESS, and the ontology knowledge \(O\). The output of the algorithm is the sequence of atomic actions, which is also the plan for accomplishing the \(t\) from the initial state.  
Figure 9: An example of task planning process.