# Automatic Optimal Robotic Base Placement for Collaborative Industrial Robotic Car Painting
## 3 Pre-Processing: Point Cloud Rendering and Ellipsoidal Fitting
This point cloud can be expressed as  
\[\mathcal{P}_{i}\left(\mathbf{p}^{i}\right)=\left\{\mathbf{t}^{i}\left( \boldsymbol{\theta}^{i}_{j},\mathbf{p}^{i}\right)\right\}_{j=1}^{N_{i}}. \tag{4}\]  
In Equation (4), \(\mathbf{t}^{i}\left(\boldsymbol{\theta}^{i}_{j},\mathbf{p}^{i}\right)\) is the position of the forearm tip under base position \(\mathbf{p}^{i}\) and joint configuration vector \(\boldsymbol{\theta}^{i}_{j}\) that can be computed using the forward kinematics mapping in (3). Each of the configuration vectors \(\boldsymbol{\theta}^{i}_{j}\), which is associated with the \(i\)th robot, is a sample drawn from the cube  
\[\left[\theta^{i}_{1,\min},\;\theta^{i}_{1,\max}\right]\times\left[\theta^{i}_{2,\min},\;\theta^{i}_{2,\max}\right]\times\left[\theta^{i}_{3,\min},\;\theta^{i }_{3,\max}\right]. \tag{5}\]Consequently, the number of samples \(N_{i}\) in the point cloud \(\mathcal{P}_{i}(\mathbf{p}^{i})\) is given by:  
\[N_{i}=\bigg{(}\left\lfloor\frac{\theta^{i}_{1,\max}-\theta^{i}_{1,\min}}{\delta_ {11}}\right\rfloor+1\bigg{)}\left(\left\lfloor\frac{\theta^{i}_{2,\max}-\theta^ {i}_{2,\min}}{\delta_{22}}\right\rfloor+1\right)\bigg{(}\left\lfloor\frac{ \theta^{i}_{3,\max}-\theta^{i}_{3,\min}}{\delta_{33}}\right\rfloor+1\bigg{)}. \tag{6}\]  
In Equation (6), \(\lfloor\cdot\rfloor\) denotes the floor function, and \(\delta_{ij}\) is a constant that specifies the distance between the samples in the \(j\)th angular interval. For example, if \(\delta_{11}=\frac{\pi}{10}\), the samples from the interval \(\left\lceil\theta^{i}_{1,\min},\,\theta^{i}_{1,\max}\right\rfloor\) are \(\frac{\pi}{10}\) radians apart. As seen in what follows, the number of points \(N_{i}\) in (6) in each forearm point cloud directly affects the computational complexity of the 3D ellipsoidal fitting algorithm. **Remark 3**. : _As it can be seen from Equation (4), the robot workspace point clouds depend on the base positions. However, the base coordinates are not known beforehand. To address this issue, we can express the relationship in (4) as follows:_  
\[\mathcal{P}_{i}\Big{(}\mathbf{p}^{i}\Big{)}=\mathcal{P}_{i}(\mathbf{0})+\Big{ }\{\mathbf{p}^{i}\},\ 1\leq i\leq M. \tag{7}\]  
_This expression indicates that the point cloud \(\mathcal{P}_{i}(\mathbf{p}^{i})\) can be obtained by translating each element of a point cloud based at the origin. In particular, each element in the set \(\mathcal{P}_{i}(\mathbf{p}^{i})\) is the sum of one element from \(\mathcal{P}_{i}(\mathbf{0})\) and the base position vector \(\mathbf{p}^{i}\). Accordingly, in the pre-processing stage of the algorithm, we can carry out the point cloud rendering of the reachable workspace of the robot forearms at the origin without the need to know the base positions. As seen in Sections 4 and 5, the base positions \(\mathbf{p}^{i}\), \(1\leq i\leq M\), can be considered as optimization decision variables._  
**Ellipsoidal fitting to the robot workspace point clouds:** Consider the point cloud \(\mathcal{P}_{i}(\mathbf{0})\) associated with the \(i\)th robot, which consists of \(N_{i}\) points in \(\mathbb{R}^{3}\). This point cloud \(\mathcal{P}_{i}(\mathbf{0})\) is computed using (4) by setting \(\mathbf{p}_{i}=\mathbf{0}\) (also, see Remark 3). To fit 3D ellipsoids to the point cloud \(\mathcal{P}_{i}(\mathbf{0})\), we used [PERSON]'s algorithm, a widely used method in convex optimization [40; 43]. [PERSON]'s algorithm is designed to compute the _minimum-volume enclosing ellipsoid (MVEE)_ of the point cloud \(\mathcal{P}_{i}(\mathbf{0})\), denoted by \(\mathrm{MVEE}(\mathcal{P}_{i}(\mathbf{0}))\), which is found by solving the following optimization problem:  
\[ \begin{split}\underset{\mathbf{A}_{i},\mathbf{c}_{i}}{\mathrm{ argmin}}\ \log(\det(\mathbf{A}_{i})),\\ \text{subject to}\ \ \ (\mathbf{t}_{k}-\mathbf{c}_{i})^{\top} \mathbf{A}_{i}(\mathbf{t}_{k}-\mathbf{c}_{i})\leq 1,\ \ \text{for all}\ \mathbf{t}_{k}\in\mathcal{P}_{i}(\mathbf{0})\end{split}