## Article
### Haptic Feedback Calculation  
This module generates the haptic feedback that will restrict the movement of the joystick axes and the movement of the impact hammer. For this purpose, a so-called _virtual collision region_ is generated around the end effector, which represents the space of the possible future positions of the end-effector, considering the direction in which it moves. The intersection of the virtual collision region with the collision point cloud will indicate possible collisions of the end-effector with the environment. For simplicity, in this work two different geometries are used for representing the virtual collision region: A rectangular cuboid and a semi-sphere, which are positioned at the end-effector point that is located on the tip of the chisel. Figure 10 shows these geometries, which are oriented with respect to the direction of movement of the end-effector. In this simulation, the yellow arrow corresponds to the direction of motion of the end-effector. As mentioned, the intersection of the virtual collision region with the collision point cloud will indicate how close is the effector to collide if the current direction and velocity of movement are maintained. The orientation of the virtual collision region has a direct relation to the direction of displacement of the end-effector, and the region it represents indicates the possible future positions in which the effector will find itself in future time steps. The length of the cuboid is selected as the maximum distance that the effector will move before stopping (inertia of the system). The height and width of the cuboid are slightly larger than the height and width of the end-effector. These values make it possible to distinguish when the end-effector is in an apparent collision state with the collision point clouds, and therefore perform subsequent actions on the effector to avoid the collision. However, it could happen that a sudden movement in the actuation of the controls would produce an abrupt change on the movement direction of the end-effector, resulting in a collision that cannot be detected by the cuboid. To avoid this situation, the semi-sphere region will act as a safety region, detecting these particular cases, where the effector is not in a collision direction, but very close to the objects. Figure 10: The yellow arrow shows the direction that the end-effector is moving. The yellow cuboid and green half-sphere are oriented according to the direction of motion of the effector. Thus, depending on the positions of the virtual collision region with respect to the collision point cloud, three different cases can be identified:  
1. Rectangular cuboid and semi-sphere regions without intersection with the collision point cloud (see Figure 11a). In this case the impact hammer can continue its trajectory;
2. Rectangular cuboid intersects the collision point cloud (see Figure 11b). In this case, the velocity will be reduced according to the distance to the obstacle (see explanation in next sub section);
3. Semi-sphere region intersects the collision point cloud and the cuboid does not (see Figure 11c). In this case the velocity will be reduced to 50% (see explanation in next sub section). The output of haptic feedback (_f_) has three values: A Boolean indicating if the cuboid intersects the collision point cloud or not, a Boolean value indicating if the semi-sphere intersects the collision point cloud or not, and a normalized value that indicates a level of safety of executing a command. The level of safety parameter (_S_) is calculated using the distance from the end-effector to the collision point cloud (\(Dist_{EP}\)), as the percentage of the cuboid region lying outside the intersection with the collision point cloud. To calculate this percentage, a max distance (\(Dist_{MAX}\)) is predefined. This distance is considered as a deceleration distance by the end effector when it moves with the maximal allowable speed and it stops. Thus, \(S\) is calculated as:  
\[S=min\bigg{\{}\frac{Dist_{EP}}{Dist_{MAX}},1\bigg{\}}. \tag{2}\]