1. Technical Field
Embodiments of the present disclosure relate to controlling mechanical arms, and more particularly to a method for rotating a mechanical arm.
2. Description of Related Art
In industry, movement control of mechanical arms is very important. However, it is not easy to control the mechanical arm to rotate to a preset final position accurately and speedily. At present, a plurality of equations need to be enumerated to analyze in order to control the mechanical arm. If the mechanical arm includes a plurality of sections, the method of enumeration to analyze is very complex and the result may not be optimal.
What is needed, therefore, is an improved method for rotating a mechanical arm.
All of the processes described below may be embodied in, and fully automated via, functional modules executed by one or more general purpose processors. The functional modules may be stored in any type of computer-readable medium or other computer storage device. Some or all of the methods may alternatively be embodied in specialized computer hardware or communication apparatus.
In block S30, the computer 1 receives user input. The user input includes origin position parameters of the mechanical arm 2, final position parameters of the mechanical arm 2, and an iteration accuracy FunX. The origin position parameters include origin coordinates of each of the base joints and each of the end joints of each of the sections of the mechanical arm 2 when the mechanical arm 2 is at an origin position. The final position parameters include final coordinates of each of the base joints and each of the end joints of each of the sections when the mechanical arm 2 is at a final position. In one embodiment, the origin coordinate of the base joint A of the first section may be (XA, YA, ZA). The origin coordinate of the end joint B of the first section may be (X1B, Y1B, Z1B). The final coordinate of the end joint B may be (X2B, Y2B, Z2B). It may be understood that the iteration accuracy FunX is a degree to be reached when each of the sections of the mechanical arm 2 rotates to the final position. Depending on the embodiment, the user input may comprise one or more inputted commands via a hard or software keyboard, or any number of other input devices.
In block S31, the computer 1 determines a position that each of the end joints of each of the sections of the mechanical arm 2 arrives at after each iteration according to the origin position parameters and the final position parameters.
In block S32, the computer 1 calculates a distance between the current position and the final position of the end joint of each of the sections after each iteration. The computer 1 also obtains a minimum distance and calculates coordinates of each of the end joints of each of the sections of the mechanical arm 2 corresponding to the minimum distance.
In block S33, the motor 4 of each of the sections of the mechanical arm 2 drives each of the end joints to rotate to the calculated coordinates of each of the end joints corresponding to the minimum distance.
In block S320, the computer 1 determines a square sum value
of a distance between the current position and the final position of each of the end joints of the mechanical arm 2. The “n” of f(x) denotes an amount of the sections of the mechanical arm 2, as an example shown in
d1=√{square root over ((XB′-X1B)2+(YB′-Y1B)2+(Z1B′-Z1B)2)}{square root over ((XB′-X1B)2+(YB′-Y1B)2+(Z1B′-Z1B)2)}{square root over ((XB′-X1B)2+(YB′-Y1B)2+(Z1B′-Z1B)2)}.
The coordinate (XB''YB''ZB') may be the coordinate of the end joint B when the first section of the mechanical arm 2 rotates to a current position which is nearest to the final position. The unknown coordinate (XB''YB''ZB') can be represented by an expression of an angle α. The expression may be
The angle α denotes the angle the first section of the mechanical arm 2 rotates. The end joint of each of the sections of the mechanical arm 2 can be represented by the expression of an angle each of the sections rotates. Thereby f(x) can be represented by the angle according to the expression. The minimum value of f(x) can be calculated by an iteration method by a preset iteration step. In one embodiment, the preset iteration step is the angle that each of the sections rotates. The minimum value of f(x) can be reached when the current position of each of the sections of the mechanical arm 2 is nearest to the final position of each of the sections.
In block S321, the computer 1 detects if f(x) is smaller than the iteration accuracy FunX. If f(x) is not smaller than the iteration accuracy FunX, block S322 is implemented. If f(x) is smaller than the iteration accuracy FunX, the procedure ends.
In block S322, the computer 1 calculates a descent direction of f(x). It may be understood that the descent direction of f(x) is a direction toward which the value of f(x) decreases.
In block S323, the computer 1 detects if the descent direction exists. If the descent direction exists, block S324 is implemented. If the descent direction does not exist, the procedure ends.
In block S324, f(x+1) is calculated when each of the end joints rotates by the preset iteration step along the descent direction. The method of calculating f(x+1) is the same as the method for calculating f(x) in block S320.
In block S325, the computer 1 detects if f(x+1) is smaller than f(x). If f(x+1) is smaller than f(x), block S322 is repeated. If f(x+1) is not smaller than f(x), block S324 is repeated.
Although certain inventive embodiments of the present disclosure have been specifically described, the present disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the present disclosure without departing from the scope and spirit of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
200910301842.X | Apr 2009 | CN | national |