A mechanical arm gravity compensation method and system based on virtual work principle and step-by-step calibration

CN122606614APending Publication Date: 2026-08-21BEIJING INST OF CONTROL ENG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610890178.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-18
Publication Date
2026-08-21

AI Technical Summary

Technical Problem

[0004]本发明解决的技术问题是:针对目前现有技术中,存在的现有主动重力补偿技术对机械臂物理参数如质量、质心的依赖性、标定困难的不足,提出了一种基于虚功原理与分步标定的机械臂重力补偿方法及系统

Benefits of technology

本发明提供的一种基于虚功原理与分步标定的机械臂重力补偿方法及系统,基于虚功原理与分步标定提出了机械臂重力补偿方法,能够通过电流反馈直接辨识集总参数,实现高精度的全构型重力平衡,利用虚位移原理推导与分步标定法,将复杂的动力学参数辨识简化为电流-角度拟合,降低了工程实现难度;且无需额外六维力传感器,仅依靠电机自带反馈即可低成本完成标定与控制;同时该方法具备全构型适应性,实现了机械臂在任意工作位置的重力平衡,有效提升了力觉交互的透明度并降低了操作疲劳。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122606614A_ABST
    Figure CN122606614A_ABST
Patent Text Reader

Abstract

A mechanical arm gravity compensation method and system based on virtual work principle and step-by-step calibration, which directly identifies lumped parameters through current feedback for balanced gravity control, specifically by establishing a gravity torque theoretical model based on virtual displacement principle; constructing a joint coulomb friction model and measuring dynamic friction parameters; using a step-by-step decoupling strategy of locking from the end to the base to calibrate the lumped gravity parameters; and in the real-time system, combining friction compensation to generate current command to control motor movement to realize mechanical arm gravity balance compensation control.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method and system for gravity compensation of a robotic arm based on the principle of virtual work and step-by-step calibration, belonging to the field of robot control technology. Background Technology

[0002] In force-sensing interaction, precision assembly, and collaborative robot applications, gravity compensation for robotic arms is a key technology for achieving compliant control and reducing motor load. Existing gravity compensation methods are mainly divided into mechanical and electronic types. While mechanical compensation (such as counterweights and springs) is energy-efficient, it increases system inertia and structural complexity, and is difficult to adapt to changes in end-effector load. Electronic compensation balances gravity by using motor output torque, offering greater flexibility.

[0003] However, existing active gravity compensation algorithms (such as those based on the Newton-Euler equations or Lagrange equations) typically rely on precise dynamic model parameters, including the mass, center of mass position, and inertia tensor of each link. In practical engineering, accurately measuring these physical parameters is extremely difficult, and assembly errors can lead to model mismatch, thus affecting compensation accuracy. Therefore, there is an urgent need for a gravity compensation method that does not rely on precise physical model parameters, is easy to implement in engineering, and offers high accuracy. Summary of the Invention

[0004] The technical problem solved by this invention is: addressing the shortcomings of existing active gravity compensation technologies, such as dependence on the physical parameters of the robotic arm, such as mass and center of mass, and the difficulty in calibration, and proposing a robotic arm gravity compensation method and system based on the principle of virtual work and step-by-step calibration.

[0005] The present invention solves the above-mentioned technical problem through the following technical solution: A method for gravity compensation of a robotic arm based on the principle of virtual work and step-by-step calibration includes: A theoretical model of gravitational torque is established, taking the robotic arm as a multi-rigid-body target with ideal constraints. The frictional characteristics of the joint transmission chain of the robotic arm are represented by the Coulomb friction model. The dynamic friction torque parameters of each joint motor are measured experimentally and used as feedforward compensation terms to construct the joint friction model. In the joint friction model, each joint is calibrated step by step from the end of the robotic arm to the base. The average current of the motor of each joint is recorded during the calibration process as the dynamic friction balance current, which is used to fit and obtain the lumped gravity parameters and motor torque coefficient of each joint. Measure the joint angle configuration of each joint of the current robotic arm and substitute it into the gravitational torque theoretical model to calculate the theoretical gravitational torque; The total compensation current value is calculated based on the motor torque coefficient, dynamic friction balance current, and theoretical gravitational torque, and the total compensation current command is generated and input into the robotic arm to control the gravity balance of the robotic arm.

