## 1 Introduction  
Flexible-joint robots are widely used in industrial fields, with a broad application prospect such as aerospace, defense, and medical [1; 2; 3; 4; 5]. The articulated flexible robot mostly adopts the harmonic reducer as its transmission mechanism. The harmonic reducer not only has the advantages of small volume, high transmission precision, and high bearing capacity, but also brings joint flexibility into the robots. The introduction of joint flexibility increases the difficulty of control Permanent magnet synchronous motor (PMSM), which has been widely used in the servo system of flexible-joint robots due to their small torque ripple, large torque inertia ratio, and high efficiency. In the past, the dynamic model of servo motors as actuators is often neglected in the controller design of mechanical systems [6; 7]. The reason for this is that considering the actuator complicates the design of the controller. However, regardless of the dynamics model of the actuator, the performance of the closed-loop system may be degraded or even have instability [8]. Most scholars have studied how to better combine electrical dynamics with mechanical dynamics, on which basis the position tracking controller of the robot is designed. An adaptive fuzzy voltage control strategy for a DC-driven rigid-joint robot with uncertainty compensation is proposed in [9]. In [10], an observer-based robust control strategy for DC-driven flexible joint robots without speed sensors is proposed. An adaptive fuzzy control strategy for a PMSM-driven rigid-joint robot is proposed in [11], but this article did not make a specific analysis of the controller performance. A global proportion-integral-derivate (PID) control strategy for a PMSM-driven rigid-joint robot and a global stability proof method of PID control are proposed in [12]. Obviously, PMSM-driven flexible-joint robots have been rarely researched until now. This paper presents a hybrid controller for PMSM-driven flexible-joint robots. In order to make the control system take into account both good dynamic and steady state performance, some researchers have begun to propose to combine two control strategies with different points through smooth switching, to achieve a hybrid control strategy based on time switching [13; 14]. However, it is difficult to determine the switching time point, which is one of the disadvantages of such control strategies. In addition, it is difficult to ensure the control effect when facing unknown disturbances by using the hybrid control strategy with time function as the switching function. Therefore, in this paper, a Gaussian switching function based on velocity error is proposed to realize smooth switching of hybrid controllers. The hybrid controller mainly includes a sliding mode controller and port-controlled Hamiltonian (PCH) controller. Sliding mode control is widely used in flexible manipulators due to its excellent robustness and excellent dynamic performance [15; 16]. Therefore, an improved hierarchical sliding mode control strategy is designed to improve the dynamic performance of the system. The chattering cannot be eliminated due to sliding mode control. Hence, IDA-PBC control is designed for the system, with good steady-state performance. As we all know, IDA-PBC has a good control effect on systems whose dynamics are difficult to accurately model [17; 18; 19]. The state error PCH system of the flexible joint is constructed to achieve better tracking effect [20]. The added PID outer ring control can effectively reduce the influence of external disturbance on the system and improve the steady state performance of the system [21; 22]. On this basis, the electrical subsystem of the PMSM is written in the form of PCH, and the IDA-PBC control is designed for current loop control. This paper is organized as follows. In Section 2, the system dynamics model proposed in this paper is established.