## 3 Methodology
### Particle Swarm Optimization (PSO)  
The Particle Swarm Optimization (PSO) algorithm was presented by [PERSON] and [PERSON] [28]. They originally intended to use existing social models and social relationships to create a type of computational intelligence that did not require individual special abilities. Their work led to the creation of a powerful optimization algorithm, called the Particle Swarm Optimization Algorithm (PSO). This method is adapted from the collective performance of groups of animals such as birds and fish. There are a number of creatures in the PSO, which we call particles, and they are scattered throughout the search space. Each particle calculates the value of the objective function at the position in the space in which it is located. The crowd chooses a direction to move. After performing the mass move, one step of the algorithm ends. These steps are repeated several times until the desired answer is obtained.  
The objective function for our method is  
\[min\;\;J(k)=\frac{1}{2}\int_{0}^{t}\left[(r-y)^{T}\;Q(r-y)+u^{T}Ru\right]\;dt \tag{1}\]  
\[u=r-kx \tag{2}\]  
\[Q\geq 0\text{ and }R>0\]  
In this study, we propose the formula as a performance index (\(J\)) that is designed to minimize ergonomics-related issues. The formula incorporates the REBA score evaluation system, which is widely used to evaluate the ergonomic risks associated with different postures and movements.  
In the formula, \(r\) represents the most optimal ergonomic posture for the human, as determined by the REBA score evaluation system, with a numerical value of \"1\". The output  
Figure 1: The ergonomics controller scheme. The human skeleton is tracked to calculate REBA scores. The robot’s end-effector position is optimized by the PSO algorithm and executed on the robot platform.  
of the REBA system for the human's current ergonomic posture is denoted as \(y\). The goal of the formula is to minimize the difference between the most optimal posture (\(r\)) and the current posture (\(y\)), as reducing this difference can potentially improve ergonomics and reduce the risk of musculoskeletal disorders.  
The input to the formula is denoted as \(u\), which is defined as \([r-kx]\), where \(x\) represents all possible states of the system, i.e., the locations of the robot's end-effector. The term \(kx\) represents the effect of the optimization algorithm, where \(k\) is a factor with three decimal places that ranges between \(-1\) and \(1\) and is set by the optimization algorithm. The purpose of this factor is to allow the system to adjust the robot's end-effector location (\(x\)) in order to decrease the difference between the best REBA score (\(r=1\)) and the worker's current ergonomics (\(y\)). By adjusting the end-effector location, the ergonomics of the user during handover can be changed, potentially improving the overall ergonomics of the task.  
To optimize the robot's end-effector motions, we utilized the Particle Swarm Optimization (PSO) algorithm, which is a popular optimization algorithm known for its speed and accuracy. The values of \(Q\) and \(R\) in the formula were determined through manual experimentation, considering criteria such as convergence speed and minimization of the REBA score. Since in this manual experimentation we investigated different values for \(Q\) and \(R\), other values lead to suboptimal output for the proposed method. It was observed that changing the values of \(Q\) or \(R\) resulted in the PSO algorithm converging to an end-effector position that was associated with a suboptimal REBA score, highlighting the importance of choosing appropriate values for these parameters [37]. The proposed formula has the potential to enhance human ergonomics during human-robot interaction tasks by minimizing the difference between the most optimal posture and the current posture of the worker. The problem is to minimize the above equation to avoid non-ergonomic postures that we applied ODE45 in MATLAB to solve this problem [38].