[0006] The method for establishing the theoretical model of gravitational torque is as follows: Based on the principle of virtual displacement, assuming the robotic arm is a multi-rigid-body target with ideal constraints, an equilibrium equation is established in which the sum of the active torque applied to each joint of the robotic arm and the work done by the gravitational potential energy in any virtual displacement is zero. The vector product expression of the gravity compensation torque of each joint of the robotic arm is derived and used to construct the theoretical model of gravity torque.

[0007] During the calibration process of each joint from the end of the robotic arm to the base, one side of the joint to be calibrated is kept still. The joint to be calibrated is controlled to move at preset angle intervals and remain still between each movement. The average value of the motor current under static conditions is recorded. The lumped gravity parameters and torque coefficients of each joint are obtained through data fitting.

[0008] The method for obtaining the lumped gravity parameters of each joint through data fitting is as follows: based on the established gravity torque theoretical model, the gravity torque of the joint to be calibrated is related to the joint angle by a sine function; the average value of the motor current recorded under the condition of moving at the preset angle interval and remaining stationary is fitted with a sine function, and the amplitude of the fitted sine curve is identified, which is used to calculate the lumped gravity parameters of the current joint to be calibrated.

[0009] The vector product expression for the gravity compensation torque of each joint is:

[0010] In the formula, For gravity, The main driving torque is represented by the vector cross product of the torques at each joint. For the k-th joint, the gravity compensation torque is... Represented as:

[0011] In the formula, Let be the antisymmetric matrix of the arm's radius vector. For load or link mass, This represents the component of gravitational acceleration in the body coordinate system.

[0012] The method for calibrating each joint in the joint friction model, proceeding step-by-step from the end of the robotic arm to the base, is as follows: The end joint of the robotic arm is set as the fourth joint. The other three joints are kept locked and stationary. The fourth joint is controlled to rotate at fixed intervals starting from 0 degrees. The holding current at different angles is measured, and the lumped gravity parameters of the fourth joint are obtained by fitting. Using the third joint as the secondary end joint, while keeping the other first, second, and fourth joints locked and stationary, control the rotation of the third joint, and calculate the lumped gravity parameters of the third joint based on the lumped gravity parameters of the fourth joint. The lumped gravity parameters of the first and second joints are calculated sequentially to obtain the lumped gravity parameters of each joint, and the motor torque coefficient of each joint is calculated using the lumped gravity parameters.

[0013] The method for calculating the total compensation current value is as follows:

[0014] In the formula, This is the total compensation current command. For the theoretical gravitational torque, This is the motor torque coefficient. This is the current for kinetic friction balance.

[0015] A robotic arm gravity compensation system for implementing a robotic arm gravity compensation method includes a multi-degree-of-freedom robotic arm body, a servo drive unit, a control unit, and a host computer, wherein: The multi-degree-of-freedom robotic arm body is composed of mechanical joints. Each mechanical joint is driven by a joint motor. The joint motor is a high torque density servo motor. An absolute encoder is integrated at the joint. The multi-degree-of-freedom robotic arm body receives control commands sent by the control unit to perform actions and gravity balance. The servo drive unit collects the position information of the absolute encoders of each joint of the multi-degree-of-freedom robotic arm to obtain the joint angle configuration. At the same time, during the calibration process, it measures the average current of each joint motor as the dynamic friction balance current and sends all recorded parameters to the control unit for data calculation. The control unit constructs a theoretical model of gravity torque and a joint friction model. In the joint friction model, each joint is calibrated step by step from the end of the robotic arm to the base. It receives the recorded parameters sent by the servo drive unit and fits them to obtain the torque coefficients of each joint and the motor. At the same time, it substitutes the joint angle configurations of each joint sent by the servo drive unit into the theoretical model of gravity torque to calculate the theoretical gravity torque. Based on the motor torque coefficient, dynamic friction balance current, and theoretical gravity torque, it calculates the total compensation current value and generates a total compensation current command, which is sent to the multi-degree-of-freedom robotic arm body through the servo drive unit. The host computer issues operation commands to the control unit and displays them visually.

