# Contingent Task and Motion Planning under Uncertainty for Human-Robot Interactions
## 3 A Proposal for Contingent Task and Motion Planning
### Geometric Constraint Predicates  
Basically, three general predicates, evaluated by geometric reasoning, are allocated that set constraints to the task states: _isCrit(\(\mathcal{O}^{m}_{j}\), \(\mathcal{O}^{\prime}\), Pos)_, _infeasByRob(\(\mathcal{R}\), \(\mathcal{O}^{\prime}\), Pos)_, and _assist(Human, \(\mathcal{O}^{\prime}\), Pos)_. The first predicate indicates that there is a blocking object \(\mathcal{O}^{m}_{j}\) which is located towards the target object \(\mathcal{O}^{\prime}\) placed in the pose _Pos_. The second one shows that the target object cannot be manipulated by the robot \(\mathcal{R}\) in the corresponding pose _Pos_. The last predicate shows the manipulation action with the target object \(\mathcal{O}^{\prime}\) and the corresponding _Pos_ must be done by a human operator _Human_.  
The proposed predicates are interleaved inside the pre- and post-conditions of the actions. Concerning the actions done by the robot, the predicates \(\sim\)_isCrit_ and \(\sim\)_infeasByRob_ are inserted within the preconditions of the actions _Transit_, _Open_, _Transfer_, and _Push_ in order to avoid moving the robot to any unreachable or infeasible configuration. Referring to the post-conditions, the last two actions may include the negation of the predicate _isCrit_ if they are moving a blocking object to a placement where the obstruction does no longer hold. With respect to the actions performed by a human, the preconditions of the actions _HumanTransfer_ and _HumanOpen_ may include the predicate _assist_ in order to indicate the requirement of a human operator.  
To illustrate the use of these predicates, the actions _Transit_ and _HumanOpen_ are described next. The action template _Transit_(\(\mathcal{R}\), \(\mathcal{O}_{i}^{m}\), _Surface_, _Pos_) is designed to move the robot \(\mathcal{R}\) (arm and base), without holding any object, towards a grasp configuration of a manipulatable object \(\mathcal{O}_{i}^{m}\) located on a surface _Surface_ at pose _Pos_. In the final configuration, the robot holds the target object. The action is applicable if the following preconditions hold: the object is located on a surface, top of the object is clear, the robot arm is empty, it can reach the grasp configuration if there is no movable objects blocking its way to \(\mathcal{O}_{i}^{m}\). The last precondition is represented by fact _isCrit_(\(\mathcal{O}_{j}^{m}\), \(\mathcal{O}_{i}^{m}\), _Pos_); objects that make this fact to hold are called _Critical Objects_ which are the objects blocking the way of reaching the object. As a result of the action, the robot holds an object.  
\(\textbf{Transit}(\mathcal{R}\), \(\mathcal{O}_{i}^{m}\), _Surface_, _Pos_):  
**Pre**: _onSurface_(\(\mathcal{O}_{i}^{m}\), _Surface_, _Pos_), _armEmpty_(\(\mathcal{R}\)), _clear_(\(\mathcal{O}_{i}^{m}\)), \(\sim\)_infeasByRob_(\(\mathcal{R}\), \(\mathcal{O}_{i}^{m}\), _Pos_), \(\forall\mathcal{O}_{j}^{m}\sim\)_isCrit_(\(\mathcal{O}_{j}^{m}\), \(\mathcal{O}_{i}^{m}\), _Pos_)  
**Effect**: _holding_(\(\mathcal{R}\), \(\mathcal{O}_{i}^{m}\), _Pos_), \(\sim\)_clear_(\(\mathcal{O}_{i}^{m}\)), \(\sim\)_armEmpty_(\(\mathcal{R}\)), \(\sim\)_onSurface_(\(\mathcal{O}_{i}^{m}\), _Surface_, _Pos_)  
The action template _HumanOpen_(_Human_, \(\mathcal{O}_{i}^{m}\), _Pos_, _Closed_, _Open_) is used to open a box-like container \(\mathcal{O}_{i}^{m}\) when it is closed. The action is applicable if the robot needs the assistance from a human operator, represented by the _assist_ predicate, and its status is closed, shown by the predicate _status_. These conditions are introduced in the action preconditions. As a result of the action, the corresponding container will be open.  
\(\textbf{HumanOpen}(\textbf{Human},\,\mathcal{O}_{i}^{m}\), _Pos_, _Closed_, _Open_):  
**Pre**: _assist_(_Human_, \(\mathcal{O}_{i}^{m}\), _Pos_), _status_(\(\mathcal{O}_{i}^{m}\), _Closed_)  
**Effect**: _status_(\(\mathcal{O}_{i}^{m}\), _Open_), \(\sim\)_status_(\(\mathcal{O}_{i}^{m}\), _Closed_)