## 4 Local Robotic Corrections
Taking the projection to the surface's tangent plane;  
\[\overrightarrow{d}\overrightarrow{P}_{\text{Proj}}=\left(\left( \overrightarrow{P}_{t+1}-\overrightarrow{P}_{r}\right)\cdot \overrightarrow{dx}\right)\overrightarrow{dx}+\left(\left(\overrightarrow{ P}_{t+1}-\overrightarrow{P}_{r}\right)\cdot\overrightarrow{dy}\right)\overrightarrow{dy}, \tag{3}\]  
and scaling this to the desired velocity; \(\overrightarrow{p}=s\cdot\overrightarrow{dP}_{\text{Proj}}/|\overrightarrow{dP }_{\text{Proj}}|\). When the remaining in-plane distance from the target is small enough that the robot would over-shoot in a control-loop cycle, the speed is reduced to the estimated value. This satisfies Condition: 3. The projection is necessary since point cloud errors along the surface normal result in jerky motion, with the velocity vector set away from the target surface while the robot tries to maintain a constant force against the surface. Finally, the stop condition for the robot at each way-point is summarised by taking the current tool position \(\overrightarrow{P}_{r}\), velocity vector \(\overrightarrow{v}\), and way point \(\overrightarrow{P}_{t+1}\). The distance \(q\) of the robot from the way-point in the plane is;  
\[q=\left(\overrightarrow{P}_{t+1}-\overrightarrow{P}_{t}\right)\cdot \overrightarrow{v}\frac{1}{|\overrightarrow{v}|}. \tag{4}\]  
Once \(q\) has reached a threshold value, the robot is considered to have reached the desired way-point, satisfying Condition: 4. This method is only suitable for point cloud representation of surfaces that fulfil the following condition: (a) there is a curve along the surface \(\overrightarrow{\gamma}(t+\delta t)\) that intersects the current and next way-points \(\overrightarrow{P}_{t}\), \(\overrightarrow{P}_{t+1}\) such that \(\overrightarrow{\gamma}(\delta t)\sim\text{{Proj}}(\overrightarrow{P}_{t+1}- \overrightarrow{\gamma}(t))\), and (b) the global minima of the parameter \(q\) is attained at only one point along this curve. Point cloud representations of surfaces that do not follow this can only allow sub-optimal solutions to the path followed, or no solutions at all. This process does assume that each point within the point cloud represents the closest position on the surface. This increases the accuracy threshold for suitable RGB/D sensors when applied to surfaces of high-curvature. For a surface with maximum normal curvature \(\kappa\), the maximal inaccuracy can be \(\delta\) with \(\delta<1/\kappa\). The speed control for the robot is summarised in Algorithm 2. ```
Define acceptable stopping radius \(r\) and expected speed \(s\). for\(\overrightarrow{P}\in\text{Path}\)do \(\overrightarrow{P}_{TCP}=\text{GetCurrentPose(0)}\), \(t=|\overrightarrow{P}_{TCP}-\overrightarrow{P}|\), \(s_{C}=s\), while\(t>r\)do \(\overrightarrow{P}_{TCP}=\text{GetCurrentPose(0)}\), \(L=\text{GetLaserData(0)}\), if\(|L|=\)3 then  Extract surface orientation matrix: \(f(L,\overrightarrow{P}_{TCP})=R\), else  Assert the current TCP orientation is the surface's; \(R=R_{TCP}\) endif  Project vector difference to surface tangent: \(\delta\overrightarrow{P}=\text{Proj}\Big{(}\overrightarrow{P}- \overrightarrow{P}_{TCP}\Big{)}\),  Update distance value: \(t=|\delta\overrightarrow{P}|\),  Moderate speed with average loop-time so far; \(s_{C}=\min\big{(}t/\tilde{d}t,s\big{)}\). endwhile endfor
```  
**Algorithm 2**Speed control algorithm applied to reach each control point.