[0016] The servo drive unit adopts a high-performance servo driver with torque control mode, and the absolute encoder is an embedded absolute encoder.

[0017] The robotic arm gravity compensation system reads the angles of each joint in real time via a high-speed fieldbus through periodic communication, and sends the total compensation current command calculated by the control unit to the system. The main body of a robotic arm with up to multiple degrees of freedom.

[0018] The advantages of this invention compared to the prior art are: This invention provides a method and system for compensating the gravity of a robotic arm based on the principle of virtual work and step-by-step calibration. The method proposes a gravity compensation approach for the robotic arm based on the principle of virtual work and step-by-step calibration. It can directly identify lumped parameters through current feedback, achieving high-precision gravity balance across all configurations. By utilizing the principle of virtual displacement and a step-by-step calibration method, the complex identification of dynamic parameters is simplified to current-angle fitting, reducing the difficulty of engineering implementation. Furthermore, it eliminates the need for an additional six-dimensional force sensor, relying solely on the feedback from the motor to complete calibration and control at low cost. Simultaneously, this method possesses full configuration adaptability, achieving gravity balance of the robotic arm in any working position, effectively improving the transparency of force interaction and reducing operator fatigue. Attached Figure Description

[0019] Figure 1 The flowchart of the mechanical arm gravity compensation method provided by the present invention is shown below. Figure 2 The coordinate system and structural analysis diagram based on the principle of virtual displacement provided for this invention; Figure 3 A schematic diagram of the joint static friction torque model used in this invention; Figure 4 The curve showing the fitting of the average current of joint 4 with the rotation angle during the step-by-step calibration process provided by the present invention. Detailed Implementation

[0020] A method and system for gravity compensation of a robotic arm based on the principle of virtual work and step-by-step calibration is disclosed. The method directly identifies lumped parameters for balanced gravity control through current feedback. Specifically, it establishes a theoretical model of gravity torque based on the principle of virtual displacement; constructs a Coulomb friction model of the joints and measures the dynamic friction parameters; calibrates the lumped gravity parameters using a step-by-step decoupling strategy that locks from the end effector to the base; and combines friction compensation to generate current commands to control the motor movement in the real-time system to achieve gravity balance compensation control of the robotic arm.

[0021] The specific process of the robotic arm gravity compensation method based on the principle of virtual work and step-by-step calibration is as follows: A theoretical model of gravitational torque is established, taking the robotic arm as a multi-rigid-body target with ideal constraints. The frictional characteristics of the joint transmission chain of the robotic arm are represented by the Coulomb friction model. The dynamic friction torque parameters of each joint motor are measured experimentally and used as feedforward compensation terms to construct the joint friction model. In the joint friction model, each joint is calibrated step by step from the end of the robotic arm to the base. The average current of the motor of each joint is recorded during the calibration process as the dynamic friction balance current, which is used to fit and obtain the lumped gravity parameters and motor torque coefficient of each joint. Measure the joint angle configuration of each joint of the current robotic arm and substitute it into the gravitational torque theoretical model to calculate the theoretical gravitational torque; The total compensation current value is calculated based on the motor torque coefficient, dynamic friction balance current, and theoretical gravitational torque, and the total compensation current command is generated and input into the robotic arm to control the gravity balance of the robotic arm.

[0022] The method for establishing the theoretical model of gravitational torque is as follows: Based on the principle of virtual displacement, assuming the robotic arm is a multi-rigid-body target with ideal constraints, an equilibrium equation is established in which the sum of the active torque applied to each joint of the robotic arm and the work done by the gravitational potential energy in any virtual displacement is zero. The vector product expression of the gravity compensation torque of each joint of the robotic arm is derived and used to construct the theoretical model of gravity torque.

