# Joint Iterative Satellite Pose Estimation and Particle Swarm Optimization
## 3 Materials and Methods
### Joint Iterative Pose Estimation and Particle Swarm Optimization (PE-PSO) Method  
Dynamic sample weighting strategy is one important concept that affects the deep learning model performance [29]. The PE-PSO method has taken the concept of dynamic sample weight and joint iteration as used in [26]. The PSO algorithm deploys as the method to estimate sample weight on the fly in every epoch of spacecraft pose estimation by using deep learning. Deep learning-based spacecraft pose estimation from photorealistic renderings in Section 2.1 is used as the pose estimation method (PE) and the objective function of the PSO algorithm, while it takes the benefit from the PSO algorithm by obtaining the updated simple weight in every epoch. This manner encourages an improvement of the final pose estimation model. The proposed method, PE-PSO, iterates between the PE and PSO processes. For the optimization problem, the slack variable (\(\xi\)) is added to an inequality constraint to transform it into an equality constraint. Assume that the batch size of the input training batch is \(i\), the modification of the slack variable (\(\xi\)), which is applied to the position of the particle (\(Position_{k}\)) in the PSO algorithm, is the following vector. \[Position_{k}=\left[\xi_{0}\ \xi_{1}\ \dots\ \xi_{i}\right] \tag{4}\]  
where subscription \(k\) is defined as the number of particles, whose maximum value is the number of batches in the deep learning-based PE scheme. It implies that particle \(k\) has \(Position_{k}\) and the \(Position_{k}\) has members to be a modification of the slack variable (\(\xi\)) equal to the number of the input training batch (\(i\)). The workflow and pseudocode of the PE-PSO method are presented in Figure 2 and Algorithm 1, respectively. In Figure 2, \(Position_{k}\) is updated via the PSO process, which is depicted by the red dotted line. The objective function for PSO is defined as a PE training function as explained in Section 2.1, which results in position error (\(Error_{position}\)), orientation error (\(Error_{orentation,k}\)), and total errors (\(Error_{total,k}\)). These errors are expressed as equations in the accuracy assessment section. The loss \(Loss_{k}\) implemented in PSO is the average of these three errors, and it is defined as the following equation. \[Loss_{k}=\frac{Error_{total,k}+Error_{position,k}+Error_{ orientation,k}}{3} \tag{5}\]  
Figure 1: The Unreal Rendered Spacecrafts On-Orbit Datasets (URSOs). (**a**) Example image (Image 1333_rgb.png) of the Soyuz_easy dataset. (**b**) Axis notation for a moving spacecraft frame [11]. In the experiment, the PE process is trained with an input consisting of a batch of four images (\(|\text{B}|=4\)) concatenated with the positions of the particles (\(Position_{k}\)). Thus, the input for each processing iteration during batch training is expressed as follows:  
\[input=[\text{batch\_images}\,\,Position_{k}]^{T} \tag{6}\]  
In every iteration of PE, PSO recalculates the values contained in \(Position_{k}\), which are part of the input. This concept is similar to the sample weight used in a general deep learning algorithm. However, it is not a predefined sample weight value that is determined  
Figure 2: The workflow of the PE-PSO method. before PE processing. \(Position_{k}\) is not related to the sample weight and is calculated on the fly based on the PSO concepts and processes in every epoch. Therefore, these values are changed to correspond to the minimum loss of the objective function at every time step. The velocity of a particle is computed via the following equation:  
\[ \begin{split} Velocity_{k,t}=\Big{(}&\ \omega* Velocity_{k,t-1}\Big{)}+\Big{(}c_{1}*r_{1}*\Big{(}pbest_{k,t}- Position_{k,t-1}\Big{)}\Big{)}\\ +&\Big{(}c_{2}*r_{2}*\Big{(}gbest_{k,t}-Position_{k,t -1}\Big{)}\Big{)}\end{split}  \tag{7}\]  
where \(c_{1}\) is the local learning coefficient, \(c_{2}\) is the global learning coefficient, and \(k,\ t\) indicate the particle of interest and epoch, respectively.