Piano robot performance feedforward compensation double-loop control system and method based on PID
By using a PID-based feedforward compensation dual-loop control system, the timing error problem in piano robot performance was solved, achieving high-precision piano performance and improving the system's adaptability and robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HEFEI PANSHI AUTOMATION TECH
- Filing Date
- 2025-12-16
- Publication Date
- 2026-04-17
AI Technical Summary
Existing piano robots, during performance, suffer from discrepancies between the performance timing and the requirements of the score due to factors such as mechanical delay, communication delay, environmental disturbances, and nonlinear errors, which affect musical expression and performance effect.
A PID-based feedforward compensation dual-loop control system is adopted. The outer loop controls the note interval error and the inner loop controls the hand movement time. Combined with the feedforward compensation module, segmented error control is achieved to optimize the performance timing.
It significantly improves the playing accuracy and effect of the piano robot. Through real-time audio feedback and iterative learning, it shortens the time difference between the playing rhythm and the rhythm marked on the score, thereby enhancing the system's adaptability and robustness.
Smart Images

Figure CN121340296B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of robot control and automated performance technology, specifically to a PID-based feedforward compensation dual-loop control system and method for piano robot performance. Background Technology
[0002] Piano playing robots are a product of the combination of automation technology and musical art. One of their core goals is to reproduce the performance sequence set in the score with high fidelity, that is, to achieve precise rhythmic control. However, in actual robot performances, various factors cause discrepancies between the robot's performance and the theoretical timing requirements of the score. For example:
[0003] (1) Mechanical delay differences: The physical structure of the robot, such as the response characteristics of pneumatic joints, friction, clearance and installation errors in the mechanical mechanism, etc., will cause the action response of the actuator to be delayed and inconsistent.
[0004] (2) Communication delay: When control commands are transmitted between the decision-making layer and the execution layer of the system, there is an unavoidable time delay;
[0005] (3) Environmental disturbances: Changes in the working environment (such as temperature and humidity) may cause slight deformations in the mechanical structure, which in turn affect the motion accuracy;
[0006] (4) Nonlinear error: The system's time delay is not a fixed constant; it drifts with changes in playing speed. At the same time, the transitions and combinations between different notes in the music (e.g., whether the hand needs to move a long distance) also introduce different time consumption, making the error exhibit nonlinear characteristics.
[0007] The combination of these factors results in a time difference between the rhythm actually played by the robot and the rhythm specified in the score. This timing discrepancy severely impacts the expressiveness of the music and the final performance effect. Therefore, effectively compensating for these complex time delays and disturbances, and adjusting and optimizing the robot's playing timing in real time, is an urgent problem to be solved. Summary of the Invention
[0008] To address the technical problems existing in the prior art, this invention provides a PID-based dual-loop control system and method for piano robot performance with feedforward compensation. Through dual-loop PID control and feedforward compensation control, the actions of the actuator can be decomposed, achieving adaptive, segmented error control and effectively optimizing the performance timing of the piano robot.
[0009] To achieve the above objectives, the present invention provides the following technical solution:
[0010] This invention discloses a PID-based dual-loop control system for piano robot performance with feedforward compensation, comprising: an execution layer, a music score parsing module, an audio recording module, an outer loop controller, a feedforward compensation module, and an inner loop controller.
[0011] The execution layer includes the hand movement mechanism and finger pressing mechanism of the piano robot.
[0012] The music score analysis module provides the set note intervals and corresponding hand movement distances in real time.
[0013] The audio recording module is used to capture the actual note intervals in the piano robot's performance in real time.
[0014] The outer loop controller is used to obtain the note interval error based on the difference between the actual note interval and the set note interval, and to calculate the total time compensation based on the note interval error and the PID control law.
[0015] The feedforward compensation module is used to determine whether the distance the palm moves is greater than a set threshold. If so, it determines to enter the movement compensation mode and calculates the expected movement time of the palm by combining the total time compensation amount; otherwise, it enters the press compensation mode and calculates the advance press compensation amount of the fingers.
[0016] The inner loop controller is used to generate a hand movement control signal to drive the hand movement mechanism in the movement compensation mode based on the expected movement time and the actual movement time fed back by the hand movement mechanism through a PID control law; the inner loop controller is also used in the press compensation mode to drive the finger press mechanism to adjust the press trigger timing based on the advance press compensation amount.
[0017] As a further improvement to the above scheme, the formula for calculating the note interval error is as follows:
[0018] ;
[0019] In the formula, k The current note; For note interval error, and These are the set note interval and the actual note interval, respectively;
[0020] The outer loop controller calculates the total time compensation using the following formula. :
[0021] ;
[0022] In the formula, , and These are the proportional, integral, and derivative coefficients of the PID controller for the outer loop; T The sampling time for the outer ring.
[0023] As a further improvement to the above scheme, the outer loop controller is also used to trigger a safety protection judgment algorithm while calculating the total time compensation:
[0024] By analyzing the note interval error of three consecutive notes, i.e. and The system judges the error value. When any one of the error values is greater than the preset error warning threshold one, the system is determined to enter a serious error execution state and outputs an emergency stop signal. When any one or more of the error values are greater than the preset error warning threshold two but not greater than the error warning threshold one, the inner loop controller and feedforward compensation module are skipped, and the single-loop PID control law of the outer loop controller is used to control the error of the actuator.
[0025] As a further improvement to the above solution, the feedforward compensation module calculates the amount of compensation for premature finger pressure using the following formula. :
[0026] ;
[0027] In the formula, This is the compensation gain coefficient; ; For the same piano piece, the first The actual pressing action execution time during the next performance, when That is, when the piano robot first plays the aforementioned piano piece. , The nominal pressing action execution time is determined experimentally; when When greater than or equal to 2, Updated to The updated formula is:
[0028] .
[0029] As a further improvement to the above solution, the feedforward compensation module calculates the expected movement time of the palm using the following formula. :
[0030] ;
[0031] In the formula, max(·) represents the maximum value.
[0032] As a further improvement to the above solution, the inner loop controller calculates the hand movement control signal using the following formula. :
[0033] ;
[0034] In the formula, , and These are the proportional coefficient, integral coefficient, and derivative coefficient of the PID controller for the inner loop; , The actual movement time is calculated from the data of the coded sensors of the servo motor in the palm movement mechanism; The sampling time for the inner loop;
[0035] The conversion relationship between the hand movement control signal and the movement speed is expressed as follows:
[0036] ;
[0037] In the formula, The distance the palm moves; The speed at which the palm moves; This is the gain coefficient.
[0038] As a further improvement to the above scheme, the gain coefficient The calculation formula is:
[0039] ;
[0040] In the formula, , and These are empirical constants used to satisfy... The values and It is positively correlated.
[0041] As a further improvement to the above scheme, the theoretical formula for the actual note interval is as follows:
[0042] ;
[0043] In the formula, For a fixed delay, This is a disturbance.
[0044] As a further improvement to the above solution, the audio recording module uses a microphone and an audio acquisition card to analyze the actual note interval while capturing the actual trigger time of the notes.
[0045] This invention also discloses a PID-based feedforward compensation dual-loop control method for piano robot performance, applied to the PID-based feedforward compensation dual-loop control system for piano robot performance described above; the method includes:
[0046] It provides real-time settings for note intervals and corresponding hand movement distances;
[0047] Real-time acquisition of actual note intervals during piano robot performance;
[0048] The note interval error is obtained by the difference between the actual note interval and the set note interval. The total time compensation is calculated based on the note interval error and the PID control law.
[0049] If the distance the palm moves is greater than a set threshold, the system enters the movement compensation mode and calculates the expected movement time of the palm based on the total time compensation. Otherwise, the system enters the press compensation mode and calculates the advance press compensation amount of the fingers.
[0050] In motion compensation mode, a hand movement control signal is generated by a PID control law to drive the hand movement mechanism based on the expected movement time and the actual movement time fed back by the hand movement mechanism. In press compensation mode, the finger press mechanism is driven to adjust the press trigger timing based on the advance press compensation amount.
[0051] Compared with the prior art, the beneficial effects of the present invention are:
[0052] This invention addresses nonlinear error problems caused by mechanical friction, gaps, and time delay drift due to variations in playing speed. It employs centralized closed-loop processing via audio feedback. Instead of attempting to control the difficult-to-model finger pressing time individually, the system treats it as a disturbance and compensates for it uniformly through the outer loop, effectively overcoming the impact of various nonlinear factors on playing accuracy. The system acquires the audio signal of the piano robot's actual performance in real time through a music recording module and compares it with the theoretical time of the score. This allows for accurate calculation of timing errors. Through closed-loop feedback and iterative learning, the system continuously shortens the time difference between the actual playing rhythm and the rhythm indicated in the score, significantly improving the playing effect.
[0053] The feedforward compensation module automatically switches compensation strategies based on whether hand movement is required. When movement is needed, it compensates for hand movement time; when no movement is needed, it compensates for finger pressing advance. This design decomposes the actuator's actions, achieving segmented control of errors and ensuring compensation is applied at the correct stage.
[0054] This invention employs a dual-loop PID control structure, with the outer loop controlling the total interval of notes and the inner loop controlling the hand movement time. The inner loop shares the compensation burden with the outer loop, resulting in better overall compensation. Simultaneously, the introduction of a feedforward module, particularly the gain coefficient in the press compensation mode, aims to achieve rapid response compensation, enabling the system to correct errors more quickly. Attached Figure Description
[0055] Figure 1 This is a three-dimensional structural diagram of the piano robot playing the piano in an embodiment of the present invention.
[0056] Figure 2 for Figure 1 Enlarged view of point A in the image.
[0057] Figure 3 This is an architecture diagram of a dual-loop control system for feedforward compensation of a piano robot based on PID control, as described in an embodiment of the present invention.
[0058] Figure 4 This is a flowchart of a PID-based feedforward compensation dual-loop control method for piano robot performance in an embodiment of the present invention. Detailed Implementation
[0059] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0060] Please see Figures 1 to 3 This embodiment provides a PID-based dual-loop control system for piano robot performance with feedforward compensation, including: an execution layer, a music score parsing module, an audio recording module, an outer loop controller, a feedforward compensation module, and an inner loop controller.
[0061] in, Figure 1 In the diagram, 1 represents a piano, 2 represents a piano robot, and the execution layer includes the piano robot's hand movement mechanism (including a hand movement servo motor) and finger pressing mechanism. Figure 2 for Figure 1 Enlarged view of point A in the image. Figure 2 21 is the finger pressing mechanism, and 22 is the palm movement mechanism. The robot's execution layer receives trigger commands and the target speed for movement between notes.
[0062] The music score analysis module provides the set note intervals and corresponding hand movement distances in real time.
[0063] The audio recording module uses a microphone and an audio acquisition card to capture the actual trigger time of the notes while analyzing the actual intervals between the notes played by the piano robot.
[0064] The remaining components of the system form the decision and control layer, which receives audio signals from the execution and perception layers, calculates errors, and updates control parameters. The controller now has two optimization objectives: finger press timing optimization and palm movement speed optimization. Timing optimization involves adjusting the instruction lead to make the actual note interval closer to the set note interval. Speed optimization involves controlling the palm movement time by adjusting the palm movement speed to make the overall error approach zero.
[0065] Considering the characteristics of musical scores, note intervals are discrete events, therefore this invention requires discretization of control. Let... For the firstk The setting value for the interval between musical notes. These are actual measurements, collected and converted from the audio recording equipment.
[0066] Note intervals Mainly includes hand movement time Finger pressing time Fixed delay and disturbance :
[0067] ;
[0068] Hand movement time Depending on the distance traveled and hand movement speed :
[0069] ;
[0070] in For hand movement control signals, This is the gain coefficient.
[0071] The duration of finger pressure is an uncertain parameter, influenced by various factors such as finger air pressure, mechanical structure, and friction, making it impossible to model and control precisely. This invention treats it as part of the system disturbance and compensates for it through closed-loop feedback.
[0072] The controller of this invention adopts a dual-loop structure. The outer loop controls the note interval, and the inner loop controls the hand movement time. Since hand movement requires setting conditions, this avoids the performance when no hand movement is needed affecting the algorithm's calculation path. Furthermore, to improve the algorithm's fast response, a feedforward compensation enhancement module is added. Because the finger pressing time is an uncertain parameter, a separate feedback control loop is not designed; instead, feedback is provided through the closed-loop outer loop. The control block diagram is as follows: Figure 3 As shown.
[0073] The outer loop controller is used to calculate the note interval error based on the difference between the actual note interval and the set note interval. The calculation formula is as follows:
[0074] ;
[0075] In the formula, k The current note; For note interval error, and These are the set note interval and the actual note interval, respectively.
[0076] The outer loop controller calculates the total time compensation based on the note interval error and the PID control law. The calculation formula is as follows:
[0077] ;
[0078] In the formula, , and These are the proportional, integral, and derivative coefficients of the PID controller for the outer loop; T The outer loop sampling time is typically 50ms-100ms.
[0079] In some embodiments, the outer loop controller is further configured to trigger a security protection judgment algorithm while calculating the total time compensation amount:
[0080] By analyzing the note interval error of three consecutive notes, i.e. and The system judges the error value. When any one of the error values is greater than the preset error warning threshold one (1000ms in this embodiment), the system is determined to enter a serious error execution state and an emergency stop signal is output to an emergency stop switch. When any one or more of the error values are greater than the preset error warning threshold two (350ms in this embodiment) but not greater than the error warning threshold one, the inner loop controller and feedforward compensation module are skipped, and the single-loop PID control law of the outer loop controller is used to control the error of the actuator.
[0081] By setting the above safety protection judgment algorithm, the output of the controller can be avoided from being affected by factors such as structural abnormalities, jamming, and stalling, which would lead to an infinite increase in control output items, excessive control force causing mechanical structural impact and signal interference, thus enhancing the robustness and industrial applicability of the system.
[0082] The feedforward compensation module is used to determine the distance the palm moves. Whether it is greater than a set threshold, in this embodiment, the set threshold is 0.
[0083] when When the time is right, it is determined that the movement compensation mode has been entered, and the expected movement time of the palm is calculated based on the total time compensation amount. The calculation formula is as follows:
[0084] ;
[0085] In the formula, max(·) represents the maximum value; For the first The actual pressing action execution time during the second piano performance; when That is, when the piano robot first plays a piano piece, , The nominal pressing action execution time is determined experimentally.
[0086] By updating the actual pressing action execution time, it is possible to effectively prevent the control system from failing to automatically adapt and learn after the pressing action is affected by external factors such as actuator damage, abnormal air pressure, and sensor failure. This improves the system's adaptability and gives it a certain degree of anti-interference capability.
[0087] when At this time, it means that the palm does not need to move to perform finger pressing and playing, and the feedback signal is ,Right now Then it enters the pressure compensation mode, calculating the amount of pre-press compensation for the finger. The calculation formula is as follows:
[0088] ;
[0089] In the formula, This is the compensation gain coefficient; ; For the same piano piece, the first The actual pressing action execution time during the next performance, when That is, when the piano robot first plays the aforementioned piano piece. , The nominal pressing action execution time is determined experimentally; when When greater than or equal to 2, Updated to The updated formula is:
[0090] .
[0091] In motion compensation mode, the inner loop controller generates a hand movement control signal to drive the hand movement mechanism based on the desired movement time and the actual movement time fed back by the hand movement mechanism using a PID control law. The inner loop controller calculates the hand movement control signal using the following formula. :
[0092] ;
[0093] In the formula, , and These are the proportional coefficient, integral coefficient, and derivative coefficient of the PID controller for the inner loop; , The actual movement time is calculated from the data of the coded sensors of the servo motor in the palm movement mechanism; The sampling time for the inner loop is typically set to 50ms-100ms.
[0094] The conversion relationship between the hand movement control signal and the movement speed is expressed as follows:
[0095] ;
[0096] In the formula, The distance the palm moves; The speed at which the palm moves; This refers to the gain coefficient. The calculation formula is:
[0097] ;
[0098] In the formula, , and These are empirical constants used to satisfy... The values and This is a positive correlation, thus balancing the nonlinear error of the piano robot system. In this embodiment, , , . The value range is from 0.6 to 1.2, where The value range is 0-0.6m.
[0099] The inner loop controller is also used, in press compensation mode, to compensate for the amount of advance press. This drives the finger pressing mechanism to adjust the pressing trigger timing and perform error compensation.
[0100] After completing the above process, the music recording module measures the new interval, completing the closed-loop control.
[0101] This embodiment also provides a PID-based feedforward compensation dual-loop control method for piano robot performance, applying the aforementioned control system. Please refer to... Figure 4 The method includes:
[0102] It provides real-time settings for note intervals and corresponding hand movement distances;
[0103] Real-time acquisition of actual note intervals during piano robot performance;
[0104] The note interval error is obtained by the difference between the actual note interval and the set note interval. The total time compensation is calculated based on the note interval error and the PID control law.
[0105] In some embodiments, this step may also trigger the security protection judgment algorithm described above while calculating the total time compensation amount, which will not be elaborated further.
[0106] If the distance the palm moves is greater than a set threshold, the system enters the movement compensation mode and calculates the expected movement time of the palm based on the total time compensation. Otherwise, the system enters the press compensation mode and calculates the advance press compensation amount of the fingers.
[0107] In motion compensation mode, a hand movement control signal is generated by a PID control law to drive the hand movement mechanism based on the expected movement time and the actual movement time fed back by the hand movement mechanism. In press compensation mode, the finger press mechanism is driven to adjust the press trigger timing based on the advance press compensation amount.
[0108] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A dual-loop control system for feedforward compensation in piano robot performance based on PID control, characterized in that, include: The execution layer includes the hand movement mechanism and finger pressing mechanism of the piano robot; The music score analysis module provides the set note intervals and corresponding hand movement distances in real time. An audio recording module is used to capture the actual note intervals in the piano robot's performance in real time. The outer loop controller is used to obtain the note interval error based on the difference between the actual note interval and the set note interval, and to calculate the total time compensation based on the note interval error and the PID control law. The feedforward compensation module is used to determine whether the distance the palm moves is greater than a set threshold. If so, it determines to enter the movement compensation mode and calculates the expected movement time of the palm by combining the total time compensation amount. Otherwise, it enters the pressure compensation mode and calculates the amount of advance pressure compensation for the finger. The inner loop controller is used to generate a hand movement control signal to drive the hand movement mechanism in the movement compensation mode based on the expected movement time and the actual movement time fed back by the hand movement mechanism through a PID control law; the inner loop controller is also used in the press compensation mode to drive the finger press mechanism to adjust the press trigger timing based on the advance press compensation amount.
2. The PID-based piano robot performance feed-forward compensation double-loop control system according to claim 1, wherein, The formula for calculating the note interval error is: wherein k is the current note; is the note spacing error, and are the set note spacing and the actual note spacing, respectively. The outer loop controller calculates the total time compensation amount by the following equation : In the formula, , and are respectively the PID proportionality coefficient, the integral coefficient and the differential coefficient of the outer loop controller; T is the outer loop sampling time.
3. The PID-based piano robot performance feed-forward compensation double-loop control system according to claim 2, wherein, The outer loop controller is also used to trigger a safety protection judgment algorithm while calculating the total time compensation: By analyzing the note interval error of three consecutive notes, i.e. and The system judges the error value. When any one of the error values is greater than the preset error warning threshold one, the system is determined to enter a serious error execution state and outputs an emergency stop signal. When any one or more of the error values are greater than the preset error warning threshold two but not greater than the error warning threshold one, the inner loop controller and feedforward compensation module are skipped, and the single-loop PID control law of the outer loop controller is used to control the error of the actuator.
4. The PID-based piano robot performance feed-forward compensation double-loop control system according to claim 2, wherein, The feedforward compensation module calculates the amount of pre-press compensation for the finger using the following formula. : In the formula, This is the compensation gain coefficient; ; For the same piano piece, the first The actual pressing action execution time during the next performance, when That is, when the piano robot first plays the aforementioned piano piece. , The nominal pressing action execution time is determined experimentally; when When greater than or equal to 2, Updated to The updated formula is: 。 5. The PID-based piano robot performance feed-forward compensation double-loop control system according to claim 4, wherein, The feedforward compensation module calculates the expected movement time of the palm through the following formula : In the formula, max(·) represents the maximum value.
6. The PID-based piano robot performance feed-forward compensation double-loop control system according to claim 5, wherein, The inner loop controller calculates the palm movement control signal by the following equation : In the formula, , and These are the proportional coefficient, integral coefficient, and derivative coefficient of the PID controller for the inner loop; , The actual movement time is calculated from the data of the coded sensors of the servo motor in the palm movement mechanism; The sampling time for the inner loop; The conversion relationship between the hand movement control signal and the movement speed is expressed as follows: In the formula, is the palm moving distance; is the palm moving speed; is the gain coefficient.
7. The PID-based piano robot performance feed-forward compensation double-loop control system according to claim 6, wherein, gain coefficient The calculation formula is: wherein , and are empirical constants to satisfy the value of is positively correlated.
8. The PID-based piano robot performance feed-forward compensation double-loop control system according to claim 6, wherein, The theoretical formula for the actual note interval is: In the formula, For a fixed delay, This is a disturbance.
9. The PID-based piano robot performance feed-forward compensation double-loop control system according to claim 1, wherein, The audio recording module uses a microphone and an audio acquisition card to capture the actual trigger time of the notes and analyze the actual note intervals.
10. A PID-based piano robot performance feed-forward compensation double-loop control method, characterized in that, The method is applied to the PID-based feedforward compensation dual-loop control system for piano robot performance as described in any one of claims 1 to 8; the method includes: It provides real-time settings for note intervals and corresponding hand movement distances; Real-time acquisition of actual note intervals during piano robot performance; The note interval error is obtained by the difference between the actual note interval and the set note interval. The total time compensation is calculated based on the note interval error and the PID control law. If the distance the palm moves is greater than a set threshold, the system enters the movement compensation mode and calculates the expected movement time of the palm based on the total time compensation. Otherwise, the system enters the press compensation mode and calculates the advance press compensation amount of the fingers. In motion compensation mode, a hand movement control signal is generated by a PID control law to drive the hand movement mechanism based on the expected movement time and the actual movement time fed back by the hand movement mechanism. In press compensation mode, the finger press mechanism is driven to adjust the press trigger timing based on the advance press compensation amount.
Citation Information
Patent Citations
Digital piano playing auxiliary system optimized by machine learning algorithm
CN119479589A
Tempo controller for controlling an automatic play tempo in response to a tap operation
US5227574A