There are five ways to fixture the relative coordinate system to an object:
Move it to the position and angle of a specified occurrence of a MIL Pattern Matching or Model Finder model.
Move it to the position and angle of a specified Metrology reference frame feature.
Move it to a position and angle that are with respect to a relative coordinate system.
Move it to a position and angle that are with respect to the absolute coordinate system.
Move it to a position and angle using one of the above techniques, and then copy its position and angle to other images that require the same relative coordinate system displacement.
The easiest way to move the relative coordinate system for fixturing is to use a MIL Pattern Matching or Model Finder model that is at a fixed positional and angular offset from the object to analyze or process. In this case, search for the model. Then, to move the relative coordinate system to the reference location of a found occurrence, call McalFixture() with M_MOVE_RELATIVE, the Model Finder/Pattern Matching result buffer, and the index of the occurrence.
For example, to move the relative coordinate system of an image to the reference location of the first occurrence of a pattern matching model:
/* Move the relative coordinate system of ImageId, with no offset,
at the location of occurrence 0 of the pattern matching model,
(location is contained in the pattern matching result PatResultId). */
McalFixture(ImageId, M_NULL, M_MOVE_RELATIVE, M_RESULT_PAT, PatResultId,
0, /* Occurrence index = 0. */
M_DEFAULT, M_DEFAULT, M_DEFAULT);
You should ensure that the Pattern Matching or Model Finder model used to establish the location has good, unique features so that there is no ambiguity over where to move the relative coordinate system.
By default, when using this technique, the relative coordinate system is placed at the reference location of the specified model occurrence. You can, however, set the relative coordinate system at an offset from this location. See the Fixturing offset section later in this chapter.
For more information about defining a Pattern Matching model, see Chapter 7: Pattern matching. For more information about defining a Model Finder model, see Chapter 8: Geometric Model Finder.
You can specify the new location for the relative coordinate system using the position and angle of a Metrology reference frame. To do so, call McalFixture() with M_MOVE_RELATIVE, the identifier of a Metrology result buffer, and the index of the reference frame feature to use. MIL will move the relative coordinate system to the location, offset, and angle specified by the constructed Metrology reference frame.
The constructed frames used in metrology cannot be used directly in other modules, and so moving the relative coordinate system to the location specified by the constructed frame could be useful to, for example, process the same image using a different module after having processed it with Metrology.
/* Move the relative coordinate system of ImageId, with no offset,
at the location of the local frame 1 of the metrology context,
(location is contained in the metrology result MetResultId). */
McalFixture(ImageId, M_NULL, M_MOVE_RELATIVE, M_RESULT_MET, MetResultId,
1, /* Local frame index = 1. */
M_DEFAULT, M_DEFAULT, M_DEFAULT);
By default, when using this technique, the relative coordinate system is placed at the reference location of the specified Metrology global or local frame result. You can, however, set the relative coordinate system at an offset from this location. See the Fixturing offset section later in this chapter.
You can have MIL establish the new location for the relative coordinate system based on an explicitly specified position and angle that are expressed in a specified relative coordinate system. In this case, the position and angle would correspond to a calculated reference location for the object to analyze or process.
To move the relative coordinate system using this technique, call McalFixture() with all of the following:
The position and angle expressed in a relative coordinate system.
If different from the target's current relative coordinate system, specify the calibrated image/camera calibration context with the relative coordinate system of the position and angle. Otherwise, use M_DEFAULT (for CalOrLocSourceId).
Internally, McalFixture() converts the specified position and angle to be with respect to the absolute coordinate system. It then uses the converted position and angle to place the new relative coordinate system.
The following animation illustrates the above mentioned process.
The animation above shows the position and angle of the relative coordinate system before and after calling McalFixture(). When you call McalFixture() with the position (X2, Y2) and angle Theta2 expressed in the current relative coordinate system, the position (X3, Y3) and angle Theta3 for the new relative coordinate system are internally calculated in the absolute coordinate system. Finally, the relative coordinate system is moved to the new position and angle in the absolute coordinate system.
/* Move the relative coordinate system of ImageId, with no offset,
at the position (X2, Y2) and angle Theta2.
This point and this angle are expressed in the relative coordinate
system of ImageId (before the move).
After the move, the relative coordinate system will be placed at position (X3, Y3)
and angle Theta3. */
McalFixture(ImageId, M_NULL, M_MOVE_RELATIVE, M_POINT_AND_ANGLE,
M_DEFAULT, /* CS for (X2, Y2) and Theta2: M_DEFAULT means use ImageId. */
X2, Y2, Theta2, M_DEFAULT);
By default, the relative coordinate system is placed at the calculated position and angle. You can, however, set the relative coordinate system at an offset from the calculated position and angle. See the Fixturing offset section later in this chapter.
If you know the position and angle for the new relative coordinate system with respect to the absolute coordinate system, you can set the new relative coordinate system directly, using McalRelativeOrigin() or McalSetCoordinateSystem().
For example, if in the previous example, you knew the position (X3, Y3) and angle Theta3 in the absolute coordinate system, you could call McalRelativeOrigin() as follows:
/* Move the relative coordinate system of ImageId, with no offset,
at the position (X3, Y3) and angle Theta3.
This point and this angle are expressed in the absolute coordinate system. */
McalRelativeOrigin(ImageId, X3, Y3, 0.0, Theta3, M_DEFAULT);
You can specify the location of the new relative coordinate system using two points. The first point defines the position, and the vector going from the first point to the second point defines the angle and direction of the X-axis.
To move the relative coordinate system using this technique, call McalFixture() with all of the following:
The first and second points expressed in the relative coordinate system.
Note that you can only pass X and Y-coordinates for the points. So, essentially you are moving the relative coordinate system along its current XY-plane.
The following animation illustrates how to move the relative coordinate system using two points in the current relative coordinate system.
Typically when using McalFixture(), you can only move the relative coordinate system along its XY-plane (Z = 0) and you can only rotate the relative coordinate system around the Z-axis or an axis parallel to it (the direction and angle of the Z-axis remains unchanged).
The animation below shows a 3D view on how the relative coordinate system is moved using McalFixture() with M_POINT_AND_DIRECTION_POINT.
This rule does not apply if you are using McalFixture() with M_LASER_3DMAP or M_RESULT_POINT_CLOUD_3DMAP; these allow you to move the relative coordinate system in 3D. If you need to move the relative coordinate system in 3D and can't use McalFixture(), you can use McalSetCoordinateSystem().
When working with multiple images of the same scene taken from different view points, you might want to move the relative coordinate system in one image, and then copy the position and angle of the new relative coordinate system to the other images. To perform the copy, iteratively call McalFixture() with all of the following:
Call McalFixture() with M_MOVE_RELATIVE as the Operation and M_SAME_AS_SOURCE as the LocationType.
Specify the source calibrated object to be copied in CalOrLocSourceId.
Specify the destination of the copy operation in DstCalibratedMilObjectId.
This operation does not copy the absolute coordinate system information. It assumes that the absolute coordinate systems of the different images are the same, although the mapping between the world and pixel coordinate systems might be different.