Method of teaching a path to a moving body
FIELD OF INVENTION 
     The present invention relates generally to a method of determining path points to be stored for controlling a moving body, and more particularly to a method of sequentially storing points for controlling movement of a body along a predetermined path wherein sampled path points are selected and stored in response to predetermined relations of three points defining distances and angles along the path. This invention is particularly suitable, but not exclusively, for industrial robots. 
     BACKGROUND OF THE INVENTION 
     A known method of teaching an industrial robot part such as an arm to transverse a path uses a control unit for successively storing points indicative of the moving part path. The points are derived at predetermined travelling distance intervals or at predetermined time intervals. In playback, the control unit controls the moving part in accordance with the stored points to trace the path made by the moving part. However, since such a teaching method involves moving the moving part linearly between the stored points, the interval must be relatively short to provide the required tracing precision. This results in a large capacity memory requirement. 
     A known technique for eliminating such a large capacity memory problem is disclosed in Japanese Patent Provisional Publication No. 56-114685, that includes a control unit for storing a subsequent point Pn+1 when the moving robot part position is greater than a predetermined distance from an extension of a straight line between a presently stored point Pn and a previously stored point Pn-1. While successfully avoiding the above-noted problem for a movement path having many straight portions because the point is not stored when the moving part travels substantially along a straight line, this technique is not well adapted for a path having complex portions such as curved portion. 
     Another approach for eliminating the large capacity problem is disclosed in Japanese Patent Provisional Publication No. 58-176705 having a temporary memory for temporarily simultaneously storing a present point Pn and an angle between a first straight line that connects point Pn with a previously stored point Pn-1 and a second straight line that connects point Pn-1 and a stored point Pn-2 derived prior to point Pn-1. Initial point P1, present point Pn and an intermediate point therebetween are supplied as path data from the temporary memory to a main memory when the angle results in a predetermined condition. Although satisfactory for a path having many curved portions, this prior art technique is disadvantageous for a path that does not have complex portions because the temporary memory must store a large amount of data and thus must have a large capacity. 
     SUMMARY OF THE INVENTION 
     It is therefore an object of the present invention to provide a method of storing a moving body path, which method is capable of effectively reducing the capacity of a storage device for the path concurrently with maintaining substantial playback precision. 
     This object is attained by determining a curved condition of a teaching path on the basis of a difference between path length between first and second points on the path and a straight line between the first and second points and an angle made by a first straight line connecting the first and second points and a second straight line connecting the second point and a third point on the line, and selectively storing the first, second and third points in accordance with the results of the determination. 
     In accordance with a first preferred embodiment of the present invention, the first, second and third points are stored as path data in a memory when said length difference is greater than a reference length and said angle between the lines is smaller than a reference angle. On the other hand, the first and second points are stored, to the exclusion of the third point, when said length difference is greater than the reference length and said angle is greater than the reference angle. 
     In accordance with a second preferred embodiment of the present invention, the first point is stored as path data in a memory when said angle is greater than a reference angle and said length difference is greater than a reference length. On the other hand, none of the first, second and third points is stored when the angle is smaller than the reference angle. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     The object and features of the present invention will become more readily apparent from the following detailed description of the preferred embodiments taken in conjunction with the accompanying drawings in which: 
     FIG. 1 is an illustration of an industrial robot for which the present invention is employed; 
     FIG. 2 is a schematic block diagram of a path teaching apparatus for a first embodiment of this invention; 
     FIG. 3 is a flow chart for the programmed operation of the first embodiment; 
     FIG. 4 is a graphic illustration of the first embodiment in detail; 
     FIGS. 5A and 5B are graphic diagrams respectively illustrating the relation between a teaching path and traced path, with FIG. 5A being a diagram of a result obtained in accordance with a conventional teaching method and FIG. 5B being a diagram of a result obtained in accordance with the first embodiment of this invention; 
     FIG. 6 is an illustration of a path teaching apparatus of a second embodiment of this invention; 
     FIG. 7 is a flow chart of the second embodiment operation; and 
     FIG. 8 is a graphic diagram of a result obtained in accordance with the second embodiment. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     Referring now to FIG. 1, there is illustrated an industrial robot for which the present invention is employed. The industrial robot comprises a base 1 on which a motor 4 is fixedly secured and a rotatable table 2 having circumferential teeth 3. The motor 4 is directly coupled to a pinion gear 5 which in turn engages the teeth 3 the rotational so that the rotational table 2 rotates about the axis of rotation thereof in the direction indicated by the reference λ. A first arm 6 is pivotally connected to the rotational table 2 by means of a pin (not shown) and is swingable by the aid of a hydraulic pressure actuator 7 in the direction indicated by the reference φ. A head portion 8 of the actuator 7 is pivotally connected to the rotational table 2 by a pin 9 and a rod 10 thereof is pivotally connected to the first arm 6 by a pin 11. The first arm 6 is further pivotally connected to a second arm 12 by means of a pin (not shown). Also provided is a hydraulic pressure actuator, having a head portion 14 pivotally coupled to the first arm 6 by a pin 15 having a rod 16 pivotally coupled to the second arm 12 by a pin 17 whereby the second arm 12 is movable in the direction indicated by the reference ψ in response to the hydraulic pressure actuator 13. A first swinging motor 18 at an end of the send arm 12, has a horizontally swinging shaft that rotates in the direction indicated by the reference γ. Connected to the first swinging motor 18 is a second swinging motor 19 having a vertically swinging shaft at right angles to the swinging shaft of the first swinging motor 18 and swinging in the direction indicated by the reference β. The second swinging motor 19 has a pair of fingers 20 for holding a sealing-material applying gun 21. Further included in the industrial robot are position detecors 22, 23, 24, 25 and 26 for respectively detecting the angular position of the rotational table 2 with respect to the base 1, the angular position of the first arm 6 with respect to the rotational table 2, the angular position of the second arm 12 relative to the first arm 6, the angular position of the first swinging motor 18 relative to the second arm 12, and the angular position of the second swinging motor 19 with respect to the first swinging motor 18. 
     FIG. 2 is a schematic block diagram of one example of a path teaching apparatus for the first embodiment of the present invention and FIG. 3 is a flow chart useful for describing the programmed steps of a control unit 32 of FIG. 2 according to the first embodiment of this invention. 
     The control unit 32, or microcomputer, first writes the initial position or basic point P1, of the applying gun 21 into a memory 29 in response to outputs of the position detectors 22 to 26 (step 101), and then samples the present position Pn thereof (step 102). Thereafter, the control unit 32 reads the position data corresponding to the earliest point (i.e., P1 here) from the memory 29 to calculate a straight line distance l between the points P1 and Pn. Here, the present point Pn is indicative of n th  sample point from the point P1, and the sampling is made at predetermined travelling distance intervals, i.e. whenever the applying gun 21 moves by a predetermined distance. Furthermore, the control unit 32 reads the position data corresponding to the sampled point Pn-1 immediately before the point Pn from a memory 31 which stores the position point sampled immediately before the present point Pn, and then computes the length S&#39; of the path between the points P1 and Pn-1. The path length S&#39; may be the straight distance therebetween. The length S&#39; is added to the path length S between the sampled points P1 and Pn-1 which has been stored in a memory 30 and read therefrom in response to a command from the control unit 32. The sum of the length S&#39; and the length S is stored in the memory 30 as the path length between the sampled points Pl and Pn, that is, the length S of the path of the applying gun 21 is updated at every sampling point. At the same time, the position data relating to the presently sampled point Pn is stored in the memory 31 (step 103). 
     The updated path length S is subtracted from the calculated distance l and the difference therebetween is compared with a reference length d derived from a reference length setting means 27. S n  -l n  is compared with d n . If the difference is equal to or greater than the reference length d, the present point Pn of the moving body, i.e., applying gun 21, is stored in the memory 29 as the point second to the point P1 and the memory 30 is reset to zero condition. Furthermore, when the applying gun 21 moves from the point Pn and reaches the next sampling point Pn+1, the control unit 32 computes the position of the sampling point Pn+1 in response to the outputs of the position detectors 22 to 26 and computes an angle θ between the straight line that connects the point P1 with the point Pn and the straight line that connects the point Pn with the point Pn+1(step 104). If the angle θ therebetween is smaller than a reference angle α set, stored and derived by a reference angle setting means 28, the point Pn+1 is stored in the memory 29 as the point second to the point Pn and as a newly basic point P1 (step 105). On the other hand, if the angle θ therebetween is greater than the reference angle α, the point Pn is set as a basic point P1 and the point Pn+1 is set as a presently positioned point Pn, and futher a length of the path between the points Pn and Pn+1 is calculated and stored in the memory 30 (step 106). The above-mentioned operation is repeatedly performed, and the point Pn is stored in the memory 29 when the difference between the path length S and the straight distance l becomes greater than the reference length d. The next point Pn+1 with respect to the stored point Pn is stored in the memory 29 when the angle θ is smaller than the reference angle α. The comparison of angle θ with reference angle α is made using a trigonometric function. 
     The position of the end of the applying gun 21 is represented by coordinates Xn, Yn and Zn on a rectangular coordinate system on the basis of the outputs a, b, c, d, and e of the position detectors 22 to 26 as follows. ##EQU1## On the other hand, the values corresponding to the outputs of the position detectors 22 to 26 are obtained from the coordinates Xn, Yn and Zn on the rectangular coordinate system as follows. ##EQU2## where A is a matrix determined in accordance with the arrangement of an industrial robot, and A -1  is an inverse matrix. 
     The angle θ between the straight line that connects the point P1 with the point Pn and the straight line that connects the point Pn with the point Pn+1 can be derived from sets of X, Y, Z coordinates corresponding to the points P1, Pn, and Pn+1. 
     A detailed description of this embodiment is made with reference to FIG. 4 in which the reference u is a teaching path. 
     When the end of the applying gun 21 lies at a start point P1, the position data relating to the start point P1 is first stored in the memory 29, at this time the memory 30 is reset to the zero condition and the position data relating to the start point P1 is written in the memory 31. When the applying gun reaches a point P2, the control unit 32 reads the data relating to the point P1 from the memory 29 to compute a straight distance P1P2 (=l) between the points P1 and P2. Furthermore, the data relating to the point P1 is read from the memory 31 to calculate a straight distance P1P2 (=S&#39;) which is in turn stored in the memory 30 as an initial path length S. The content of the memory 31 is rewritten with the data relating to the point P2. At this time, the path length S is equal to the straight distance l and therefore the point P2 is not stored. When point P3 is reached, the earliest point P1 is read from the memory 29 to compute a straight distance P1P3 (=l) between the points P1  and P3, and the data relating to the point P2 is read from the memory 31 to calculate a straight distance P2P3 (=S&#39;) which is in turn added to the path length S stored in the memory 30. The sum thereof is stored in the memory 30 as a new path length S, and the memory contents are rewritten with the data relating to the point 30. Here, since the difference between the path length S and straight distance is smaller than the reference length d, the data corresponding to the point P3 is not stored in the memory 29. As long as the applying gun 21 moves from the point P3 to a point P6, the difference is still smaller than the reference length d and therefore the data relating to the points P4 to P6 is not stored therein. However, the contents of the memories 30 and 31 are similarly updated in accordance with the movement of the applying gun 21. 
     At a point P7, similarly, the data relating to the point P1 is read from the memory 29 to compute a straight distance P1P7 (=l), and the data relating to the point P6 is read from the memory 31 to calculate a straight distance P6P7 (=S&#39;) between the points P6 and P7 which in turn added to the path length S stored in the memory 30. The content of the memory 31 is rewritten with the data corresponding to the point P7. At this time, the difference between the path length S and the straight distance P1P7 becomes greater than the reference length d, causing the point P7 to be stored in the memory 29 as a point second to the point P1. When reaching the next point P8, the control unit 32 computes an angle θ (∠P1P7P8) between the straight line that connects the point P1 with the point P7 and the straight line that connects the point P7 with the point P8. Because angle θ is greater than the reference angle α obtained by the reference angle setting means 28 point P8 is not stored and the straight distance P7P8 (=S&#39;) is calculated and stored in the memory 30 as a new path length S. 
     Thereafter, the point P7 is set as a new initial point P&#39;1 and the above operation is repeatedly performed. When the applying gun 21 reaches a point P&#39;7, the difference between a path length S and a straight distance l from the point P&#39;1 to the point P&#39;7 becomes greater than the reference length d, causing point P&#39;7 to be stored in the memory 29. Subsequently, when moving up to a point P&#39;8, an angle θ&#39; (∠P&#39;1P&#39;7P&#39;8) between the straight line that connects the point P&#39;1 with the point P&#39;7 and the straight line that connects the point P&#39;7 with the point P&#39;8 becomes smaller than the reference angle α, causing point P&#39;8 to be stored in the memory 29. At this time, the point P&#39;8 is written in the memory 31 and the memory 30 is reset to the zero condition. The point data stored in the memory 29 is used as path data in playback. 
     Coordinates (X, Y, Z) on a rectangular coordinate system or outputs (a, b, c, d, e) of the position detectors 22 to 26 are employed for storage of the points. 
     In playback, Akima&#39;s method or one-dimentional quasi-cubic bermite interpolation is employed for interpolation with respect to the path data; Akima&#39;s method being disclosed in &#34;NUMERICAL CALCULATION METHOD&#34; written by Hideyo Nagashima and published by MAKI. When a teaching points comprise the start point and the end point, the linear interpolation is employed. On the other hand, when there are three teaching points, the arc interpolation may be used. 
     FIGS. 5a and 5B are graphs respectively illustrating the relation between a teaching path and a traced path where the teaching path is indicated by a solid line and the traced path is indicated by a dotted line. In FIG. 5A is shown a result obtained in accordance with a conventional teaching method, and in FIG. 5B is illustrated the path in accordance the FIG. 4 embodiment, wherein there is a comparison between the angles θ and α in the vicinity of curved portions of the teaching path. The comparison provides two teaching points in the vicinity thereof. It will be understood from the figures that this embodiment provides a satisfactory interpolation result compared with the conventional case of FIG. 5A. 
     According to this embodiment, only two teaching points are stored between the points P1 and Pn or three teaching points are stored between the points P1 and Pn+1 so it is possible to reduce storage capacity. In addition, as described above, it is also possible to trace a teaching path with a relatively high accuracy. 
     A further embodiment of the present invention is described with reference to FIGS. 6 through 8. Fundamentally, a path teaching apparatus for the second embodiment shown in FIG. 6 is the same as that described in connection with FIG. 2 with the exception that a main memory 33 and temporary memory 34 are employed as data storing means. Therefore, the reference numerals designaing corresponding parts are the same as those in FIG. 2. 
     The second embodiment of this invention is described hereinbelow with reference to FIG. 7. 
     A control unit 32 first computes the initial position point P1, the present position point Pn, and the point Pn-1 immediately prior to the present point Pn of a moving part, i.e., an applying gun 21, in response to outputs of position detectors 22 to 26. Unit 31 stores data relating to the respective points in the temporary memory 34 (step 201). Subsequently, the control unit 32 reads the data relating to the initial position point P1 from the temporary memory 30 in order to compute a straight distance l between the initial point P1 and the present point Pn. Here, the present point Pn is indicative of the n th  sampling point with respect to the point P1. The points are sampled whenever the applying gun 21 moves by a predetermined distance. The control unit 32 reads out the data relating to the point Pn-1 from the temporary memory 34 to compute a reads path distance S&#39; between the points Pn and Pn-1, and reads the path length S between the points P1 and Pn-1 from the temporary memory 34 so that the path distance S&#39; is added to the path length S. The sum of the path distance S&#39; and the path length S is stored in the memory 34 as a path length between the points P1 and Pn, thereby updating the path length stored in the memory 34. Furthermore, the control unit 32 reads the data relating to the points P1, Pn-1 and Pn to calculate an angle θ (∠P1Pn-1Pn) between the straight line that connects the point P1 with the point Pn-1 and the straight line that connects the point Pn-1 with the point Pn (step 202). When the angle θ is greater than a reference angle α given by a reference angle setting means 28, the following steps are performed. 
     (1) The control unit 32 determines the difference between the path length S and a straight line distance from the point P1 to the point Pn and compares the difference therebetween with a reference length d set, stored and derived by a reference length setting means 27. When the difference therebetween is greater than the reference length d, a decision flag stored in memory 34 is checked. The decision flag is set to &#34;1&#34; whenever the angle θ is smaller than the reference angle α . If the decision flag is &#34;0&#34;, the data relating to the point P1 is stored in the main memory 33 (step 203). If the decision flag is &#34;1&#34;, the flag is reset to &#34;0&#34; (step 204). Thereafter, the path length S, stored in the memory 34, is rewritten as path distance S&#39; between the points Pn-1 and Pn, and the point Pn-1 is stored in the memory 34 as an initial point P1 and the point Pn is stored therein as a previous point, i.e., Pn-1, (step 205). When the difference between the path length S and the straight distance l is smaller than the reference length d, the present point Pn is stored in the memory 34 as a point of one before the present point (step 206). 
      On the other hand, if the angle θ is smaller than the reference angle α, the following steps are performed. 
     (2) The control unit 32 replaces the path length S, stored in the memory 34, with the distance S&#39; between the points Pn-1 and Pn, and stores the point Pn-1 as an initial point P1 and also stores the point Pn as a point of one before the present point. At the same time, the decision flag in the memory 34 is set to &#34;1&#34; (step 207). 
     Subsequently, the control unit 32 computes a new present point of the applying gun 21 in response to outputs of the position detectors 22 to 26 (step 208). The above-described operation is repeatedly performed until termination of the teaching path. 
     Accordingly, in the second embodiment, only the point P1 is stored as path data when the angle θ is greater than the reference angle α and the difference between the path length and straight line distance is greater than reference length d. On the other hand, none of the points P1, Pn-1 and Pn is stored as path data when the angle θ is smaller than reference angle α, resulting in smoothly tracing the rapidly curved portions of the teaching path which are caused by the vibration of operator&#39;s hand, because points are not stored as path data in the vicinity of the rapidly curved portions. 
     One example performed in accordance with the second embodiment is illustrated in FIG. 8 wherein a teaching path is indicated by a solid line and a traced path is indicated by a dotted line. Similarly, the playback is performed on the basis of Akima&#39;s method. It will be understood from the figure that the highly curved portions of the teaching path are traced smoothly because a teaching point is not provided in the vicinity of rapidly curved portions of the teaching path. The second embodiment is adapted for the case that it is not required to accurately trace a teaching path or that it is required to prevent the vibration of operator&#39;s hand from adversely affecting a path teaching. 
     It should be understood that the foregoing relates to only preferred embodiment of the present invention, and that it is intended to cover all changes and modifications of the embodiments of this invention herein used for the purpose of the disclosure, which do not constitute departures from the spirit and scope of this invention.