Hello! After a long struggle trying to figure it out myself, I finally decided to post the problem on the forum to gather some insights and advices. Apologize about the bit-lengthy post of mine.... I'm currently using a 4-DOF upper-limb model - 3-DOF on the shoulder and 1-DOF on the elbow. Each joint was mounted with a torque actuator. The upper-limb movement was generated with a first order impedance controller: tau = K(q0-q) + B(q0'-q'), where tau denotes input torque (4-dim vec), q0 denotes input reference trajectory (4-dim vec), q denotes the actual joint angle trajectory (4-dim vec), and K and B are constant 4-by-4 stiffness and damping matrices, respectively. I recognized some cases where the simulation halted due to an inf. qacc value. I found out the problem was from the 3-DOF shoulder joint in the model. I modeled the 3-DOF ball-socket mechanism of the shoulder joint as 3 sequential hinge joints, and the simulation became unstable when the joints are in kinematic singularities (in particular, when the 1st and 3rd joints roughly co-align). I later discovered in the MuJoCo forum that modeling a ball joint out of hinge joints is not a good idea [REF]. I believe using a ball joint with 3 orthogonal gear actuators may solve the problem [REF]. However, as a person who wants to use the first order impedance controller, I'm having a hard time incorporating the quaternion vector notation of qpos, and the gear actuators into the framework of impedance controller. Hence my question is.... [Q1] Assume that we stick with the shoulder joint modeled with 3 sequential hinges, rather than the long way of incorporating quaternions and gear actuators. Are there any recommended "tricks", which can circumvent the problem of kinematic singularities, that I can get away with? For instance, slight modification of the impedance controller to prevent reaching the singular configuration? Or imposing constraints of joint angle ranges? [Q2] In case approach [Q1] is bound for failure and is not a good idea to stick with, how can we incorporate the quaternion vector notation of qpos, and the gear actuators, into the framework of impedance controller? Hope I made the point clear. Any help will be thoroughly appreciated. I'm aware that these questions are sort of broad, but even pointing out some references/papers to read will be highly helpful. Thank you very much in advance, and looking forward to hearing back from anyone who can thankfully help me.