The invention belongs to the technical field of mechanical arm motors, and particularly relates to an
algorithm for optimizing relative
position control of a mechanical arm motor, which comprises the following steps of: 1, expanding a
state observer, and further performing disturbance
estimation and acceleration
estimation by expanding the
state observer so as to serve as preposed work for online
estimation of an active anti-disturbance device and
inertia; the method comprises the following steps of: 1, judging whether
inertia online estimation in the first step meets the condition of minimum acceleration, 2, judging whether
inertia online estimation in the first step meets the condition of minimum acceleration or not, 3, estimating inertia online, 4, updating controller parameters in real time according to the inertia estimated in the third step so as to improve the self-adaptive capability of a
system, and 5, performing active anti-interference by using a disturbance estimated value so as to improve the self-adaptive capability of the
system. And performing disturbance compensation in cooperation with the fourth step to improve the real-
time response capability of the
system. According to the method, the problems of low response speed, poor self-adaptive capability, high requirement on
system model precision and the like in an existing mechanical arm motor relative
position control algorithm can be solved.