###### Abstract
[15] further develops an online NMPC approach using a kinematic model with vision-based feedback. NMPC can guarantee asymptotic stability and collision avoidance in most cases [16]. However, infeasible solutions might be obtained in some cases, especially within the stringent sampling time requirements encountered in HRC (typically a few milliseconds). This presents challenges for the real-time computation of NMPC, as there is the potential for collisions if an inaccurate solution is computed within the available time [17]. To overcome this limitation of NMPC, it is necessary to calculate the minimum distance between the end-effector and a human's interactive body component more accurately and to add a safety filter to constrain the robot's behavior within a safe area. To solve this problem, we use the Gilbert-Johnson-Keerth (GJK) algorithm [18] to solve the collision detection problem and add a control barrier function (CBF)-based constraint into the NMPC problem to guarantee the safety of the operator. In [19], a CBF-based approach is presented to constrain a redundant manipulator within a safe working area when interacting with a human operator. High-order CBF (HOCBF) and exponential CBF (ECBF) extensions are proposed in [20; 21] to solve higher-order relative degree problems. In this paper, we combine a vision system with NMPC-ECBF to solve the safe pHRI problem online. In summary, the existing research gaps are as follows. First, there is no established approach for designing a safe controller that uses the information from human motion prediction and action recognition. Second, collaboration under a tight sampling regime limits the accuracy of the NMPC solver, leading to errors that may present a risk to the human operators in the shared workspace. With estimates of the future target and obstacle position in the working environment, we propose a real-time motion planning algorithm for the physical human-robot interaction (PHRI) task based on NMPC-ECBF. In this work, to test the performance of the proposed controller, we set up several HRC scenarios with a seven-degrees-of-freedom (DOFs)manipulator (a Baxter robot) whereby motion capture, action recognition, motion prediction, and trajectory planning modules are integrated into a single system. The screwdriver usage scenario in the manufacturing assembly task includes subtasks such as picking up, moving forward, picking up a screw, operating, and moving backward. Each subtask is divided into a sequence of subtasks, with the robot end-effector required to reach a continuously updated predicted interactive position without collision when a subtask is triggered. However, as human motion and pose predictions are subject to approximation errors, the risk of collision still exists in HRC. Therefore, the output configuration of a manipulator is followed by a safety-critical controller implemented using an ECBF-based approach. There have been several works [22] that consider integrating motion prediction into HRC tasks, but no corresponding safe controllers have been proposed to guarantee the safety of human operators. In this work, we focus on the NMPC-ECBF system to enable safe and real-time human-robot collaboration (HRC). The controller integrates a safety filter to enforce ISO safety regulations, with experimental validation demonstrating its performance in dynamic environments. This paper proposes a novel NMPC-ECBF framework for ensuring safety in real-time human-robot collaboration (HRC) scenarios. The developed controller integrates a safety-critical filter to guarantee strict compliance with ISO safety standards. Experimental results demonstrate the system's effectiveness in maintaining robust performance within dynamic operational environments. Furthermore, the implemented vision system provides crucial human action recognition and trajectory prediction capabilities, thereby validating the practical feasibility of incorporating motion prediction techniques in HRC applications. The main contributions of the paper are as follows.