[0023] During the calibration process of each joint from the end of the robotic arm to the base, one side of the joint to be calibrated is kept still. The joint to be calibrated is controlled to move at preset angle intervals and remain still between each movement. The average value of the motor current under static conditions is recorded. The lumped gravity parameters and torque coefficients of each joint are obtained through data fitting.

[0024] The vector product expression for the gravity compensation torque of each joint is:

[0025] In the formula, For gravity, The main driving torque is represented by the vector cross product of the torques at each joint. For the k-th joint, the gravity compensation torque is... Represented as:

[0026] In the formula, Let be the antisymmetric matrix of the arm's radius vector. For load or link mass, This represents the component of gravitational acceleration in the body coordinate system.

[0027] The method for calibrating each joint in the joint friction model, proceeding step-by-step from the end of the robotic arm to the base, is as follows: The end joint of the robotic arm is set as the fourth joint. The other three joints are kept locked and stationary. The fourth joint is controlled to rotate at fixed intervals starting from 0 degrees. The holding current at different angles is measured, and the lumped gravity parameters of the fourth joint are obtained by fitting. Using the third joint as the secondary end joint, while keeping the other first, second, and fourth joints locked and stationary, control the rotation of the third joint, and calculate the lumped gravity parameters of the third joint based on the lumped gravity parameters of the fourth joint. The lumped gravity parameters of the first and second joints are calculated sequentially to obtain the lumped gravity parameters of each joint, and the motor torque coefficient of each joint is calculated using the lumped gravity parameters.

[0028] The method for calculating the total compensation current value is as follows:

[0029] In the formula, This is the total compensation current command. For the theoretical gravitational torque, This is the motor torque coefficient. This is the current for kinetic friction balance.

[0030] A robotic arm gravity compensation system that implements the robotic arm gravity compensation method includes: The multi-degree-of-freedom robotic arm body, servo drive unit, control unit, and host computer include: The multi-degree-of-freedom robotic arm body is composed of mechanical joints. Each mechanical joint is driven by a joint motor. The joint motor is a high torque density servo motor. An absolute encoder is integrated at the joint. The multi-degree-of-freedom robotic arm body receives control commands sent by the control unit to perform actions and gravity balance. The servo drive unit collects the position information of the absolute encoders of each joint of the multi-degree-of-freedom robotic arm to obtain the joint angle configuration. At the same time, during the calibration process, it measures the average current of each joint motor as the dynamic friction balance current and sends all recorded parameters to the control unit for data calculation. The control unit constructs a theoretical model of gravity torque and a joint friction model. In the joint friction model, each joint is calibrated step by step from the end of the robotic arm to the base. It receives the recorded parameters sent by the servo drive unit and fits them to obtain the torque coefficients of each joint and the motor. At the same time, it substitutes the joint angle configurations of each joint sent by the servo drive unit into the theoretical model of gravity torque to calculate the theoretical gravity torque. Based on the motor torque coefficient, dynamic friction balance current, and theoretical gravity torque, it calculates the total compensation current value and generates a total compensation current command, which is sent to the multi-degree-of-freedom robotic arm body through the servo drive unit. The host computer issues operation commands to the control unit and displays them visually.

[0031] The servo drive unit uses a high-performance servo driver with torque control mode, and the absolute encoder is an embedded absolute encoder.

[0032] The robotic arm's gravity compensation system reads the angles of each joint in real time via a high-speed fieldbus through periodic communication, and sends the total compensation current command calculated by the control unit to the system. The main body of a robotic arm with up to multiple degrees of freedom.

[0033] The following description, in conjunction with the accompanying drawings and preferred embodiments, provides further details: In the current embodiment, the overall process of the robotic arm gravity compensation method based on the principle of virtual work and step-by-step calibration is as follows: Figure 1 As shown, it includes the following steps: Step S1: Establish a theoretical model of gravitational torque. Using the principle of virtual displacement, analyze the relationship between the potential energy change and virtual work of the robotic arm in a gravitational field. Treat the complex linkage system as a multi-rigid-body system and derive the vector product relationship between joint torque, joint angle, link radius vector, and gravity vector.

