## 3 User Interface Overall Description
### Behaviour Implementation  
The HRI incorporates a module to design cooperative scripts, including support to access the available components as well as to compile functionality (see Figure 13).  
The scripts can be executed in three ways: (1) linked to a sensor input, (2) as an HRI output to a robot controller, or (3) working in a closed-loop base as a parallel thread to the HRI process. As an example, Listings 2 and3 show some simple behaviours that have been implemented for the current experimentation. We can see that they are invoked by the HRI and are able to receive the packet that holds the sensor input (e.g., distance or camera) or the robot movement, so the script can enhance that input information to perform additional cooperative operations.  
```
defstartScript(packet,client): ifclient.Manager.IsBehaviourActive('ARMG500_02_FOLLOWS_ARMG500_01'): tcpClientARMG500_02=client.getTCPClientFromPort(G500_2_ARM_PORT) tcpClientARMG500_02.SendPacket(packet)
```  
Listing 1: Implementation of the behaviour to make the follower robot arm synchronised with the leader manipulator.  
```
defstartScript(packet,client): ifclient.Manager.IsBehaviourActive('ARMG500_02_FOLLOWS_ARMG500_01'): tcpClientARMG500_02=client.getTCPClientFromPort(G500_2_ARM_PORT) tcpClientARMG500_02.SendPacket(packet)
```  
Listing 2: Implementation of the behaviours that enable the follower mobile manipulator and the auxiliary robot to move according to the leader.  
```
defstartScript(packet,client):
#IFBEHAVIOUR(G500_2 FOLLOWSG500_1)ISACTIVE,SENDMOVEMENTTOG500_2 ifclient.Manager.IsBehaviourActive('G500_2_FOLLOWS_G500_1'): tcpClientG500_2=client.getTCPClientFromPort(G500_2_PORT) tcpClientG500_2.SendPacket(packet)
```  
Listing 3: Implementation of the behaviour to make the follower mobile manipulator and the auxiliary robot to move according to the leader.  
Figure 13: HRI script editor.  
```
defstartScript(packet,header,client): ifclient.Manager.IsBehaviourActive('G500_1.APPROACH_TARGET_2 METERS'):
#Thedistancetothesseafloorisreadfromthesonarsensor distanceToTarget=header.getDistanceToTarget()
#Accordingtothedistancesensorof500_1
#robotisappackendedtotheseafloor cpcClientets00_1 =client.getTPCClientFromPort(G500_1.PORT) tcpClientGet00_2=client.getTPCClientFromPort(g500_2.PORT) tcpClientAtUX=client.getTPCClientFromPort(AUX_PORT)
#Createpackettomovetherobotsvertically packet=client.createPacket() if(distanceToTarget>5.0):
#packet.TargetVelocity.z=-36.0 elif(distanceToTarget>1.1):
#packet.TargetVelocity.z=(distanceToTarget-1.0)/2.0*-36.0 else:
#packet.TargetVelocity.z=0.0 tcpClientGet00_1.SendPacket(packet) tcpClientGet500_2.SendPacket(packet) tcpClientUX.SendPacket(packet)
```  
Listing 3: Simplified example of a script that implements the behaviour to bring the robot team closer to the seabed.  
In summary, the cooperative module architecture and design enable the operator to prepare, activate, and tune very simple scripts that can help during an intervention. In fact, as the interventions are studied in advance, the scripts and corresponding behaviours can also be implemented before facing a real intervention. Also, in case of necessity, taking into account the simplicity of the procedure, a trained operator can tune the scripts using the Graphic User Interface (GUI) during an intervention in case of real necessity.