Visual tool setting method based on cad drawing features and machine tool
By using a visual tool setting method based on CAD drawing features, and utilizing a monocular camera and machine tool motion information, the features of the CAD drawing are analyzed and a feature map is constructed. This achieves precise alignment between the machine tool coordinate system and the workpiece coordinate system, solves the problems of tool setting accuracy and reliability in existing technologies, and improves the reliability and efficiency of tool setting.
Patent Information
- Application Number
- CN202611659341.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-26
- Publication Date
- 2026-11-24
AI Technical Summary
Existing tool setting methods, without increasing hardware costs, cannot rely on manual teaching and offline calibration, nor can they use the existing CAD drawings of the workpiece as the sole dimensional reference to achieve precise alignment between the machine tool coordinate system and the workpiece coordinate system. This is especially problematic in areas with limited accessibility in deep cavities, inclined surfaces, and thin walls, and there is a lack of judgment on the reliability of the results.
A visual tool setting method based on CAD drawing features is adopted. By combining a monocular camera with machine tool motion information, the features of the CAD drawing are analyzed and a feature map is constructed. The correspondence between the drawing coordinates and pixel coordinates is established using a random sampling consistency method. The pixel distance and the actual size scale factor are calculated. Combined with C-axis rotation trajectory fitting and mechanical touch detection, the workpiece origin is accurately positioned in the turntable coordinate system and written into the CNC system.
It achieves precise alignment of the machine tool coordinate system and the workpiece coordinate system without increasing hardware costs or relying on manual teaching, improving tool setting accuracy and reliability, avoiding feature-by-feature contact and the use of special instruments, and ensuring the reliability and verifiability of tool setting results.
Smart Images