[0034] Step S2: Construct a joint friction model. For the low-speed motion characteristics of the joints, a Coulomb friction model is used. The average current of each joint during uniform motion is experimentally determined, i.e., the kinetic friction current threshold, and used as a friction compensation term.

[0035] Step S3: Perform step-by-step decoupling parameter calibration. This is the core step of this embodiment. Unlike the traditional full parameter identification, this embodiment adopts a step-by-step locking strategy from the outside in: (1) Keep joints 1-3 locked, rotate only joint 4, record current and angle data, and fit the gravity parameters of joint 4; (2) Keep joints 1, 2, and 4 locked, rotate joint 3, and use the known parameters of joint 4 to decouple and calculate the parameters of joint 3; (3) And so on, until the calibration of base joint 1 is completed. This method directly obtains the lumped coefficients (such as motor torque constant) including the motor torque constant. This avoids the direct measurement of physical quality.

[0036] Step S4: Real-time compensation control. In real-time control systems such as TwinCAT, the gravitational torque is calculated based on the real-time joint angle, and after superimposing friction compensation, a current command is generated to control the motor.

[0037] The robotic arm gravity compensation system includes: a GIM series high-torque motor, an Elmo servo driver, an absolute encoder, and a PC-based TwinCAT control master station. The system achieves millisecond-level real-time communication and control via the EtherCAT bus.

[0038] Example 1: The experimental platform mainly consists of joint motors, servo drivers, absolute encoders, and a host computer control system. The joint drive unit uses a GIM8108-36 high-torque disc motor, with a rated voltage of 24V, a rated torque of 36 N·m, and 21 pole pairs, meeting the low-speed, high-load drive requirements of the robotic arm. The servo driver is an ElmoGold series (G-POLBEE), connected to the host PC via an EtherCAT bus interface for real-time data communication and control. To obtain accurate joint position information, the system integrates an EA20S06 embedded absolute encoder, feeding back 18-bit high-precision position data to the driver via an RS485 interface. The host computer runs TwinCAT3 real-time control software, identifying EtherCAT slave stations by scanning I / O devices and configuring the motors in torque control mode, thus establishing a complete underlying control architecture.

[0039] Based on the aforementioned hardware platform, in order to achieve high-precision gravity compensation, the system's dynamic parameters need to be identified. The first step is to calibrate the joint friction torque, based on... Figure 3 The Coulomb friction model shown in this embodiment uses experimentally determined dynamic friction compensation parameters. In specific operation, the motor is placed in current mode, with an initial current of 0A and enabled. The current command is then gradually increased in steps of 0.001A, while simultaneously and slightly manually moving the motor arm. The current value is recorded when the motor can maintain a uniform rotation speed for an extended period. Experimentally, the dynamic friction torque parameter of the GIM8108-36 motor in this embodiment is 0.331A, and the dynamic friction torque parameter of the Zhengyuan motor is 0.158A. These parameters will be used as feedforward terms and added to the final control law.

[0040] After determining the friction parameters, this invention employs a step-by-step decoupling strategy, locking the force from the end to the base, to calibrate the gravity parameters. For example... Figure 2 As shown, this invention first establishes the linkage coordinate system and geometric model of the robotic arm, clarifying the geometric relationship between the axial direction of each joint and the gravity vector, including 1. the Elmo motor; 2. the positive element motor; and 3. the robotic arm link. Thus, based on the principle of virtual displacement, the complex dynamic equations are simplified into a theoretical expression of joint torques.

[0041] The specific calibration process begins with the end joint (joint 4): Based on the gravitational torque theoretical model established in step S1, the gravitational torque of this joint theoretically has a sinusoidal relationship with the joint angle. Therefore, keeping the first three joints of the robotic arm mechanically locked, the fourth joint is controlled to rotate from 0 to 500 degrees and remain stationary, and the average motor current required to maintain stationary position at each angle is recorded. Figure 4 As shown, the experimentally measured current data verified the sinusoidal characteristics of the theoretical model. Based on this theoretical model, a sine function was used to fit the measured data to identify the amplitude of the sine wave, and the lumped coefficient of the fourth joint was calculated to be 700 (corresponding to the physical quantity). The current coefficient is calculated to be 168 based on the arm length.

[0042] Subsequently, keeping joints 1, 2, and 4 locked, joint 3 is rotated. Using the torque balance principle and the known parameters of joint 4, the gravity coefficient of joint 3 is calculated. This process is repeated for joints 2 and 4, and the parameters of the base joints are identified sequentially. Finally, a complete set of gravity compensation formulas, including the mass distribution of all connecting rods and the motor torque coefficient, is obtained.

[0043] Finally, the calibrated gravity compensation algorithm was integrated into the TwinCAT3 PLC control program. The system reads the absolute position of each joint encoder in real time during each communication cycle. Substitute the values ​​into the calibrated formula to calculate the theoretical gravitational torque. And combined with the measured friction compensation current Calculate the final total current command The data is then sent to the driver via the EtherCAT bus. In actual operation, after activating the gravity compensation control, the robotic arm can be manually dragged to any configuration within the workspace. The robotic arm can overcome its own gravity and remain stationary without falling or drifting, verifying the effectiveness and engineering applicability of the proposed method based on the principle of virtual work and step-by-step calibration.

[0044] Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make possible changes and modifications to the technical solutions of the present invention by utilizing the methods and techniques disclosed above without departing from the spirit and scope of the present invention. Therefore, any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solutions of the present invention shall fall within the protection scope of the technical solutions of the present invention.

[0045] The contents not described in detail in this specification are common knowledge to those skilled in the art.

Claims

1. A method for gravity compensation of a robotic arm based on the principle of virtual work and step-by-step calibration, characterized in that... include: A theoretical model of gravitational torque is established, taking the robotic arm as a multi-rigid-body target with ideal constraints. The frictional characteristics of the joint transmission chain of the robotic arm are represented by the Coulomb friction model. The dynamic friction torque parameters of each joint motor are measured experimentally and used as feedforward compensation terms to construct the joint friction model. In the joint friction model, each joint is calibrated step by step from the end of the robotic arm to the base. The average current of the motor of each joint is recorded during the calibration process as the dynamic friction balance current, which is used to fit and obtain the lumped gravity parameters and motor torque coefficient of each joint. Measure the joint angle configuration of each joint of the current robotic arm and substitute it into the gravitational torque theoretical model to calculate the theoretical gravitational torque; The total compensation current value is calculated based on the motor torque coefficient, dynamic friction balance current, and theoretical gravitational torque, and the total compensation current command is generated and input into the robotic arm to control the gravity balance of the robotic arm.

2. The method for gravity compensation of a robotic arm based on the principle of virtual work and step-by-step calibration according to claim 1, characterized in that: The method for establishing the theoretical model of gravitational torque is as follows: Based on the principle of virtual displacement, assuming the robotic arm is a multi-rigid-body target with ideal constraints, an equilibrium equation is established in which the sum of the active torque applied to each joint of the robotic arm and the work done by the gravitational potential energy in any virtual displacement is zero. The vector product expression of the gravity compensation torque of each joint of the robotic arm is derived and used to construct the theoretical model of gravity torque.

3. The method for compensating the gravity of a robotic arm based on the principle of virtual work and step-by-step calibration according to claim 2, characterized in that: During the calibration process of each joint from the end of the robotic arm to the base, one side of the joint to be calibrated is kept still. The joint to be calibrated is controlled to move at preset angle intervals and remain still between each movement. The average value of the motor current under static conditions is recorded. The lumped gravity parameters and torque coefficients of each joint are obtained through data fitting.