Figure CN123160571A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of CNC machine tool technology, specifically to a visual tool setting method and machine tool based on CAD drawing features. Background Technology
[0002] Tool setting is the process of determining the positional relationship between the workpiece coordinate system and the machine tool coordinate system before cutting. It transfers the workpiece origin and coordinate directions from the drawing to the machine tool. After the workpiece is clamped onto the rotary table, the workpiece coordinate system must also establish a correspondence with the coordinate system that moves with the rotary table; otherwise, once the rotary table rotates, the previously written coordinates will no longer hold true. The workpiece origin deviation obtained from tool setting is directly mapped to the deviation of the machining contour, which is equivalent to the machine tool geometric error in finishing.
[0003] Existing contact-based methods rely on edge finders, dial indicators, or in-machine probes, where the operator drives the spindle to contact reference surfaces or reference holes one by one, calculating the workpiece origin based on the readings. This method requires contacting each feature individually, limiting accessibility to deep cavities, inclined surfaces, and thin-walled areas. The contact force can cause elastic deformation in thin-walled parts, and each contact consumes spindle and tool change time. Laser tool setters offer higher accuracy, but their primary measurement object is the tool; measuring the workpiece requires additional transmitting and receiving devices, occupying internal machine space and increasing hardware costs.
[0004] Visual methods replace physical contact with cameras. Monocular 2D vision is mostly used for positioning markers or pre-taught templates, requiring manual selection of features or taking teaching images; re-teaching is necessary after feature changes. Binocular vision and structured light can provide depth, but require additional cameras or projection devices, introducing new calibration problems. The camera and turntable parameters of the above methods are mostly obtained through offline calibration, resulting in drift between the calibration results and the actual field conditions. Pixel coordinates are not linked to the turntable coordinate system, and there is a lack of assessment of the reliability of the results.
[0005] Therefore, the technical problem that needs to be solved is how to obtain tool setting results that can be directly written into the CNC system and have evaluation and correction mechanisms, without increasing hardware costs, relying on manual teaching and offline calibration, using the existing CAD drawings of the workpiece as the sole dimensional reference, and relying solely on a monocular camera device coaxial with the spindle and the machine tool's own motion information. Summary of the Invention
[0006] In view of the above problems, this application provides a visual tool setting method and machine tool based on CAD drawing features.
[0007] According to a first aspect of this application, a visual tool setting method based on CAD drawing features is provided. The machine tool includes a machine body, a spindle, a rotary table, and a monocular camera device. The rotary table includes a B-axis and a C-axis, the C-axis being mounted on the B-axis and tilting with the rotation of the B-axis. The B-axis is arranged around the Y-axis of the machine tool, and the C-axis is arranged around the Z-axis of the machine tool. The spindle is configured to perform linear feed along the X-axis, Y-axis, and Z-axis of the machine tool. The monocular camera device is clamped to the spindle via a tool holder-type connector, the interface of which is consistent with the tool holder interface of the spindle. The optical axis of the monocular camera device is coaxial with the axis of the spindle. The method includes: parsing imported CAD drawings, extracting features from the CAD drawings... A feature graph is constructed based on the given features and the nominal distance and tolerance between each pair of features. The feature graph includes nodes constructed based on the features and edges constructed based on the nominal distance and tolerance between each pair of features. The integer is greater than or equal to 3; the initial image of the workpiece is acquired by the monocular camera device, and the [unclear] is detected in the initial image. Among the features that can be detected The sub-pixel coordinates of each feature, the The two-dimensional coordinates of each feature in the drawing coordinate system and the... A correspondence is established between the sub-pixel coordinates of each feature. The parameters of the two-dimensional similarity transformation of the correspondence are solved using a random sampling consensus method, and erroneous correspondences are eliminated to obtain the interior point set. 3 is greater than or equal to 3 and less than or equal to 3 Integers; based on the pixel distance, nominal distance, and corresponding tolerance of the feature pairs selected from the inlier set, calculate the scaling factor between the pixel distance and the actual workpiece size; according to the priority determined by the feature type, select from the... Select from the features Each candidate feature, for the Perform observability verification on each candidate feature. For candidate features that meet the observability requirement, measure them in the given attitude. For candidate features that do not meet the observability requirement, plan the B-axis swing angle and switch to the corresponding attitude for measurement. 3 is greater than or equal to 3 and less than or equal to 3 The integer; causing the C-axis to rotate to multiple angles with a fixed step size, acquiring images at each angle, forming the... For each candidate feature, a sequence of image point trajectories is obtained. A circle is fitted to each of these trajectories to obtain the center coordinates and radius of the fitted circle. The center coordinates of the fitted circle are determined as the projection position of the C-axis rotation axis in the image, and the radius of the fitted circle is determined as the pixel distance from the candidate feature to the rotation axis. The rotation radius of the candidate feature is obtained based on the scaling factor and the pixel distance from the candidate feature to the rotation axis. The two-dimensional offset vector of the candidate feature in the turntable coordinate system is determined based on the rotation radius and the projection position. The Z-axis coordinate of each candidate feature in the machine tool coordinate system is calculated based on the system deviation determined using the touch detection method. The three-dimensional coordinate measurement value of each candidate feature in the machine tool coordinate system is obtained based on the Z-axis coordinate and the corresponding two-dimensional offset vector. Based on the feature map... The three-dimensional feature coordinates of the candidate features after dimensionality upgrading and the... The rigid body transformation is solved by measuring the three-dimensional coordinates of the candidate features. The rigid body transformation is used as the transformation from the drawing coordinate system to the machine tool coordinate system. The workpiece origin is transformed to the rotary table coordinate system according to the transformation from the drawing coordinate system to the machine tool coordinate system. The coordinates of the workpiece origin in the rotary table coordinate system are obtained and written into the CNC system of the machine tool.
[0008] According to a second aspect of this application, a machine tool is also provided, including a machine tool body, a spindle, a rotary table, a monocular camera device, a tool holder type connector, and a CNC system; the rotary table includes a B-axis and a C-axis, the C-axis is mounted on the B-axis and tilts as the B-axis rotates, the B-axis is arranged about the Y-axis of the machine tool, and the C-axis is arranged about the Z-axis of the machine tool; the spindle is configured to perform linear feed along the X-axis, Y-axis, and Z-axis of the machine tool; the monocular camera device is clamped to the spindle via a tool holder type connector, the interface of the tool holder type connector is consistent with the tool holder interface of the spindle, and the optical axis of the monocular camera device is coaxial with the axis of the spindle; the CNC system is configured to perform the steps of the visual tool setting method based on CAD drawing features according to an embodiment of this application.
[0009] According to some embodiments of this application, this application uses the nominal distance and tolerance of features in CAD drawings as the sole dimensional reference, and the correspondence between drawing coordinates and image coordinates simultaneously provides pixel equivalents, replacing calibration plates and offline calibration. Tool setting accuracy is updated according to the correspondence between drawings and images. The projection position and radius of rotation of the rotation axis are fitted by the trajectory circle of each feature image point when rotating with a fixed step distance on the C-axis. The geometric parameters of the turntable are directly excited by the movement of the machine tool itself. The depth missing by the monocular camera is closed by a single mechanical touch, avoiding feature-by-feature contact and dedicated instruments. The workpiece origin is anchored to the turntable coordinate system by rigid body transformation solved by three-dimensional feature coordinates and three-dimensional coordinate measurement values. The coordinates written into the CNC system are still valid after the turntable rotates. Confidence assessment, automatic correction, and full feature retesting provide comparable criteria before writing, making the tool setting result change from invisible pixel calculations to verifiable coordinate output. Attached Figure Description
[0010] The above-mentioned contents, other objects, features and advantages of this application will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0011] Figure 1 A flowchart illustrating a visual tool setting method based on CAD drawing features according to an embodiment of this application is shown schematically.
[0012] Figure 2 A schematic diagram of the structure of a machine tool according to an embodiment of this application is shown. Detailed Implementation
[0013] The embodiments of this application will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of this application for ease of explanation. However, it will be apparent that one or more embodiments may be implemented without these specific details. Furthermore, descriptions of well-known structures and technologies are omitted in the following description to avoid unnecessarily obscuring the concepts of this application.
[0014] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0015] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0016] To facilitate understanding, the following terms and their definitions, origins, and uses are explained first. The machine tool coordinate system refers to a three-dimensional Cartesian coordinate system with the mechanical zero point of each feed axis as its origin and the guide rail direction of each feed axis as its coordinate axis direction. Its origin is the definition of coordinate readings for each axis by the CNC system, used as a common reference for all measured values. The rotary table coordinate system refers to a three-dimensional Cartesian coordinate system fixed to the C-axis rotary table and rotating with the C-axis. Its origin is the intersection of the C-axis axis and the clamping surface. Its origin is the mechanical structure of the rotary table, used to support the workpiece origin and extend to any B / C posture. The drawing coordinate system refers to the two-dimensional Cartesian coordinate system used in CAD drawings. Its origin is the annotation reference of the drawing, used to provide coordinate references for features, nominal distances, and tolerances. The workpiece origin refers to the point on the drawing representing the workpiece position. Its origin is the drawing annotation, used to write into the workpiece coordinate system register of the CNC system.
[0017] The transformation between the machine tool coordinate system and the rotary table coordinate system is given by the forward kinematics of equation (1):
[0018] (1)
[0019] In equation (1), The coordinates of the point in the machine tool coordinate system are in millimeters. The coordinates of the point in the turntable coordinate system are in millimeters. for Axis angle, for Axial angles, all in radians; To bypass Axis rotation The homogeneous transformation matrix, To bypass Axis rotation The homogeneous transformation matrix is given by both of these matrices, which are dimensionless. This formula connects the tool setting results from the rotary table coordinate system to any machining posture, serving as the common basis for all subsequent coordinate transformations.
[0020] Features refer to geometric elements on a drawing that correspond to the image detection results, including the center of a circular hole, contour corner points, points on a straight contour, and reference marks. Their source is drawing analysis, and they serve as nodes in the feature map, participating in matching and calculation. Nominal distance refers to the distance between two features marked on the drawing, and tolerance refers to the allowable deviation range of that distance. Both originate from drawing annotations and are used to construct the edges of the feature map and as constraints for pixel equivalent calibration. A feature map is a graph structure constructed with features as nodes and nominal distance and tolerance as edges. The source of Z is the parsing result of step S110, which is used for subsequent matching, filtering and dimensionality upgrading index; Z-axis attribution refers to the annotation that the feature belongs to the top surface, bottom surface or through, which is sourced from drawing annotation or user specification, and is used to upgrade the two-dimensional coordinates to three-dimensional feature coordinates in step S180; priority refers to the selection order determined by the feature type, which is sourced from the feature type and tolerance size, and is used to select candidate features in step S140 and replace substitute features in step S210.
[0021] The initial image refers to the panoramic image acquired at the initial working height, originating from the acquisition action in step S120, and is used to detect sub-pixel coordinates. Sub-pixel coordinates refer to the position of features in the image, with a precision higher than integer pixels, and are measured in pixels. They originate from image detection and are used to establish correspondences and calculate pixel distances. The correspondence refers to the pairing between a drawing feature and an image detection result, originating from pairing the drawing's two-dimensional coordinates and sub-pixel coordinates according to feature type, and is used to solve for two-dimensional similarity transformations. Two-dimensional similarity transformations refer to those involving only scaling, rotation, and translation. Plane transformation, whose parameters include scaling factor, rotation angle, and translation vector, is derived from the solution in step S120 and is used for coarse positioning and residual calculation; the random sampling consensus method refers to a robust estimation method that repeatedly randomly draws the smallest sample and selects the best one based on the degree of consensus, which is derived from step S120 and is used to eliminate outliers; the interior set refers to the set of correspondences judged to be correct, and the interior ratio refers to the proportion of the interior set in all correspondences, both of which are derived from the judgment in step S120 and are used for the regression samples in step S130 and the confidence index in step S210.
[0022] Pixel distance refers to the Euclidean norm of the difference between the sub-pixel coordinates of two features, measured in pixels. It originates from image detection and is used in step S130 to regress the scaling factor and in step S150 to fit a circle. The scaling factor is the ratio between the pixel distance and the actual size of the workpiece, measured in millimeters per pixel, also known as the pixel equivalent. It originates from the weighted regression in step S130 and is used in step S160 to calculate the radius of gyration and in step S210 to evaluate the calibration results. Tolerance weight refers to the regression weight assigned to the feature pair based on the inverse square of the distance tolerance. It originates from the drawing tolerance and is used in step S150. The weighted least squares in step S130; candidate features refer to the features selected for measurement in the current posture, which are selected according to priority in step S140 and used for C-axis rotation measurement in step S150; observability refers to the property of whether a feature can be effectively imaged in the current posture, which is derived from the angle between the normal vector and the optical axis and the field of view, and used for the measurement posture arrangement in step S140; B-axis sway angle refers to the rotation angle planned for unobservable features within the B-axis travel limit, which is derived from the planning in step S140 and used for adjusting the measurement posture of the feature.
[0023] The image point trajectory sequence refers to the sequence of sub-pixel coordinates of the same feature in each frame of the image arranged in angular order when the C-axis rotates at a fixed step. Its source is the data acquisition in step S150, used for least-squares circle fitting. Least-squares circle fitting is a method that uses the sum of the squares of the radial distances from the image point to the circle to solve for the fitting of the circle's center and radius. Its source is step S150, used to provide the projection position and pixel distance. The projection position refers to the coordinates of the projection point of the C-axis rotation axis on the image plane, sourced from the center of the fitted circle, used to determine the orientation of the two-dimensional offset vector. The rotation radius is... The feature's actual distance from the C-axis rotation axis, measured in millimeters, is derived from the product of the scaling factor and the radius of the fitted circle, and is used to calculate the two-dimensional offset vector. The azimuth angle is the polar angle of the feature image point relative to the projected position, derived from the azimuth angle calculation and 90° verification in step S160, and is used for the component decomposition of the two-dimensional offset vector. The two-dimensional offset vector is the position vector of the feature relative to the rotation axis in the turntable coordinate system, with its first component along the X-axis direction and its second component along the Y-axis direction, derived from step S160, and used for the forward kinematics solution in step S170.
[0024] Visual height fixation refers to determining the top surface of a feature based on the peak focus sharpness. The estimation process originates from the acquisition and evaluation in step S170, which provides a Z-axis reference. The touch test method refers to contacting the top surface of a feature with a probe or tool setting block and reading the machine tool data. The coordinate method originates from the mechanical measurements of the machine tool and is used to determine the system deviation. The system deviation refers to the common difference between the top surface height obtained from visual height determination and the height obtained from mechanical touch measurement, measured in millimeters. It originates from a single touch measurement in step S170 and is used to uniformly compensate for the Z-axis coordinates of all candidate features. The Z-axis coordinate refers to the coordinates of the feature along the Z-axis in the machine tool coordinate system. The three-dimensional coordinate measurement value refers to the three-dimensional coordinates of the feature in the machine tool coordinate system. Both originate from compensation and forward kinematics, and are used for the rigid body transformation in step S180. Rigid body transformation refers to transformations that only involve rotation and translation and do not change the distance between two points. Coordinate transformation, described by rotation matrix and translation vector, originates from the singular value decomposition in step S180 and is used for workpiece origin transformation in step S190; root mean square residual refers to the root mean square of the sum of squares of residuals for each feature pair, originates from the back substitution of rigid body transformation, and is used for confidence assessment in step S210; acceptance threshold refers to the maximum deviation limit on which the retest is judged to pass, originates from the free tolerance of the drawing, and is used for retest judgment in step S230; tool setting report refers to the structured output recording feature table, confidence index and calibration results, originates from generation in step S270, and is used for user review and archiving.
[0025] The machine tool body refers to the basic mechanical component that supports the spindle and rotary table. It originates from the assembly relationship of the bed, column, and guide rails, and provides the installation reference for the spindle and rotary table. The spindle is the component that performs linear feed and clamps the tool or camera device. It originates from the feed axis configuration of the machine tool and is used to drive the camera device and provide coordinate readings. The rotary table is the component that clamps and rotates the workpiece, including the B-axis and C-axis. The B-axis is positioned around the Y-axis, and the C-axis is positioned around the Z-axis, with the C-axis mounted on top of the B-axis. It originates from the rotary table-type five-axis structure and is used to support the workpiece and excite rotary motion. The toolholder-type extension rod refers to an extension rod with one end consistent with the spindle toolholder interface and the other end clamping the monocular camera device. It originates from the standard toolholder interface. To ensure that the optical axis of the imaging device is coaxial with the axis of the spindle; a monocular imaging device refers to a measuring device consisting of an imaging lens and an image sensor, which originates from the vision configuration of a machine tool and is used to acquire workpiece images; the optical axis refers to the optical axis of the imaging lens, which originates from the assembly of the lens and the image sensor, and is used to ensure that it is coaxial with the axis of the spindle, so that the image becomes an orthographic projection along the direction of the spindle; the tool holder interface refers to the positioning and clamping structure at the front end of the spindle used to clamp the tool holder, which originates from the structure at the end of the spindle and is used to cooperate with the interface of the tool holder type connecting rod; the CNC system refers to the control system that executes the tool setting steps and stores the workpiece coordinate system, which originates from the control configuration of the machine tool, and is used to receive the workpiece origin coordinates and control the movement of each axis.
[0026] like Figure 1 As shown, the visual tool setting method of this application embodiment includes steps S110 to S190.
[0027] In step S110, the imported CAD drawings are parsed and the CAD drawings are extracted. A feature graph is constructed based on each feature and the nominal distance and tolerance between every two features. The feature graph includes nodes constructed based on the features and edges constructed based on the nominal distance and tolerance between every two features. It is an integer greater than or equal to 3.
[0028] In some embodiments, the parsing of CAD drawings is performed by reading the elements separately: for circles and arcs, the center, radius, and diameter tolerances are read; for lines and polylines, the endpoints and the included angles between adjacent sides are read; and for datum symbols and geometric tolerance annotations, the constrained features and tolerance zones are read. The extracted... Each feature serves as a node in the feature graph. The nominal distance between any two features is calculated as the difference between their two-dimensional coordinates. The tolerance is a combination of the dimensional and positional tolerances of the two features, which serves as the attribute of the connection. Take an integer greater than or equal to 3, and its lower bound guarantees that there are at least 3 pairs of corresponding relationships that can be solved in the subsequent two-dimensional similarity transformation.
[0029] In some embodiments, features with only two-dimensional annotations are assigned Z-axis affiliation according to default rules: hole features are treated as through-holes, top surface contour points are treated as top surfaces, and bottom surface contour points are treated as bottom surfaces. Accordingly, the two-dimensional coordinates are upgraded to three-dimensional feature coordinates, and the upgrade result participates in rigid body transformation in step S180. Priority is also assigned to each feature for use in step S140 to select candidate features.
[0030] Feature map denoted as ,in, For a set of nodes, For the set of edges, nodes and edges are defined according to equation (2):
[0031] , (2)
[0032] In equation (2), For a set of nodes, nodes Corresponding to the One feature; For the set of connected edges, the connected edges The attribute is nominal distance. With tolerance All units are millimeters; The characteristic number is an integer greater than or equal to 3.
[0033] The two-dimensional feature coordinates are upgraded to three-dimensional feature coordinates according to equation (3):
[0034] (3)
[0035] In equation (3), For the first The three-dimensional feature coordinates of each feature in the drawing coordinate system, in millimeters; , The coordinates of this feature on the drawing are in millimeters. To be according to The attribution of belonging The coordinates are in millimeters.
[0036] In step S120, an initial image of the workpiece is acquired by a monocular camera device, and detection is performed in the initial image. Among the features that can be detected The sub-pixel coordinates of each feature will The two-dimensional coordinates of each feature in the drawing coordinate system and A correspondence is established between the sub-pixel coordinates of each feature. The parameters of the two-dimensional similarity transformation of the correspondence are solved using a random sampling consensus method, and erroneous correspondences are eliminated to obtain the interior point set. 3 is greater than or equal to 3 and less than or equal to 3 Integers.
[0037] In some embodiments, the initial image is a panoramic image acquired after the main shaft drives the monocular camera to the initial working height; during detection, the appropriate detection operator is selected according to the feature type: for hole features, the center coordinates are obtained by center detection; for corner points, the sub-pixel coordinates are obtained by corner detection; and for straight line contour points, the sub-pixel coordinates are obtained by sub-pixel edge fitting. The detectable features are denoted as... indivual, Take a value greater than or equal to 3 and less than or equal to 3. Integers; When the value is less than 3, there is no solution for the two-dimensional similarity transformation. The system outputs a message indicating insufficient measurable features and terminates.
[0038] In some embodiments, the random sampling consensus method repeatedly selects from... At least two pairs are randomly selected from the correspondences, and the candidate parameters are solved by least squares. Then, all correspondences are projected according to equation (4), and the number of deviations not exceeding the deviation threshold is counted. The candidate parameter set with the most interior points wins. The extraction, solution, and statistics are repeated until the termination condition is met. The termination condition is the maximum number of iterations or the number of interior points no longer increases. The interior point set and interior point ratio are used again as confidence indicators in step S210.
[0039] The matching residual is calculated according to equation (4):
[0040] (4)
[0041] In equation (4), For the first The features of the first drawing and the first The matching residuals between image detection results are expressed in pixels. This is a rough value for the scaling factor, in millimeters per pixel; The angle at which the workpiece is positioned on the turntable, in radians; It is a two-dimensional rotation matrix, and it is a dimensionless matrix; For the first The two-dimensional coordinates of each feature in the drawing coordinate system, in millimeters; This is a translation vector, with units of pixels; For the first Subpixel coordinates of each detection result, in pixels; This represents the Euclidean norm.
[0042] The interior set and interior ratio are calculated according to equation (5):
[0043] , (5)
[0044] In equation (5), It is an interior point set; For the first The matching residual of the correspondence, in pixels; This is the deviation threshold, expressed in pixels. The set of correspondences participating in the matching; Indicates the number of elements in the set; Let be the interior point law, and be a dimensionless quantity.
[0045] In step S130, the scaling factor between the pixel distance and the actual size of the workpiece is calculated based on the pixel distance, nominal distance and corresponding tolerance of the feature pairs selected in the inner point set.
[0046] In some embodiments, feature pairs are obtained by pairwise combination from the set of interior points, totaling... right, Take values greater than or equal to 1 and less than or equal to 1. The integer; the pixel distance of each feature pair is calculated using the Euclidean norm of the difference between the sub-pixel coordinates of the two features. The nominal distance is read from the edge attribute of the feature map, and the distance tolerance is synthesized using the root mean square of the tolerances of the two features. The ratio of the pixel distance to the nominal distance is the pixel equivalent observation value given by the feature pair. The observation values are weighted according to the tolerance weights and then regressed; the smaller the tolerance, the larger the weight.
[0047] In some embodiments, weighted regression uses a linear model passing through the origin to solve for the scaling factor: the nominal distance of each feature pair is used as the independent variable and the pixel distance as the dependent variable, with the weights being the inverse square of the distance tolerance; after regression, each feature pair is regressed one by one, and correspondences with residuals exceeding half of the strictest tolerance are discarded and regressed until the feature pairs participating in the regression are stable. The scaling factor continues to be used in steps S160 and S210.
[0048] The scaling factor is calculated using the weighted least squares regression solution of equation (6):
[0049] (6)
[0050] In equation (6), This is a scaling factor, measured in millimeters per pixel; For feature pairs The tolerance weight is expressed in units of 1 / square millimeter; For feature pairs The pixel distance, in pixels; For feature pairs The nominal distance, in millimeters; summation iterates through all feature pairs involved in the regression.
[0051] Tolerance weights and composite distance tolerances are calculated according to formula (7):
[0052] , (7)
[0053] In equation (7), For feature pairs The composite distance tolerance is expressed in millimeters. , For the tolerances of the two features, in millimeters; This represents the tolerance weight, expressed in units of 1 / square millimeter.
[0054] In step S140, according to the priority determined based on the feature type, from Select from the features Each candidate feature, for Perform observability verification on each candidate feature. For candidate features that meet the observability requirement, measure them in the given attitude. For candidate features that do not meet the observability requirement, plan the B-axis swing angle and switch to the corresponding attitude for measurement. 3 is greater than or equal to 3 and less than or equal to 3 Integers.
[0055] In some embodiments, priority is determined by feature type, in the order of: reference feature > high-precision hole > contour corner point > general contour point; within the same type, features are sorted by tolerance from smallest to largest. This order is followed from... Select from the features One candidate feature, Take a value greater than or equal to 3 and less than or equal to 3. The integer is set to 4 to 6 by default, taking into account both computational redundancy and tool setting time.
[0056] In some embodiments, the observability check calculates two things for each candidate feature: first, the cosine of the angle between the unit normal vector of the workpiece surface at the feature and the unit vector opposite to the optical axis; a larger cosine indicates that the feature surface is more directly facing the lens; second, whether the sub-pixel coordinates of the feature in the initial image fall within the field of view. If both conditions are met, the feature is considered observable and is measured directly in the current posture; otherwise, a feasible swing angle is searched for for the feature within the B-axis travel limit, and the feature is transferred to the corresponding posture for measurement. If no feasible swing angle can be found for any of the candidate features, a feature unreachable prompt is output and the process terminates.
[0057] The observability criterion is given by equation (8):
[0058] ,and (8)
[0059] In equation (8), For the first The angle between the workpiece surface normal vector and the optical axis reverse vector at each candidate feature location, in radians; Let be the unit normal vector of the workpiece surface at this feature, which is a dimensionless quantity; It is a unit vector that is reversed on the optical axis of a monocular camera, and it is a dimensionless quantity; The maximum allowed observation angle is in radians, with a default value of 45°. These are the subpixel coordinates of the feature in the initial image, in pixels; This represents the camera's field of view at the current pose.
[0060] In step S150, the C-axis is rotated to multiple angles with a fixed step size, and images are acquired at each angle to form a... For each candidate feature, a sequence of image point trajectories is obtained. For each image point trajectory sequence, a circle is fitted to obtain the center coordinates and radius of the fitted circle for that candidate feature. The center coordinates of the fitted circle are determined as the projection position of the C-axis rotation axis in the image, and the radius of the fitted circle is determined as the pixel distance from the candidate feature to the rotation axis.
[0061] In some embodiments, the C-axis rotates within a set range at fixed step intervals. From one angle, Take an integer greater than or equal to 3; capture one frame of image at each angle, for a total of Frame images. The sub-pixel coordinates of the same candidate feature in each frame image are arranged in angular order to form a sequence of image point trajectories. Each image point in the sequence corresponds to a known C-axis rotation angle, which is taken from the machine tool encoder rather than image estimation.
[0062] In some embodiments, circle fitting is performed in two steps: First, a least-squares circle fitting is performed using all image points to obtain a preliminary fitted circle, and the radial distance from each image point to the preliminary fitted circle is calculated as the fitting residual; after removing image points whose residuals exceed a residual threshold, a second least-squares circle fitting is performed using the remaining image points to obtain the refined center coordinates and radius. The center coordinates are the projection position of the C-axis rotation axis in the set of images, and the radius is the pixel distance from the feature to the rotation axis.
[0063] The least squares circle fit is solved according to equation (9):
[0064] (9)
[0065] In equation (9), The coordinates of the center of the fitted circle are in pixels. The radius of the fitted circle is in pixels; This is the optimal solution to equation (9); , For the first The two components of the subpixel coordinates of this feature in the frame image, in pixels; sum them up and traverse all image points of the trajectory sequence.
[0066] Image point residuals are calculated according to formula (10):
[0067] (10)
[0068] In equation (10), For the first The radial distance from each pixel to the fitted circle, in pixels; Image points exceeding the residual threshold are discarded; the residual threshold is measured in pixels.
[0069] In step S160, the rotation radius of the candidate feature is obtained based on the scaling factor and the pixel distance from the candidate feature to the rotation axis, and the two-dimensional offset vector of the candidate feature in the turntable coordinate system is determined based on the rotation radius and the projection position.
[0070] In some embodiments, the rotation radius is obtained by multiplying the scaling factor by the pixel distance, in millimeters. The azimuth angle is the polar angle of the feature image point relative to the projected position. To determine the rotation direction, two frames of images with a 90° difference are taken and the first and second azimuth angles are calculated respectively. The deviation of the azimuth angle difference from 90° is used as a check. If the absolute value of the deviation does not exceed the angle threshold, the rotation angle of the two frames of images is considered to be consistent with the encoder reading. The first azimuth angle is taken as the azimuth angle of the feature in the turntable coordinate system. Otherwise, the two frames of images are re-acquired.
[0071] In some embodiments, the first component of the two-dimensional offset vector is the product of the radius of gyration and the cosine of the azimuth angle, and the second component is the product of the radius of gyration and the sine of the azimuth angle. The two components are respectively along the X-axis and Y-axis of the rotary table coordinate system and are transformed to the machine tool coordinate system by forward kinematics in step S170.
[0072] The radius of gyration and the two-dimensional offset vector are calculated according to equation (11):
[0073] ; ; (11)
[0074] In equation (11), For the first candidate features to The radius of gyration of the axis of rotation, in millimeters; This is a scaling factor, measured in millimeters per pixel; For the first The radius of the fitted circle after refining each candidate feature, in pixels; , These are the first and second components of a two-dimensional offset vector, in millimeters. The azimuth angle of this feature is expressed in radians.
[0075] Azimuth angle verification is performed according to formula (12):
[0076] , (12)
[0077] In equation (12), This is the azimuth difference; , The first and second azimuth angles of the feature relative to its projection position in two frames that are 90° apart are given in radians. This is the angle threshold, in radians, with a default value of 2°.
[0078] In step S170, based on the system deviation determined by the touch test method, the Z-coordinate of each candidate feature in the machine tool coordinate system is calculated. Based on the Z-coordinate and the two-dimensional offset vector of the corresponding candidate feature, the three-dimensional coordinate measurement value of each candidate feature in the machine tool coordinate system is obtained.
[0079] In some embodiments, the focus sharpness at visual height is adjusted according to the main axis. The peak value of the coordinate change determines the top surface of the feature. Estimated value: The principal axis moves in small steps within a set range, acquiring one image for each step and calculating the sharpness evaluation function. The principal axis corresponding to the peak value of the evaluation function is then selected. The coordinates are subtracted from the lens working distance to obtain the top surface coordinates of the feature. Estimated value.
[0080] In some embodiments, the system deviation can be determined with just one mechanical touch test: the machine tool's probe or tool setting block touches the top surface of any candidate feature, and the machine tool records the touch time. Coordinate reading, which is relative to the top surface of the feature. The difference in estimates is the systematic bias; under the same clamping conditions, this bias affects the visual perception of all candidate features. The estimated values are uniformly compensated. Then, the two-dimensional offset vector is converted to machine tool coordinates using the forward kinematics solution. Quantity and The component, together with the compensated Z-axis coordinate, is used to synthesize the three-dimensional coordinate measurement value.
[0081] Systematic bias and The coordinates are calculated according to equation (13):
[0082] ; (13)
[0083] In equation (13), This is the systematic deviation, in millimeters; Machine tools for mechanical touch testing Coordinate readings, in millimeters; The visual top surface of the touched feature Estimated value, in millimeters; For the first After compensation of candidate features Coordinates, in millimeters; For the visual top surface of this feature Estimated value, in millimeters.
[0084] The two-dimensional offset vector is transformed to the machine tool coordinate system according to the forward kinematics solution of equation (1), and the coordinates of this feature in the rotary table coordinate system are taken. The result The first two components are Quantity and Components; the three-dimensional coordinate measurement values are synthesized according to formula (14):
[0085] (14)
[0086] In equation (14), For the first Machine tool coordinate measurements of each candidate feature, in millimeters; , The result obtained according to formula (1) Quantity and Quantity, in millimeters; After compensation The coordinates are in millimeters.
[0087] In step S180, based on the feature map The three-dimensional feature coordinates of each candidate feature after dimensionality upgrade and Solve the rigid body transformation by taking the three-dimensional coordinate measurements of each candidate feature, and use the rigid body transformation as the transformation from the drawing coordinate system to the machine tool coordinate system.
[0088] In some embodiments, before solving, the two-dimensional coordinates of the drawing are first upgraded according to the Z-axis attribution of each candidate feature: the top surface feature is taken as the height of the top surface annotation, the bottom surface feature is taken as the height of the bottom surface annotation, and the through-feature is taken as one of the heights of its two end surfaces. The upgraded three-dimensional feature coordinates constitute the first point set, and the three-dimensional coordinate measurements constitute the second point set. The two point sets correspond one-to-one according to the feature number.
[0089] In some embodiments, the objective function is the sum of squared Euclidean distances between the first point set and the second point set after rotation and translation; the constraint is that the rotation matrix is orthogonal and its determinant is positive 1. The solution is obtained using a closed-form solution with singular value decomposition: calculate the centroids of the two point sets respectively, construct the cross-covariance matrix after removing the centroids, perform singular value decomposition on it to obtain the rotation matrix, and then calculate the translation vector from the two centroids and the rotation matrix.
[0090] Rigid body transformations are solved according to equation (15):
[0091] , , (15)
[0092] In equation (15), It is a 3×3 rotation matrix, and it is a dimensionless matrix; This is a translation vector, in millimeters; For the first The three-dimensional feature coordinates of each candidate feature in the drawing coordinate system, in millimeters; For the first The three-dimensional coordinate measurements of each candidate feature in the machine tool coordinate system, in millimeters; It is the identity matrix; Representing the determinant of a matrix; summation and traversal. One candidate feature.
[0093] The closed-form solution of equation (15) is given by equation (16):
[0094] ; ; ; (16)
[0095] In equation (16), , Let be the centroid of the first and second point sets, in millimeters; The cross-covariance matrix is in square millimeters. , , for The singular value decomposition results; Construct a function for a diagonal matrix; , The rotation matrix and translation vector are used to transfer the coordinates from the drawing coordinate system to the machine tool coordinate system.
[0096] In step S190, the workpiece origin is transformed to the rotary table coordinate system according to the transformation from the drawing coordinate system to the machine tool coordinate system, so as to obtain the coordinates of the workpiece origin in the rotary table coordinate system, and the coordinates of the workpiece origin in the rotary table coordinate system are written into the CNC system of the machine tool.
[0097] In some embodiments, the workpiece origin is given by the drawing, and a point with technological significance is selected from the drawing. The workpiece origin is first transformed to the machine tool coordinate system by the rotation matrix and translation vector from the drawing coordinate system to the machine tool coordinate system, and then transformed to the rotary table coordinate system by the inverse transformation from the rotary table coordinate system to the machine tool coordinate system.
[0098] In some embodiments, the transformation from the rotary table coordinate system to the machine tool coordinate system is given by the forward kinematics solution, and its inverse transformation is achieved by transposing the rotation matrix and reversing the sign of the translation vector. The transformation result is written to the workpiece coordinate system register of the CNC system, and after writing, it is read back for verification. If the readback value is inconsistent, it is rewritten.
[0099] The transformation of the workpiece origin is given by equation (17):
[0100] ; (17)
[0101] In equation (17), The coordinates of the workpiece origin in the drawing coordinate system are in millimeters. The coordinates of the workpiece origin in the machine tool coordinate system are in millimeters. , The rotation matrix and translation vector are used to transfer the coordinates from the drawing coordinate system to the machine tool coordinate system. The coordinates of the workpiece origin in the rotary table coordinate system are in millimeters. , for shaft and The homogeneous transformation matrix of the inverse axis transformation is a dimensionless matrix.
[0102] According to the visual tool setting method based on CAD drawing features in this application, the nominal distance and tolerance of features in the CAD drawing are used as the only dimensional reference. The correspondence between the drawing coordinates and the image coordinates simultaneously provides the pixel equivalent, replacing the calibration plate and offline calibration. The tool setting accuracy is updated according to the correspondence between the drawing and the image. The projection position and rotation radius of the rotation axis are fitted by the trajectory circle of each feature image point when rotating with a fixed step distance on the C-axis. The geometric parameters of the turntable are directly excited by the movement of the machine tool itself. The depth missing by the monocular camera is closed by a single mechanical touch, avoiding feature-by-feature contact and dedicated instruments. The workpiece origin is anchored to the turntable coordinate system by rigid body transformation solved by three-dimensional feature coordinates and three-dimensional coordinate measurement values. The coordinates written into the CNC system are still valid after the turntable rotates. Confidence assessment, automatic correction and full feature retesting provide comparable criteria before writing, so that the tool setting result is changed from invisible pixel calculation to verifiable coordinate output.
[0103] According to some embodiments of this application, the initial image is detected. Among the features that can be detected The sub-pixel coordinates of each feature, the The two-dimensional coordinates of each feature in the drawing coordinate system and the... The steps include steps S121 to S126: establishing a correspondence between the sub-pixel coordinates of each feature, solving the parameters of the two-dimensional similarity transformation of the correspondence using a random sampling consensus method, and eliminating erroneous correspondences.
[0104] In step S121, detection is performed in the initial image. Among the features that can be detected Features and extract The subpixel coordinates of each feature in the initial image.
[0105] In some embodiments, the detection is assigned operators based on feature type: for hole features, the sub-pixel center is fitted within a local window using the integer pixel center as the initial value; for corner points, the corner response maxima are used for localization, and sub-pixel interpolation is performed in the neighborhood; for straight line contour points, the sub-pixel position is fitted using the edge normal gray-level gradient. Detection results are paired with drawing features according to type, with holes paired only with holes and corner points paired only with corner points.
[0106] Sub-pixel coordinates are defined according to equation (18):
[0107] (18)
[0108] In equation (18), For the first The coordinates of each detection result in the image, in pixels; , It consists of two components, measured in pixels; the detection accuracy is typically better than 0.3 pixels.
[0109] In step S122, For each feature, establish a correspondence between its two-dimensional coordinates in the drawing coordinate system and its sub-pixel coordinates in the initial image. Correspondence.
[0110] In some embodiments, the correspondence is established with the drawing feature number as the index: each drawing feature is paired with at most one detection result of the same type. The initial value is taken first according to the principle of closest distance, and then the back-substitution verification is performed according to formula (4); the drawing features that fail to be paired are recorded in the undetected set and do not participate in the subsequent similarity transformation.
[0111] In step S123, using two-dimensional similarity transformation as a model, from For each pair of correspondences, at least two pairs are randomly selected to solve for the candidate parameters of the two-dimensional similarity transformation.
[0112] In some embodiments, at least two pairs of correspondences can be randomly selected to determine the four degrees of freedom of the similarity transformation, namely the two components of scaling, rotation and translation. The selection is carried out without replacement. If the distance between the two pairs of correspondences is too small, the solution is unstable. A minimum baseline constraint is set during the selection.
[0113] Two-dimensional similarity transformation is expanded according to equation (19):
[0114] , (19)
[0115] In equation (19), To predict subpixel coordinates, in pixels; This is a scaling factor, measured in millimeters per pixel; The rotation angle is expressed in radians. This is a translation vector, with units of pixels; These are coordinates on the drawing, in millimeters. It is a two-dimensional rotation matrix, and it is a dimensionless matrix.
[0116] In step S124, based on the candidate parameters, The two-dimensional coordinates of each feature in the drawing coordinate system are projected onto the initial image to obtain the predicted sub-pixel coordinates of the feature, and the deviation between the predicted sub-pixel coordinates and the sub-pixel coordinates of the feature is compared with a preset deviation threshold.
[0117] In some embodiments, the deviation is calculated according to formula (4), and the deviation threshold is 2.0 pixels by default. If the threshold is too small, the correct correspondence will be judged as an outside point, and if it is too large, the mismatch will be let go. The actual value is calibrated according to the image noise level.
[0118] In step S125, correspondences with deviations less than or equal to the deviation threshold are identified as interior points, and correspondences with deviations greater than the deviation threshold are identified as erroneous correspondences and discarded.
[0119] In some embodiments, the determination of interior points and exterior points is performed pairwise, and the determination result is recorded in the interior point set; the eliminated exterior points no longer participate in parameter solving, but are still retained in the log for reference in the tool setting report of step S270.
[0120] In step S126, the two-dimensional similarity transformation is repeated as the model, from... The steps of randomly selecting at least two pairs of correspondences from the correspondences and solving for candidate parameters of the two-dimensional similarity transformation are continued until a pre-set termination condition is met. The candidate parameter with the largest number of corresponding interior points is determined as the parameter of the two-dimensional similarity transformation, and the set of interior points corresponding to the candidate parameter with the largest number of interior points is determined as the interior point set.
[0121] In some embodiments, the termination condition is the maximum number of iterations or no longer increasing the number of interior points; the candidate parameter with the most interior points wins; if multiple sets of parameters have the same number of interior points, the set with the smaller sum of squared residuals is selected to ensure the result is determined.
[0122] According to some embodiments of this application, the step of calculating the scaling factor between the pixel distance and the actual size of the workpiece based on the pixel distance, nominal distance and corresponding tolerance of the feature pairs selected in the set of interior points includes steps S131 to S134.
[0123] In step S131, features are selected pairwise from the interior point set and combined to obtain... For feature pairs, greater than or equal to 1 and less than or equal to 1 Integers.
[0124] In some embodiments, feature pairs are combined pairwise from features of the interior point set, and the number of combinations is subject to... Upper limit constraint: When selecting features, priority is given to feature pairs that span a large field of view, so that the constraint of pixel distance on the scaling factor is stronger.
[0125] The pixel distance between feature pairs is calculated according to equation (20):
[0126] (20)
[0127] In equation (20), , These are the sub-pixel coordinates of the two features, in pixels; The distance is in pixels; It is the Euclidean norm.
[0128] In step S132, for each pair of features, the pixel distance between the two features in the initial image is calculated based on their sub-pixel coordinates; and the nominal distance between the two features in the feature map is read.
[0129] In some embodiments, pixel distance is calculated as the Euclidean norm of the difference between the sub-pixel coordinates of two features; nominal distance is read from the edge attribute of the feature map, and if the feature pair has no direct edge in the feature map, the nominal distance is obtained by accumulating the shortest path.
[0130] In step S133, the distance tolerance of the pair of features is synthesized by the root mean square based on the tolerance of the two features in the feature map; the reciprocal square of the distance tolerance of the pair of features is determined as the tolerance weight of the pair of features.
[0131] In some embodiments, the distance tolerance is synthesized from the root mean square of the individual tolerances of the two features; the tolerance weight is the inverse square of the synthesized tolerance, so that the high-precision feature pair has a higher weight in the regression.
[0132] The composite distance tolerance and tolerance weight are calculated according to formula (7), where, , The tolerances for the two features are in millimeters. For composite tolerances, the unit is millimeters; This represents the tolerance weight, expressed in units of 1 / square millimeter.
[0133] In step S134, with For each feature pair in the feature pair, the pixel distance, nominal distance, and tolerance weight are used as inputs, and the feature pairs are processed according to the tolerance weights. We perform a weighted regression on the ratio of pixel distance to nominal distance for feature pairs to calculate the scaling factor between pixel distance and actual workpiece size.
[0134] In some embodiments, weighted regression is solved using a linear model passing through the origin; after regression is completed, back-substitute pairwise, and feature pairs whose residuals exceed half of the strictest tolerance are removed and re-regressed until the feature pairs are stable or the number reaches the lower limit.
[0135] The scaling factor is calculated according to equation (6), where, This is a scaling factor, measured in millimeters per pixel; The nominal distance is in millimeters; other symbols are the same as before.
[0136] This embodiment reduces the regression variance of the scaling factor by limiting the number of feature pairs and prioritizing long baselines, thereby enabling regression observations to cover a larger distance range.
[0137] According to some embodiments of this application, priority is determined based on feature type from the... Select from the features Each candidate feature, for the The steps include steps S141 to S146: performing observability verification on candidate features, measuring candidate features that meet observability requirements in the attitude, and planning the B-axis swing angle and switching to the corresponding attitude measurement for candidate features that do not meet observability requirements.
[0138] In step S141, according to the feature type Each feature is assigned a priority, with the priority order from highest to lowest as follows: baseline features > high-precision holes > contour corner points > general contour points.
[0139] In some embodiments, within the same priority level, the order is arranged in ascending order of tolerance and lexicographical order of drawing position, so that the sorting result is independent of the input order; the priority level continues to be used when the substitute feature is replaced in step S210.
[0140] The priority weights determined according to the feature type are calculated using equation (21):
[0141] (twenty one)
[0142] In equation (21), For the first The priority weights of each feature are dimensionless quantities. The tolerance for this feature is expressed in millimeters; sorting is done using type order as the primary key. The descending order is the second key.
[0143] In step S142, according to priority from high to low, from Select from the features One candidate feature.
[0144] In some embodiments, features are retrieved sequentially according to priority until a certain value is reached. indivual; The default value is 4 to 6. Using the upper limit takes into account computational redundancy, while using the lower limit takes into account tool setting time; insufficient... The system outputs a message indicating insufficient measurable features.
[0145] In step S143, for each candidate feature, the workpiece surface unit normal vector and the optical axis reverse unit vector of the monocular camera device in the current posture are obtained, and the cosine of the angle between the workpiece surface unit normal vector and the optical axis reverse unit vector is calculated.
[0146] In some embodiments, the unit normal vector of the workpiece surface is determined by the drawing feature type: top surface is taken as... Bottom surface The side profile is normal to the outer contour; the reverse unit vector of the optical axis is determined by the principal axis attitude and the camera mounting angle.
[0147] The cosine of the included angle is calculated according to the criterion in equation (8), where, Let be the unit normal vector of the workpiece surface at the feature point, which is a dimensionless quantity; It is the unit vector in the opposite direction of the optical axis, and it is a dimensionless quantity; The angle between the two is expressed in radians.
[0148] In step S144, if the cosine of the included angle is greater than or equal to the cosine of the preset maximum allowable observation angle, and the sub-pixel coordinates of the candidate feature in the initial image are within the field of view of the monocular camera, the candidate feature is determined to be observable, and the candidate feature is measured in this posture.
[0149] In some embodiments, the maximum observation angle is allowed to be 45° by default, i.e., the cosine is not less than 0.707; the field of view is calculated based on the imaging range of the camera in the current posture, and the feature projection is considered observable only if it falls within it.
[0150] In step S145, if the cosine of the included angle is less than the cosine of the maximum allowed observation angle, or if the sub-pixel coordinates of the candidate feature in the initial image are not within the field of view, it is determined that the candidate feature does not meet the observability requirement. Within the travel limit of the B-axis, a swing angle is planned for the candidate feature, and the candidate feature is transferred to the posture corresponding to the swing angle for measurement.
[0151] In some embodiments, the swing angle is searched within the B-axis travel limit with a fixed step size to find the feasible angle that maximizes the cosine of the included angle; the planning result is written into the "Attitude-Feature" allocation table, and the attitude is changed according to the table during measurement.
[0152] In step S146, at If none of the candidate features can find a feasible swing angle within the travel limit of the B-axis, the output feature cannot be reached prompt.
[0153] In some embodiments, the feature unreachable prompt includes the feature number, current posture and required posture. After output, the tool setting process is terminated, and the user is left to adjust the clamping or add features to the drawing.
[0154] This embodiment determines the selection result of candidate features by fixing the priority order and the lexicographical order when they are listed in parallel, so that the selection result does not change with the order of drawing analysis.
[0155] According to some embodiments of this application, the C-axis is rotated to multiple angles with a fixed step size, and images are acquired at each angle to form the... The steps include steps S151 to S158: obtaining the center coordinates and radius of the fitted circle for each candidate feature's image point trajectory sequence, performing circle fitting on each image point trajectory sequence, determining the center coordinates of the fitted circle as the projection position of the C-axis rotation axis in the image, and determining the radius of the fitted circle as the pixel distance from the candidate feature to the rotation axis.
[0156] In step S151, the C-axis is rotated within a set range at a fixed step distance. Images of the workpiece are acquired from each angle using a monocular camera. Frame image, It is an integer greater than or equal to 3.
[0157] In some embodiments, the C-axis rotates a full revolution in fixed increments of 30°. Take 12; the step distance and angle number are determined according to the rotary table resolution and tool setting time. Not less than 3.
[0158] No. Each collection angle The axial angle is determined according to formula (22):
[0159] , (twenty two)
[0160] In equation (22), For the first Each collection angle Axial angle, in radians; Fixed step size, unit: radians; The value is the angle, and it should be an integer greater than or equal to 3.
[0161] In step S152, for For each of the candidate features, In each frame of the image, the sub-pixel coordinates of the candidate feature are detected, and the sub-pixel coordinates are sorted according to... The image point trajectory sequence of the candidate feature is formed by arranging the angles in sequence.
[0162] In some embodiments, each frame image is detected only within a neighborhood window of the candidate features, and the window size is determined according to the estimated image point displacement; the detection results are arranged into a sequence in angular order, and the angles that are not detected are marked in the sequence and skipped.
[0163] In step S153, the first least squares circle fitting is performed on the trajectory sequence of each image point to obtain a preliminary fitted circle.
[0164] In some embodiments, the first fitting uses all image points, and the initial value replaces the result of the circular fitting; before fitting, obviously outlier image points are removed to avoid the initial value being skewed by gross errors.
[0165] The first least squares circle fitting is solved according to equation (9), where all symbols are the same as before. The fitting output is the center of the preliminary fitted circle. With radius All units are pixels.
[0166] In step S154, the distance from each sub-pixel coordinate in the image point trajectory sequence of the candidate feature to the preliminary fitting circle is calculated, which is used as the fitting residual of the sub-pixel coordinate.
[0167] In some embodiments, the absolute value of the difference between the distance from the image point of the fitted residual to the center of the initial fitted circle and the radius is used. The residuals are recorded in angular order for the tool setting report statistics in step S270.
[0168] Image point residuals are calculated according to formula (10), where in the formula... Take the center of the initially fitted circle With radius In the formula, For the first The coordinates of an image point are in pixels. The residuals are for fitting, and the unit is pixels.
[0169] In step S155, sub-pixel coordinates with fitting residuals exceeding a preset residual threshold are removed to obtain the remaining sub-pixel coordinates.
[0170] In some embodiments, the residual threshold is set to 0.5 pixels by default; pixels with residuals exceeding the threshold are judged as occluded or falsely detected, and after removal, there are no less than 3 remaining pixels; otherwise, the angle sequence is re-acquired.
[0171] In step S156, a second least-squares circle fitting is performed on the remaining sub-pixel coordinates to obtain the center coordinates and radius of the refined fitted circle.
[0172] In some embodiments, the second fitting uses only the remaining image points, and the initial values are the center and radius of the circle from the first fitting; after the fitting converges, the refined center and radius are obtained.
[0173] In step S157, the coordinates of the center of the refined fitted circle are determined as the rotation axis of the C-axis. The projection position in the frame image.
[0174] In some embodiments, the refined center, i.e., the projection position of the C-axis rotation axis, in the set of images is determined; the projection positions of each candidate feature under the same camera pose should be consistent, and its dispersion can serve as evidence of data quality.
[0175] In step S158, the radius of the refined fitted circle is determined as the pixel distance from the candidate feature to the axis of rotation.
[0176] In some embodiments, the refinement radius is the pixel distance from the feature to the rotation axis; the radius varies with the position of the feature on the turntable, and the rotation radius is calculated by a scaling factor in step S160.
[0177] This embodiment provides an equally spaced angle sequence through the machine tool encoder, making the sampling interval of the image point trajectory known, and the geometric constraints for circle fitting are directly provided by the machine tool motion.
[0178] According to some embodiments of this application, the steps of obtaining the rotation radius of the candidate feature based on the scaling factor and the pixel distance of the candidate feature to the rotation axis, and determining the two-dimensional offset vector of the candidate feature in the turntable coordinate system based on the rotation radius and the projection position, include steps S161 to S168.
[0179] In step S161, the scaling factor is multiplied by the pixel distance from the candidate feature to the rotation axis to obtain the rotation radius of the candidate feature to the C-axis.
[0180] In some embodiments, the scaling factor is the solution from step S130, and the pixel distance is the radius of the refined fitting circle from step S150; the two are multiplied together to obtain the radius of gyration, with the unit being millimeters per pixel multiplied by the pixel to obtain millimeters.
[0181] The radius of gyration is calculated according to formula (11), where, Radius of gyration, in millimeters; This is a scaling factor, measured in millimeters per pixel; The radius of the refined fitted circle is in pixels.
[0182] In step S162, at The image at the first angle and the image at the second angle are selected from the frame image. The difference between the first angle and the second angle is 90 degrees.
[0183] In some embodiments, the first angle and the second angle differ by 90°, and the two frames are indexed by angle from... The frame is selected, and the index is determined by encoder readings, not by image estimation.
[0184] In step S163, for each candidate feature, the first azimuth angle of the sub-pixel coordinates of the candidate feature relative to the projection position is determined in the image at the first angle, and the second azimuth angle of the sub-pixel coordinates of the candidate feature relative to the projection position is determined in the image at the second angle.
[0185] In some embodiments, the polar angle of the azimuth angle image point relative to the projection position is taken with the X-axis of the turntable coordinate system as the polar axis and counterclockwise as positive; the azimuth angles of the two frames of images are calculated and recorded respectively.
[0186] The azimuth angle of the projection position of the feature image point relative to the axis of rotation is calculated according to formula (23):
[0187] (twenty three)
[0188] In equation (23), This is the azimuth angle, in radians; , These are the two components of the image point coordinates in this frame, in pixels; , The coordinates of the projected position obtained from equation (9) are in pixels; It is the arctangent function in the four quadrants.
[0189] In step S164, the difference between the second azimuth angle and the first azimuth angle is determined as the azimuth angle difference.
[0190] In some embodiments, the azimuth difference is taken as the second azimuth minus the first azimuth; the difference is normalized to the rotation direction. Use intervals to avoid jumps across weeks.
[0191] The azimuth difference is calculated according to formula (12), where, , These are the first and second azimuth angles, in radians; The difference in azimuth is expressed in radians.
[0192] In step S165, if the absolute value of the deviation between the azimuth angle difference and 90 degrees is less than or equal to a preset angle threshold, the first azimuth angle is determined as the azimuth angle of the candidate feature in the turntable coordinate system.
[0193] In some embodiments, the angle threshold is set to 2° by default; when the absolute value of the deviation does not exceed the threshold, the rotation angle is considered to be consistent with the encoder, and the first azimuth angle is taken as the azimuth angle of the feature in the turntable coordinate system.
[0194] The verification condition is executed according to the criterion in equation (12), where, This is the angle threshold, in radians, with a default value of 2°.
[0195] In step S166, if the absolute value of the deviation between the azimuth angle difference and 90 degrees is greater than the angle threshold, the image of the candidate feature is re-acquired at the first angle and the second angle.
[0196] In some embodiments, if the verification fails, the two frames of images are reacquired and the azimuth angle is recalculated; if the consecutive failures exceed the retry limit, the process is terminated and a diagnostic list is output.
[0197] In step S167, the product of the radius of rotation and the cosine of the azimuth angle is determined as the first component of the two-dimensional offset vector.
[0198] In some embodiments, the first component is along the X-axis of the turntable coordinate system, and is the product of the radius of rotation and the cosine of the azimuth angle, in millimeters.
[0199] The first component of the two-dimensional offset vector is calculated according to equation (11), where, The first component is in millimeters; the other symbols are the same as before.
[0200] In step S168, the product of the radius of rotation and the sine of the azimuth angle is determined as the second component of the two-dimensional offset vector.
[0201] In some embodiments, the second component is taken along the Y-axis of the turntable coordinate system as the product of the radius of rotation and the sine of the azimuth angle; the two components are combined to form a two-dimensional offset vector. .
[0202] The second component of the two-dimensional offset vector is calculated according to equation (11), where, This is the second component, in millimeters; the other symbols are the same as before.
[0203] This embodiment converts the pixel radius into the actual radius of rotation by using a scaling factor, so that the same set of scaling factors can be used for both scale calibration and geometric calculation.
[0204] According to some embodiments of this application, the steps of calculating the Z-axis coordinate of each candidate feature in the machine tool coordinate system based on the system deviation determined by the tactile method, and obtaining the three-dimensional coordinate measurement value of each candidate feature in the machine tool coordinate system based on the Z-axis coordinate and the two-dimensional offset vector of the corresponding candidate feature, include steps S171 to S177.
[0205] In step S171, the monocular camera device... For each candidate feature among the candidate features, visual height is determined to obtain the top surface of that candidate feature. Estimated value.
[0206] In some embodiments, visual elevation is determined by the peak value of the sharpness evaluation function to determine the top surface. The estimated value is obtained by taking the image gradient energy or Laplacian variance as the evaluation function, and the peak search is performed in 0.01 mm steps within a set interval.
[0207] Visual features of the top surface The estimated value is calculated according to formula (24):
[0208] (twenty four)
[0209] In equation (24), For the visual of the feature top surface Estimated value, in millimeters; For the peak resolution Coordinates, in millimeters; The specified working distance is in millimeters.
[0210] In step S172, the machine tool's probe or tool setting block... Mechanical touch testing is performed on the top surface of any candidate feature among the candidate features, and the machine tool at the time of touch testing is recorded. Coordinate readings.
[0211] In some embodiments, mechanical contact testing is performed by a probe or a tool setting block, with the contact point taken from the top surface of any candidate feature; the contact speed is set according to the machine tool's allowable detection speed, and the data is recorded after the contact test. Coordinate readings.
[0212] In step S173, the machine tool The top surface of the candidate feature targeted by coordinate readings and mechanical touch. The difference between the estimated values is determined as the systematic bias.
[0213] In some embodiments, the system bias is taken as the difference between the touch reading and the top surface of the touch-sensitive feature. The difference in estimated values; under the same clamping conditions, this deviation is the same for all features, requiring only one touch test.
[0214] System deviation is calculated according to formula (13), where, This is the systematic deviation, in millimeters; For mechanical touch testing Coordinate readings, in millimeters; The visual top surface of the touched feature Estimated value, in millimeters.
[0215] In step S174, the system deviation is used to... The top surface of each candidate feature among the candidate features The estimated value is compensated to obtain The Z-coordinate of each candidate feature in the machine tool coordinate system.
[0216] In some embodiments, compensation is performed separately for each candidate feature: by adding top surface with systematic bias. The estimated value is the Z-coordinate of the feature in the machine tool coordinate system.
[0217] After compensation The coordinates are calculated according to equation (13), where, For the first Features Coordinates, in millimeters; For the visual top surface of this feature Estimated value, in millimeters.
[0218] In step S175, for each candidate feature, according to the forward kinematics of the machine tool, the two-dimensional offset vector of the candidate feature in the rotary table coordinate system is converted into the two-dimensional offset vector of the candidate feature in the machine tool coordinate system. Components and Quantity.
[0219] In some embodiments, the coordinates of the turntable are determined according to the forward kinematics. Transforming to the machine tool coordinate system, the first two components are... Quantity and Quantity; , The angle is taken from the encoder reading at the moment of measurement.
[0220] , The components are given by the forward kinematics of equation (1), taking The first two components; in the formula, , for shaft and Axial angle, in radians; , is a homogeneous transformation matrix, and is a dimensionless matrix; , These are the two components of a two-dimensional offset vector, measured in millimeters.
[0221] In step S176, the Z-axis coordinate of the candidate feature in the machine tool coordinate system is used as the three-dimensional coordinate measurement value of the candidate feature. Quantity.
[0222] In some embodiments, The component directly takes the compensated Z-axis coordinate, without further kinematic forward rotation, to ensure that the Z-axis is strictly consistent with the touch reference.
[0223] In step S177, according to Quantity, Components and The components are used to obtain the three-dimensional coordinate measurement value of the candidate feature in the machine tool coordinate system.
[0224] In some embodiments, Quantity, Quantity and The components are synthesized into three-dimensional coordinate measurement values in the order of the machine tool coordinate system coordinate axes, and used as elements of the second point set in step S180.
[0225] The three-dimensional coordinate measurement values are synthesized according to formula (14), where, For the first The three-dimensional coordinates of each feature are measured in millimeters. , for Quantity and Quantity, in millimeters; After compensation The coordinates are in millimeters.
[0226] This embodiment converts visual height into the principal axis by using the sharpness peak. Coordinate readings allow the visual height setting and machine tool coordinates to share the same ruler.
[0227] According to some embodiments of this application, based on the feature map... The three-dimensional feature coordinates of the candidate features after dimensionality upgrading and the... The steps of solving the rigid body transformation by taking the three-dimensional coordinate measurement values of candidate features and using the rigid body transformation as the transformation from the drawing coordinate system to the machine tool coordinate system include steps S181 to S186.
[0228] In step S181, for For each candidate feature among the candidate features, obtain the two-dimensional coordinates and Z-direction assignment of the candidate feature in the feature map, wherein the Z-direction assignment includes at least one of top surface, bottom surface, and through surface.
[0229] In some embodiments, the Z-direction is assigned during the parsing in step S110, and can be the top surface, bottom surface, or through surface; the through surface feature is the end whose height is consistent with the measurement surface among the two end surfaces.
[0230] The upgraded three-dimensional feature coordinates are given by equation (3), where, These are three-dimensional feature coordinates, in millimeters. , The coordinates of the drawing are in two dimensions, in millimeters. for The coordinates are in millimeters.
[0231] In step S182, according to the Z-axis attribution, the candidate feature is assigned a Z-axis coordinate in the drawing coordinate system.
[0232] In some embodiments, the top surface feature is taken as the top surface annotation height, the bottom surface feature is taken as the bottom surface annotation height, and the through-feature is taken as one of the heights of the two end surfaces; the Z-axis assignment of the same feature in different processes can be configured.
[0233] In step S183, the two-dimensional coordinates of the candidate feature in the feature map and the assigned Z-axis coordinates are combined to obtain the three-dimensional feature coordinates of the candidate feature in the drawing coordinate system.
[0234] In some embodiments, the two-dimensional coordinates and the Z-axis coordinates are combined to form three-dimensional feature coordinates, which are used as elements of the first point set; when combined, the feature number corresponds one-to-one with the measured value.
[0235] In step S184, the three-dimensional feature coordinates of each candidate feature in the drawing coordinate system are taken as the first point set, and the three-dimensional coordinate measurement values of each candidate feature in the machine tool coordinate system are taken as the second point set. An objective function is constructed that minimizes the sum of squared Euclidean distances between the first point set and the second point set after rotation and translation.
[0236] In some embodiments, the objective function is the sum of the squared Euclidean distances between the first point set and the second point set after rotation and translation; the two point sets are paired according to feature numbers, and features that do not participate in the tool matching do not enter the point set.
[0237] The objective function is defined according to equation (25):
[0238] (25)
[0239] In equation (25), is a rotation matrix, and is a dimensionless matrix; This is a translation vector, in millimeters; , For the corresponding points in the first and second point sets, the unit is millimeters; summation traversal. One candidate feature.
[0240] In step S185, the objective function is solved with the rotation matrix being an orthogonal matrix and its determinant being positive 1 as a constraint, resulting in the rotation matrix and translation vector. The solution includes: calculating the centroids of the first and second point sets; constructing a cross-covariance matrix based on the centroid-free first and second point sets; performing singular value decomposition on the cross-covariance matrix to obtain the rotation matrix; and calculating the translation vector based on the rotation matrix, the centroids of the first and second point sets.
[0241] In some embodiments, the closed-form solution is divided into three steps: first, find the centroids of the two point sets and remove the centroids; then, construct the cross-covariance matrix and perform singular value decomposition; finally, assemble the rotation matrix from the decomposition results and calculate the translation vector according to the centroids.
[0242] The cross-covariance matrix and the closed-form solution are given by equation (16), where, The cross-covariance matrix is in square millimeters. , , for The singular value decomposition results; , Here are the rotation matrix and translation vector; , Let be the centroid of the two point sets, in millimeters.
[0243] In step S186, the rotation matrix and translation vector are determined as the transformation from the drawing coordinate system to the machine tool coordinate system.
[0244] In some embodiments, the rotation matrix and translation vector are combined to transform the drawing coordinate system to the machine coordinate system; this transformation is used in step S190, and its root mean square residual is used as a confidence index in step S210.
[0245] This embodiment uses Z-axis attribution to upgrade the features of two-dimensional drawings, enabling rigid body transformations to have solutions in three-dimensional space.
[0246] According to some embodiments of this application, the step of transforming the workpiece origin to the rotary table coordinate system according to the transformation from the drawing coordinate system to the machine tool coordinate system, and obtaining the coordinates of the workpiece origin in the rotary table coordinate system, includes steps S191 to S194.
[0247] In step S191, the coordinates of the workpiece origin in the drawing coordinate system are obtained.
[0248] In some embodiments, the workpiece origin is taken as a point with technological significance on the drawing, usually the center of a hole or the intersection of contours; the coordinates of the origin are read directly from the drawing, and the unit is millimeters.
[0249] The coordinates of the workpiece origin in the drawing coordinate system are expressed by formula (26):
[0250] (26)
[0251] In equation (26), The coordinates of the workpiece origin in the drawing coordinate system are in millimeters. , The coordinates of the workpiece origin as marked on the drawing, in millimeters; The surface where the workpiece origin is located The coordinates are in millimeters.
[0252] In step S192, the coordinates of the workpiece origin in the drawing coordinate system are transformed into the coordinates of the workpiece origin in the machine tool coordinate system according to the transformation from the drawing coordinate system to the machine tool coordinate system.
[0253] In some embodiments, the workpiece origin is transformed to the machine tool coordinate system by using a rotation matrix and a translation vector; the transformation is consistent with the rigid body transformation obtained in step S180.
[0254] The transformation of the workpiece origin to the machine tool coordinate system is calculated according to formula (17), where, The coordinates of the workpiece origin in the drawing coordinate system are in millimeters. The coordinates of the workpiece origin in the machine tool coordinate system are in millimeters. , The rotation matrix and translation vector are obtained by solving equation (15).
[0255] In step S193, the transformation from the rotary table coordinate system to the machine tool coordinate system is calculated based on the forward kinematics of the machine tool.
[0256] In some embodiments, the transformation from the rotary table coordinate system to the machine tool coordinate system is given by the forward kinematics, and the forward kinematics matrix is defined according to the measurement time. , Angle calculation.
[0257] In step S194, the coordinates of the workpiece origin in the machine tool coordinate system are transformed into the coordinates of the workpiece origin in the rotary table coordinate system according to the inverse transformation from the rotary table coordinate system to the machine tool coordinate system.
[0258] In some embodiments, the machine tool coordinates are transformed to the rotary table coordinate system by inverse transformation: the rotation matrix is transposed and the translation vector is reversed; the result is written into the CNC system and read back for verification.
[0259] The inverse transformation to the turntable coordinate system is calculated according to equation (17), where, The coordinates of the workpiece origin in the rotary table coordinate system are in millimeters. , for shaft and The homogeneous transformation matrix of the inverse axis transformation is a dimensionless matrix.
[0260] This embodiment explicitly reads the workpiece origin, making the coordinate system establishment result directly correspond to the drawing annotation.
[0261] According to some embodiments of this application, after transforming the workpiece origin to the rotary table coordinate system according to the transformation from the drawing coordinate system to the machine tool coordinate system, and before writing the coordinates of the workpiece origin in the rotary table coordinate system into the CNC system of the machine tool, the method further includes steps S210 to S260.
[0262] In step S210, the confidence level of the transformation from the drawing coordinate system to the machine tool coordinate system is evaluated based on the interior point rate of the interior point set and the root mean square residual of the transformation from the drawing coordinate system to the machine tool coordinate system.
[0263] In some embodiments, confidence assessment uses two metrics: the interior point ratio reflects the quality of coarse matching, and the root mean square residual reflects the degree of consistency between the rigid body transformation and the measured value; both metrics must be satisfied simultaneously for the assessment to be considered successful.
[0264] The confidence criterion is given by equation (27):
[0265] ; (27)
[0266] In equation (27), is the interior point law, and is a dimensionless quantity; For interior points; This represents the total number of corresponding relationships involved in the matching process. The root mean square residual is expressed in millimeters. , The rotation matrix and translation vector obtained from equation (15); The characteristic number used in residual statistics; This is the in-point ratio threshold, with a default value of 0.9; This is the residual threshold, in millimeters, set to 1 / 3 of the strictest tolerance.
[0267] In step S220, if the inlier rate is greater than or equal to a preset inlier rate threshold and the root mean square residual is less than or equal to a preset residual threshold, the confidence assessment is deemed to have passed.
[0268] In some embodiments, a pass is determined when both indicators are met simultaneously; a fail is determined when either indicator is not met, and the process proceeds to the correction process in step S230.
[0269] In step S230, if the inlier rate is less than the inlier rate threshold or the root mean square residual is greater than the residual threshold, the confidence assessment is deemed unsuccessful. Automatic correction is then performed in the following order: first, replacing candidate features; then, reducing the distance between the monocular camera and the workpiece and re-acquiring the image. The confidence assessment is repeated if the number of corrections does not exceed a pre-set retry limit. If the number of corrections exceeds the retry limit, the process terminates and a diagnostic list is output. Replacing candidate features includes: from... The feature that was not selected is Among the candidate features, substitute features are selected in descending order of priority to replace them. At least one of the candidate features.
[0270] In some embodiments, the correction is performed in the order of first replacing candidate features, then reducing the working distance and retaking the image; replacing candidate features starts from... Not selected among the features Among the candidate features, replacements are made according to priority, and the default maximum number of retries is 3.
[0271] The constraint on the number of corrections is given by equation (28):
[0272] (28)
[0273] In equation (28), This represents the number of corrections that have been performed. This is the maximum number of retries, set to 3 by default. and All are dimensionless quantities.
[0274] In step S240, if the confidence assessment passes, all selected features are retested, the Euclidean distance between the three-dimensional coordinate measurements of the two features in each feature pair is calculated as the measured distance of the feature pair, and the maximum deviation between the measured distance of each feature pair and the nominal distance in the feature map is calculated.
[0275] In some embodiments, the retest is performed on all selected features, and the difference between the measured distance and the nominal distance is calculated for each pair. The one with the largest absolute value is taken as the acceptance index. The measured distance is calculated according to the Euclidean distance of the three-dimensional coordinate measurement value.
[0276] In step S250, if the maximum deviation is less than or equal to the preset acceptance threshold, the retest is deemed to have passed, and the coordinates of the workpiece origin in the rotary table coordinate system are written into the CNC system of the machine tool.
[0277] In some embodiments, the acceptance threshold is set to half of the free tolerance of the drawing by default; when the maximum deviation does not exceed the threshold, the acceptance is deemed to be passed, and the coordinates of the workpiece origin in the rotary table coordinate system are written into the CNC system.
[0278] The acceptance criteria are given according to formula (29):
[0279] (29)
[0280] In equation (29), The maximum deviation is expressed in millimeters. , These are the three-dimensional coordinate measurements of the two features, in millimeters. The nominal distance between the two features, in millimeters; This is the acceptance threshold, in millimeters, and is set to half of the free tolerance by default.
[0281] In step S260, if the maximum deviation is greater than the acceptance threshold, the retest is deemed unacceptable. The coordinates of the workpiece origin in the rotary table coordinate system are not written into the CNC system of the machine tool. A residual list is output, which includes the feature pair with the largest deviation, the deviation value, and the possible cause.
[0282] In some embodiments, the residual list lists the feature pairs with the largest deviations, the deviation values, and possible causes; possible causes include feature contamination, loose clamping, and mismatch between drawings.
[0283] This embodiment evaluates matching quality and solution quality separately using dual criteria, ensuring that erroneous results are not allowed if a single indicator is occasionally met.
[0284] According to some embodiments of this application, the method further includes step S270.
[0285] In step S270, a tool setting report is generated. The tool setting report includes a feature table, confidence index, and calibration results. The feature table includes... The features involved in tool setting include the feature type, the two-dimensional coordinates of the feature in the feature map, and the three-dimensional coordinates of the feature in the machine tool coordinate system. Confidence indicators include the interior point rate of the interior point set, the root mean square residual of the transformation from the drawing coordinate system to the machine tool coordinate system, and the maximum deviation. The calibration results include the scaling factor and the systematic deviation.
[0286] In some embodiments, the knife report is generated with structured data, which can be displayed on the interactive interface or archived for traceability; each entry is output in groups according to features, confidence level and calibration results.
[0287] This embodiment uses a structured report to fix the data and criteria of the tool setting process, making the results verifiable and archiveable.
[0288] This application also provides a machine tool. The following will be combined with... Figure 2 The machine tool is described in detail.
[0289] Figure 2 A schematic diagram of the structure of a machine tool according to an embodiment of this application is shown.
[0290] like Figure 2 As shown, the machine tool 100 includes a machine tool body 101, a spindle 110, a rotary table 120, a monocular camera device 130, a tool holder type extension rod 140, and a numerical control system 150.
[0291] The machine tool body 101 is the load-bearing and foundational component of the machine tool 100, including the bed, column, and guide rails for each feed axis, providing an installation reference for the spindle 110 and rotary table 120. The machine tool body 101 is provided with a drive and guide structure that enables the spindle 110 to make linear feeds along the X-axis, Y-axis, and Z-axis of the machine tool 100, and also provides a routing space for the monocular camera device 130 to move with the spindle 110.
[0292] The spindle 110 is mounted on the machine tool body 101 and is configured to perform linear feed along the X-axis, Y-axis and Z-axis of the machine tool 100. The front end of the spindle 110 is provided with a tool holder interface, the type of which is the same as that of the tool holder type connector 140, so that the spindle 110 can clamp both cutting tools and monocular camera device 130.
[0293] A rotary table 120 is mounted on the machine tool body 101 and is used to clamp and rotate the workpiece. The rotary table 120 includes a B-axis 121 and a C-axis 122. The B-axis 121 is arranged around the Y-axis of the machine tool 100 and is located below it. The C-axis 122 is arranged around the Z-axis of the machine tool 100 and is mounted on the B-axis 121. The C-axis 122 tilts as the B-axis 121 rotates. The clamping surface of the workpiece is located on the C-axis 122, and the orientation of the workpiece is determined by the coordinate readings of the C-axis 122 and the B-axis 121.
[0294] The monocular camera device 130 includes an imaging lens and an image sensor, which is clamped to the spindle 110 via a tool holder-type connecting rod 140. Its optical axis is coaxial with the axis of the spindle 110 and moves with the spindle 110 along the X, Y, and Z axes. The field of view of the monocular camera device 130 covers the area to be measured on the workpiece, and the acquired images are sent to the CNC system 150 via a communication connection. The position of the monocular camera device 130 is given by the coordinate readings of each axis of the spindle 110, and there is no need to separately calibrate the external parameters between the camera and the machine tool.
[0295] One end of the tool holder type connecting rod 140 is an interface consistent with the tool holder interface of the spindle 110, and the other end is fixedly connected to the monocular camera device 130, so that the monocular camera device 130 is clamped by the spindle 110 and grasped by the tool changer in the same way as the cutting tool. The axis of the tool holder type connecting rod 140 coincides with the optical axis of the monocular camera device 130, and after installation, the optical axis is coaxial with the axis of the spindle 110.
[0296] The CNC system 150 is communicatively connected to the spindle 110, the rotary table 120, and the monocular camera device 130, and is configured to execute the steps of the visual tool setting method based on CAD drawing features according to embodiments of this application. The CNC system 150 stores feature maps of the CAD drawing, coordinate readings of each axis, and kinematic parameters, and writes the coordinates of the workpiece origin obtained from tool setting in the rotary table coordinate system offset.
[0297] The technical effects of the machine tool according to the embodiments of this application are similar to the visual tool setting method based on CAD drawing features, and will not be described in detail here.
[0298] Those skilled in the art will understand that the features described in the various embodiments of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, the features described in the various embodiments of this application can be combined and / or combined in various ways without departing from the spirit and teachings of this application. All such combinations and / or combinations fall within the scope of this application.
Claims
1. A visual tool setting method based on CAD drawing features, characterized in that, The machine tool includes a machine body, a spindle, a rotary table, and a monocular camera device. The rotary table includes a B-axis and a C-axis. The C-axis is mounted on the B-axis and tilts as the B-axis rotates. The B-axis is positioned about the Y-axis of the machine tool, and the C-axis is positioned about the Z-axis of the machine tool. The spindle is configured to feed linearly along the X-axis, Y-axis, and Z-axis of the machine tool. The monocular camera device is clamped to the spindle via a tool holder-type connector. The interface of the tool holder-type connector is consistent with the tool holder interface of the spindle. The optical axis of the monocular camera device is coaxial with the axis of the spindle. The method includes: The imported CAD drawing is parsed, and M features of the CAD drawing and the nominal distance and tolerance between each pair of features are extracted to construct a feature map. The feature map includes nodes constructed based on the features and edges constructed based on the nominal distance and tolerance between each pair of features. M is an integer greater than or equal to 3. The initial image of the workpiece is acquired by the monocular camera device. The sub-pixel coordinates of N features that can be detected among the M features are detected in the initial image. A correspondence is established between the two-dimensional coordinates of the N features in the drawing coordinate system and the sub-pixel coordinates of the N features. The parameters of the two-dimensional similarity transformation of the correspondence are solved by the random sampling consensus method and erroneous correspondences are eliminated to obtain the interior point set, where N is an integer greater than or equal to 3 and less than or equal to M. Based on the pixel distance, nominal distance, and corresponding tolerance of the feature pairs selected in the in-point set, calculate the scaling factor between the pixel distance and the actual size of the workpiece; P candidate features are selected from the M features according to the priority determined by the feature type. The observability of the P candidate features is checked. The candidate features that meet the observability are measured in the attitude. The candidate features that do not meet the observability are planned with the B-axis swing angle and transferred to the corresponding attitude for measurement. P is an integer greater than or equal to 3 and less than or equal to M. The C-axis is rotated to multiple angles with a fixed step size, and images are acquired at each angle to form a sequence of image point trajectories for each of the P candidate features. Circle fitting is performed on each image point trajectory sequence to obtain the center coordinates and radius of the fitted circle for the candidate feature. The center coordinates of the fitted circle are determined as the projection position of the rotation axis of the C-axis in the image, and the radius of the fitted circle is determined as the pixel distance from the candidate feature to the rotation axis. The rotation radius of the candidate feature is obtained based on the scaling factor and the pixel distance from the candidate feature to the rotation axis. The two-dimensional offset vector of the candidate feature in the turntable coordinate system is determined based on the rotation radius and the projection position. Based on the system deviation determined by the touch test method, the Z-coordinate of each candidate feature in the machine tool coordinate system is calculated. Based on the Z-coordinate and the two-dimensional offset vector of the corresponding candidate feature, the three-dimensional coordinate measurement value of each candidate feature in the machine tool coordinate system is obtained. Based on the three-dimensional feature coordinates after dimensionality upgrade of the P candidate features in the feature map and the three-dimensional coordinate measurement values of the P candidate features, the rigid body transformation is solved, and the rigid body transformation is used as the transformation from the drawing coordinate system to the machine tool coordinate system. The workpiece origin is transformed to the rotary table coordinate system according to the transformation from the drawing coordinate system to the machine tool coordinate system, and the coordinates of the workpiece origin in the rotary table coordinate system are obtained. The coordinates of the workpiece origin in the rotary table coordinate system are then written into the CNC system of the machine tool.
2. The visual tool setting method based on CAD drawing features according to claim 1, characterized in that, The steps of detecting the sub-pixel coordinates of N detectable features out of the M features in the initial image, establishing a correspondence between the two-dimensional coordinates of the N features in the drawing coordinate system and the sub-pixel coordinates of the N features, solving the parameters of the two-dimensional similarity transformation of the correspondence using a random sampling consensus method, and eliminating erroneous correspondences to obtain the interior point set include: Detect N detectable features from the M features in the initial image, and extract the sub-pixel coordinates of each of the N features in the initial image; Establish a correspondence between the two-dimensional coordinates of each of the N features in the drawing coordinate system and the sub-pixel coordinates of the feature in the initial image, thus obtaining N pairs of correspondences; Using two-dimensional similarity transformation as a model, at least two pairs of correspondences are randomly selected from the N pairs of correspondences to solve for the candidate parameters of the two-dimensional similarity transformation; Based on the candidate parameters, the two-dimensional coordinates of each of the N features in the drawing coordinate system are projected onto the initial image to obtain the predicted sub-pixel coordinates of the feature, and the deviation between the predicted sub-pixel coordinates and the sub-pixel coordinates of the feature is compared with a preset deviation threshold. Correspondences with deviations less than or equal to the deviation threshold are identified as interior points, while correspondences with deviations greater than the deviation threshold are identified as erroneous correspondences and discarded. Repeat the steps of using two-dimensional similarity transformation as a model, randomly selecting at least two pairs of correspondences from the N pairs of correspondences, and solving for the candidate parameters of the two-dimensional similarity transformation until a pre-set termination condition is met. Then, determine the candidate parameter with the largest number of interior points as the parameter of the two-dimensional similarity transformation, and determine the set of interior points corresponding to the candidate parameter with the largest number of interior points as the set of interior points.
3. The visual tool setting method based on CAD drawing features according to claim 1, characterized in that, The step of calculating the scaling factor between the pixel distance and the actual size of the workpiece based on the pixel distance, nominal distance, and corresponding tolerance of the feature pairs selected from the inlier set includes: Features are selected from each pair of the inlier set and combined to obtain K feature pairs, where K is an integer greater than or equal to 1 and less than or equal to N; For each pair of features, the pixel distance between the two features in the initial image is calculated based on their sub-pixel coordinates; the nominal distance between the two features in the feature map is then read. Based on the tolerances of the two features in the feature graph, the distance tolerance of the feature pair is synthesized using the root mean square; the reciprocal square of the distance tolerance of the feature pair is determined as the tolerance weight of the feature pair. Using the pixel distance, nominal distance, and tolerance weight of each of the K feature pairs as input, a weighted regression is performed on the ratio of the pixel distance to the nominal distance of the K feature pairs according to the tolerance weight, and the scaling factor between the pixel distance and the actual size of the workpiece is calculated.
4. The visual tool setting method based on CAD drawing features according to claim 1, characterized in that, The steps include selecting P candidate features from the M features according to the priority determined by the feature type, performing observability verification on the P candidate features, measuring the candidate features that meet the observability requirements in the current attitude, and planning the B-axis oscillation angle and switching to the corresponding attitude measurement for the candidate features that do not meet the observability requirements. The M features are assigned priorities according to their feature types, wherein the priorities from high to low are: reference features > high-precision holes > contour corner points > general contour points. P candidate features are selected from the M features in descending order of priority. For each candidate feature, obtain the workpiece surface unit normal vector at the candidate feature and the optical axis reverse unit vector of the monocular camera device in the current posture, and calculate the cosine of the angle between the workpiece surface unit normal vector and the optical axis reverse unit vector. If the cosine of the included angle is greater than or equal to the cosine of the preset maximum allowable observation angle, and the sub-pixel coordinates of the candidate feature in the initial image are within the field of view of the monocular camera, then the candidate feature is determined to be observable, and the candidate feature is measured in this posture. If the cosine of the included angle is less than the cosine of the maximum allowable observation angle, or if the sub-pixel coordinates of the candidate feature in the initial image are not within the field of view, the candidate feature is determined to be unobservable. Within the travel limit of the B-axis, a swing angle is planned for the candidate feature, and the candidate feature is transferred to the posture corresponding to the swing angle for measurement. If none of the P candidate features can find a feasible swing angle within the travel limit of the B axis, an output feature unreachable prompt will be displayed.
5. The visual tool setting method based on CAD drawing features according to claim 1, characterized in that, The steps of rotating the C-axis to multiple angles with a fixed step size, acquiring images at each angle to form an image point trajectory sequence for each of the P candidate features, performing circle fitting on each image point trajectory sequence to obtain the center coordinates and radius of the fitted circle for that candidate feature, determining the center coordinates of the fitted circle as the projection position of the rotation axis of the C-axis in the image, and determining the radius of the fitted circle as the pixel distance from the candidate feature to the rotation axis, include: The C-axis is rotated to R angles within a set range with a fixed step distance. At each angle, the monocular camera device acquires an image of the workpiece to obtain R frames of images, where R is an integer greater than or equal to 3. For each of the P candidate features, the sub-pixel coordinates of the candidate feature are detected in each frame of the R frames of the image, and the sub-pixel coordinates are arranged in the order of the R angles to form the image point trajectory sequence of the candidate feature. For each image point trajectory sequence, perform a first least-squares circle fitting to obtain a preliminary fitted circle; Calculate the distance from each sub-pixel coordinate in the image point trajectory sequence of the candidate feature to the preliminary fitted circle, and use it as the fitting residual of the sub-pixel coordinate; Sub-pixel coordinates that exceed a pre-set residual threshold are removed to obtain the remaining sub-pixel coordinates; A second least-squares circle fitting is performed on the remaining sub-pixel coordinates to obtain the center coordinates and radius of the refined fitted circle; The center coordinates of the refined fitted circle are determined as the projection position of the rotation axis of the C-axis in the R-frame image. The radius of the refined fitted circle is determined as the pixel distance from the candidate feature to the axis of rotation.
6. The visual tool setting method based on CAD drawing features according to claim 5, characterized in that, The steps of obtaining the rotation radius of the candidate feature based on the scaling factor and the pixel distance from the candidate feature to the rotation axis, and determining the two-dimensional offset vector of the candidate feature in the turntable coordinate system based on the rotation radius and the projection position, include: Multiply the scaling factor by the pixel distance from the candidate feature to the rotation axis to obtain the rotation radius of the candidate feature to the C-axis. In the R-frame image, select the image at a first angle and the image at a second angle, where the difference between the first angle and the second angle is 90 degrees; For each candidate feature, in the image at the first angle, a first azimuth angle of the subpixel coordinates of the candidate feature relative to the projection position is determined, and in the image at the second angle, a second azimuth angle of the subpixel coordinates of the candidate feature relative to the projection position is determined. The difference between the second azimuth angle and the first azimuth angle is defined as the azimuth angle difference; If the absolute value of the deviation between the azimuth angle difference and 90 degrees is less than or equal to a preset angle threshold, the first azimuth angle is determined as the azimuth angle of the candidate feature in the turntable coordinate system. If the absolute value of the deviation between the azimuth angle and 90 degrees is greater than the angle threshold, the images of the candidate feature at the first angle and the second angle are re-acquired. The product of the radius of gyration and the cosine of the azimuth angle is determined as the first component of the two-dimensional offset vector; The product of the radius of gyration and the sine of the azimuth angle is determined as the second component of the two-dimensional offset vector.
7. The visual tool setting method based on CAD drawing features according to claim 1, characterized in that, The steps of calculating the Z-coordinate of each candidate feature in the machine tool coordinate system based on the system deviation determined by the touch method, and obtaining the three-dimensional coordinate measurement value of each candidate feature in the machine tool coordinate system based on the Z-coordinate and the two-dimensional offset vector of the corresponding candidate feature, include: The monocular camera device performs visual elevation determination on each of the P candidate features to obtain the Z-estimated value of the top surface of the candidate feature; The top surface of any one of the P candidate features is mechanically probed by the probe or tool setting block of the machine tool, and the Z coordinate reading of the machine tool is recorded at the time of probe. The difference between the machine tool Z-coordinate reading and the estimated top surface Z-coordinate of the candidate feature targeted by the mechanical touch is determined as the system bias; The system bias is used to compensate for the Z-axis estimate of the top surface of each of the P candidate features, so as to obtain the Z-axis coordinate of each of the P candidate features in the machine tool coordinate system. For each candidate feature, according to the forward kinematics of the machine tool, the two-dimensional offset vector of the candidate feature in the rotary table coordinate system is converted into the X and Y components of the candidate feature in the machine tool coordinate system; The Z-axis coordinate of the candidate feature in the machine tool coordinate system is taken as the Z component of the three-dimensional coordinate measurement value of the candidate feature; Based on the X component, the Y component, and the Z component, the three-dimensional coordinate measurement value of the candidate feature in the machine tool coordinate system is obtained.
8. The visual tool setting method based on CAD drawing features according to claim 1, characterized in that, The step of solving the rigid body transformation based on the upgraded 3D feature coordinates of the P candidate features in the feature map and the 3D coordinate measurements of the P candidate features, and using the rigid body transformation as the transformation from the drawing coordinate system to the machine tool coordinate system, includes: For each of the P candidate features, obtain the two-dimensional coordinates and Z-direction attribution of the candidate feature in the feature map, wherein the Z-direction attribution includes at least one of top surface, bottom surface, and through surface; According to the Z-axis attribution, assign the candidate feature a Z-axis coordinate in the drawing coordinate system; The candidate feature's two-dimensional coordinates in the feature map and the assigned Z-axis coordinates are combined to obtain the candidate feature's three-dimensional feature coordinates in the drawing coordinate system. Using the three-dimensional feature coordinates of each candidate feature in the drawing coordinate system as the first point set, and the three-dimensional coordinate measurement values of each candidate feature in the machine tool coordinate system as the second point set, construct an objective function that minimizes the sum of squared Euclidean distances between the first point set and the second point set after rotation and translation. The objective function is solved with the rotation matrix being an orthogonal matrix and its determinant being positive 1 as a constraint, yielding the rotation matrix and translation vector. The solution process includes: calculating the centroids of the first and second point sets; constructing a cross-covariance matrix based on the centroid-free first and second point sets; performing singular value decomposition on the cross-covariance matrix to obtain the rotation matrix; and calculating the translation vector based on the rotation matrix, the centroids of the first and second point sets. The rotation matrix and the translation vector are used to determine the transformation from the drawing coordinate system to the machine tool coordinate system.
9. The visual tool setting method based on CAD drawing features according to claim 1, characterized in that, The step of transforming the workpiece origin to the rotary table coordinate system according to the transformation from the drawing coordinate system to the machine tool coordinate system, and obtaining the coordinates of the workpiece origin in the rotary table coordinate system, includes: Obtain the coordinates of the workpiece origin in the drawing coordinate system; According to the transformation from the drawing coordinate system to the machine tool coordinate system, the coordinates of the workpiece origin in the drawing coordinate system are transformed to the coordinates of the workpiece origin in the machine tool coordinate system; The transformation from the rotary table coordinate system to the machine tool coordinate system is calculated based on the forward kinematics of the machine tool. By performing the inverse transformation from the rotary table coordinate system to the machine tool coordinate system, the coordinates of the workpiece origin in the machine tool coordinate system are transformed into the coordinates of the workpiece origin in the rotary table coordinate system.
10. The visual tool setting method based on CAD drawing features according to any one of claims 1 to 9, characterized in that, After transforming the workpiece origin to the rotary table coordinate system according to the transformation from the drawing coordinate system to the machine tool coordinate system, and before writing the coordinates of the workpiece origin in the rotary table coordinate system into the CNC system of the machine tool, the method further includes: The confidence level of the transformation from the drawing coordinate system to the machine tool coordinate system is evaluated based on the interior point rate of the interior point set and the root mean square residual of the transformation from the drawing coordinate system to the machine tool coordinate system. If the inlier rate is greater than or equal to a preset inlier rate threshold and the root mean square residual is less than or equal to a preset residual threshold, the confidence assessment is deemed to have passed. If the inlier rate is less than the inlier rate threshold or the root mean square residual is greater than the residual threshold, the confidence assessment is deemed unsuccessful. Automatic correction is then performed in the following order: first, replacing the candidate feature; then, reducing the distance between the monocular camera and the workpiece and re-acquiring the image. If the number of corrections does not exceed a preset retry limit, the confidence assessment is re-performed. If the number of corrections exceeds the retry limit, the process terminates and a diagnostic list is output. The replacement of the candidate feature includes: selecting a substitute feature from the M features that were not selected as the P candidate features, in descending order of priority, to replace at least one of the P candidate features. If the confidence level assessment is passed, all selected features are retested, and the Euclidean distance between the three-dimensional coordinate measurements of the two features in each feature pair is calculated as the measured distance of the feature pair. The maximum deviation between the measured distance of each feature pair and the nominal distance in the feature map is also calculated. If the maximum deviation is less than or equal to the preset acceptance threshold, the retest is deemed to have passed, and the coordinates of the workpiece origin in the rotary table coordinate system are written into the CNC system of the machine tool. If the maximum deviation is greater than the acceptance threshold, the retest is deemed unacceptable. The coordinates of the workpiece origin in the rotary table coordinate system are not written into the CNC system of the machine tool. A residual list is output, which includes the feature pair with the largest deviation, the deviation value, and the possible cause.
11. The visual tool setting method based on CAD drawing features according to claim 10, characterized in that, Also includes: Generate a tool calibration report, which includes a feature table, confidence index, and calibration results. The feature table includes the feature type of the feature involved in tool setting among the M features, the two-dimensional coordinates of the feature in the feature diagram, and the three-dimensional coordinate measurement value of the feature in the machine tool coordinate system. The confidence index includes the interior point rate of the interior point set, the root mean square residual of the transformation from the drawing coordinate system to the machine tool coordinate system, and the maximum deviation. The calibration results include the scaling factor and the system deviation.
12. A machine tool, characterized in that, This includes the machine tool body, spindle, rotary table, monocular camera device, tool holder extension rod, and CNC system; The rotary table includes a B-axis and a C-axis. The C-axis is mounted on the B-axis and tilts as the B-axis rotates. The B-axis is arranged around the Y-axis of the machine tool, and the C-axis is arranged around the Z-axis of the machine tool. The spindle is configured to feed linearly along the X-axis, Y-axis and Z-axis of the machine tool; The monocular camera device is clamped to the main shaft via a tool holder type connector, the interface of the tool holder type connector is consistent with the tool holder interface of the main shaft, and the optical axis of the monocular camera device is coaxial with the axis of the main shaft; The CNC system is configured to perform the steps of the visual tool setting method based on CAD drawing features according to any one of claims 1 to 11.