4. The method for gravity compensation of a robotic arm based on the principle of virtual work and step-by-step calibration according to claim 3, characterized in that: The method for obtaining the lumped gravity parameters of each joint through data fitting is as follows: based on the established gravity torque theoretical model, the gravity torque of the joint to be calibrated is related to the joint angle by a sine function; the average value of the motor current recorded under the condition of moving at the preset angle interval and remaining stationary is fitted with a sine function, and the amplitude of the fitted sine curve is identified, which is used to calculate the lumped gravity parameters of the current joint to be calibrated.

5. The method for compensating the gravity of a robotic arm based on the principle of virtual work and step-by-step calibration according to claim 3, characterized in that: The vector product expression for the gravity compensation torque of each joint is: In the formula, For gravity, The main driving torque is represented by the vector cross product of the torques at each joint. For the k-th joint, the gravity compensation torque is... Represented as: In the formula, Let be the antisymmetric matrix of the radius vector of the arm. For load or link mass, This represents the component of gravitational acceleration in the body coordinate system.

6. The method for gravity compensation of a robotic arm based on the principle of virtual work and step-by-step calibration according to claim 3, characterized in that: The method for calibrating each joint in the joint friction model, proceeding step-by-step from the end of the robotic arm to the base, is as follows: The end joint of the robotic arm is set as the fourth joint. The other three joints are kept locked and stationary. The fourth joint is controlled to rotate at fixed intervals starting from 0 degrees. The holding current at different angles is measured, and the lumped gravity parameters of the fourth joint are obtained by fitting. Using the third joint as the secondary end joint, while keeping the other first, second, and fourth joints locked and stationary, control the rotation of the third joint, and calculate the lumped gravity parameters of the third joint based on the lumped gravity parameters of the fourth joint. The lumped gravity parameters of the first and second joints are calculated sequentially to obtain the lumped gravity parameters of each joint, and the motor torque coefficient of each joint is calculated using the lumped gravity parameters.

7. The method for gravity compensation of a robotic arm based on the principle of virtual work and step-by-step calibration according to claim 6, characterized in that: The method for calculating the total compensation current value is as follows: In the formula, This is the total compensation current command. For the theoretical gravitational torque, This is the motor torque coefficient. This is the current for kinetic friction balance.

8. A robotic arm gravity compensation system for implementing the robotic arm gravity compensation method of claim 6, characterized in that: It includes a multi-degree-of-freedom robotic arm body, a servo drive unit, a control unit, and a host computer, among which: The multi-degree-of-freedom robotic arm body is composed of mechanical joints. Each mechanical joint is driven by a joint motor. The joint motor is a high torque density servo motor. An absolute encoder is integrated at the joint. The multi-degree-of-freedom robotic arm body receives control commands sent by the control unit to perform actions and gravity balance. The servo drive unit collects the position information of the absolute encoders of each joint of the multi-degree-of-freedom robotic arm to obtain the joint angle configuration. At the same time, during the calibration process, it measures the average current of each joint motor as the dynamic friction balance current and sends all recorded parameters to the control unit for data calculation. The control unit constructs a theoretical model of gravity torque and a joint friction model. In the joint friction model, each joint is calibrated step by step from the end of the robotic arm to the base. It receives the recorded parameters sent by the servo drive unit and fits them to obtain the torque coefficients of each joint and the motor. At the same time, it substitutes the joint angle configurations of each joint sent by the servo drive unit into the theoretical model of gravity torque to calculate the theoretical gravity torque. Based on the motor torque coefficient, dynamic friction balance current, and theoretical gravity torque, it calculates the total compensation current value and generates a total compensation current command, which is sent to the multi-degree-of-freedom robotic arm body through the servo drive unit. The host computer issues operation commands to the control unit and displays them visually.

9. The robotic arm gravity compensation system according to claim 8, characterized in that: The servo drive unit adopts a high-performance servo driver with torque control mode, and the absolute encoder is an embedded absolute encoder.

10. The robotic arm gravity compensation system according to claim 8, characterized in that: The robotic arm gravity compensation system reads the angles of each joint in real time via a high-speed fieldbus through periodic communication, and sends the total compensation current command calculated by the control unit to the system. The main body of a robotic arm with up to multiple degrees of freedom.