// Cocoa Example #3 // // Determining the location of an object from photogrametry // // This example models a simple object ("myObject1") with 3 photogramtery targets. // We wish to determine a particular point (a "calibration pin") on // the object in a global coordinate system established by a // photogrammetric survey. It is assumed that the relationship between // the calibration pin and each of the three targets are known wrt to each // other, but that the location and orientation of the calibration pin // in the global coordinate system is unknown. A similiar script // was employed to determine the placement of COPS objects in the // CERN ISR2000 prototype alignment system tests (see CMS IN-2002/004 // for a complete description). // // In practice (think real world !) we know approximately the orientation // and location of the object we are doing photogrametry on. For example, // we know the orientation of the object within 45 degrees and a couple // meters from just looking at the object being surveyed or from the // raw photogrametry data. Even though we call the initial orientation and // location of the object 'unk', we want to specify a starting value roughly // near where we expect the object to wind up so that we can avoid false // minima or a large number of iterations. // // Setting up the script : // // COCOA has "distancemeter1dim" and "distance_target" as native objects. // Ordinarily, the two are used to simulate a distance measuring device. // We will let the distancemeter1dim object represent a 3D point given by // the surveyors and the distance_target represent a photogramtery target // on the object. By specificing the measurement made between the // distancemeter1dim and distance_target as being fixed at exactly 0mm, // we force COCOA to fit the three photogrammetry targets over the 3 // survey points by repositioning the entire object. // // When we create a photogramtery target or survey measurement point, we will // specify 3 distancemeters or distancetargets for each point, corresponding // to x,y, and z axis displacements of each target from the survey point. Care // must be taken to rotate each distance meter and target to make the measurement // along the desired x, y, and z axis, else you will get errors reporting that // the measurements in the MEASUREMENT section are made in non-intersecting planes. // GLOBAL_OPTIONS report_verbose 2 save_matrices 0 debug_verbose 3 calcul_type 1 length_value_dimension 1 length_error_dimension 2 angle_value_dimension 3 angle_error_dimension 2 output_length_value_dimension 1 output_length_error_dimension 2 output_angle_value_dimension 3 output_angle_error_dimension 2 writeVRML 2 onlyVRML 0 PARAMETERS //PRECISION parameters prec_pos_sv 0 prec_ang_sv 0 prec_pos_myObject1 11 prec_ang_myObject1 13 prec_pos_pg 0 prec_ang_pg 0 dist_prec 1. SYSTEM_TREE_DESCRIPTION object system myObject 3 survey_point object survey_point 3 distancemeter1dim object myObject 3 pgtarget object pgtarget 3 distance_target SYSTEM_TREE_DATA system s myObject myObject1 // I start with a very rough guess (to the nearest meter and 90 degree // rotation) of the object in the survey system to minimize the chances // of stumbling upon a false minima in the COCOA fit. One could look at // the raw survey data to make such a guess. center X 7000 prec_pos_myObject1 unk Y 2000 prec_pos_myObject1 unk Z 8000 prec_pos_myObject1 unk angles X 0 prec_ang_myObject1 unk Y 90 prec_ang_myObject1 unk Z 0 prec_ang_myObject1 unk pgtarget pg1 // Data for Photogramtery (PG) Target 1 goes here. This is the distance from the // calibration pin to the PG target. center X -73.835 prec_pos_pg fix Y 14.940 prec_pos_pg fix Z 0 prec_pos_pg fix angles X 0 prec_ang_pg fix Y 0 prec_ang_pg fix Z 0 prec_ang_pg fix distance_target dt1x center X 0. prec_pos_pg fix Y 0. prec_pos_pg fix Z 0. prec_pos_pg fix // The distance target points by default along the Z axis. We need to rotate // it so that it points along the X axis (since this is the target for the // measurement along the x axis) angles X 0 prec_ang_pg fix Y 90 prec_ang_pg fix Z 0 prec_ang_pg fix distance_target dt1y center X 0. prec_pos_pg fix Y 0. prec_pos_pg fix Z 0. prec_pos_pg fix // The distance target points by default along the Z axis. We need to rotate // it so that it points along the Y axis (since this is the target for the // measurement along the Y axis) angles X 90 prec_ang_pg fix Y 0 prec_ang_pg fix Z 0 prec_ang_pg fix distance_target dt1z center X 0. prec_pos_pg fix Y 0. prec_pos_pg fix Z 0. prec_pos_pg fix angles X 0 prec_ang_pg fix Y 0 prec_ang_pg fix Z 0 prec_ang_pg fix pgtarget pg2 //CMM Data for PG2 goes here center X -73.922 prec_pos_pg fix Y 65.770 prec_pos_pg fix Z 0. prec_pos_pg fix angles X 0 prec_ang_pg fix Y 0 prec_ang_pg fix Z 0 prec_ang_pg fix distance_target dt2x center X 0. prec_pos_pg fix Y 0. prec_pos_pg fix Z 0. prec_pos_pg fix angles X 0 prec_ang_pg fix Y 90 prec_ang_pg fix Z 0 prec_ang_pg fix distance_target dt2y center X 0. prec_pos_pg fix Y 0. prec_pos_pg fix Z 0. prec_pos_pg fix angles X 90 prec_ang_pg fix Y 0 prec_ang_pg fix Z 0 prec_ang_pg fix distance_target dt2z center X 0. prec_pos_pg fix Y 0. prec_pos_pg fix Z 0. prec_pos_pg fix angles X 0 prec_ang_pg fix Y 0 prec_ang_pg fix Z 0 prec_ang_pg fix pgtarget pg3 //CMM data for PG3 goes here center X 10.919 prec_pos_pg fix Y 45.959 prec_pos_pg fix Z 0. prec_pos_pg fix angles X 0 prec_ang_pg fix Y 0 prec_ang_pg fix Z 0 prec_ang_pg fix distance_target dt3x center X 0. prec_pos_pg fix Y 0. prec_pos_pg fix Z 0. prec_pos_pg fix angles X 0 prec_ang_pg fix Y 90 prec_ang_pg fix Z 0 prec_ang_pg fix distance_target dt3y center X 0. prec_pos_pg fix Y 0. prec_pos_pg fix Z 0. prec_pos_pg fix angles X 90 prec_ang_pg fix Y 0 prec_ang_pg fix Z 0 prec_ang_pg fix distance_target dt3z center X 0. prec_pos_pg fix Y 0. prec_pos_pg fix Z 0. prec_pos_pg fix angles X 0 prec_ang_pg fix Y 0 prec_ang_pg fix Z 0 prec_ang_pg fix // Now for the data from the survey group survey_point sv1 center X 6954.392 prec_pos_sv fix Y 1491.397 prec_pos_sv fix Z 7913.311 prec_pos_sv fix angles X 0 prec_ang_sv fix Y 90 prec_ang_sv fix Z 0 prec_ang_sv fix distancemeter1dim dm1x center X 0. prec_pos_sv fix Y 0. prec_pos_sv fix Z 0. prec_pos_sv fix // The distance meter points by default along the Z axis. We need to rotate // it so that it points along the X axis (since this is the meter for the // measurement along the X axis) angles X 0 prec_ang_sv fix Y 90 prec_ang_sv fix Z 0 prec_ang_sv fix distancemeter1dim dm1y center X 0. prec_pos_sv fix Y 0. prec_pos_sv fix Z 0. prec_pos_sv fix angles // The distance target points by default along the Z axis. We need to rotate // it so that it points along the Y axis (since this is the target for the // measurement along the Y axis) X 90 prec_ang_sv fix Y 0 prec_ang_sv fix Z 0 prec_ang_sv fix distancemeter1dim dm1z center X 0. prec_pos_sv fix Y 0. prec_pos_sv fix Z 0. prec_pos_sv fix angles X 0 prec_ang_sv fix Y 0 prec_ang_sv fix Z 0 prec_ang_sv fix survey_point sv2 // ISR Photogrametry position PG2 goes here center X 6954.359 prec_pos_sv fix Y 1542.181 prec_pos_sv fix Z 7913.433 prec_pos_sv fix angles X 0 prec_ang_sv fix Y 90 prec_ang_sv fix Z 0 prec_ang_sv fix distancemeter1dim dm2x center X 0. prec_pos_sv fix Y 0. prec_pos_sv fix Z 0. prec_pos_sv fix angles X 0 prec_ang_sv fix Y 90 prec_ang_sv fix Z 0 prec_ang_sv fix distancemeter1dim dm2y center X 0. prec_pos_sv fix Y 0. prec_pos_sv fix Z 0. prec_pos_sv fix angles X 90 prec_ang_sv fix Y 0 prec_ang_sv fix Z 0 prec_ang_sv fix distancemeter1dim dm2z center X 0. prec_pos_sv fix Y 0. prec_pos_sv fix Z 0. prec_pos_sv fix angles X 0 prec_ang_sv fix Y 0 prec_ang_sv fix Z 0 prec_ang_sv fix survey_point sv3 // ISR Photogrametry PG3 survey goes here center X 6953.898 prec_pos_sv fix Y 1522.556 prec_pos_sv fix Z 7828.585 prec_pos_sv fix angles X 0 prec_ang_sv fix Y 90 prec_ang_sv fix Z 0 prec_ang_sv fix distancemeter1dim dm3x center X 0. prec_pos_sv fix Y 0. prec_pos_sv fix Z 0. prec_pos_sv fix angles X 0 prec_ang_sv fix Y 90 prec_ang_sv fix Z 0 prec_ang_sv fix distancemeter1dim dm3y center X 0. prec_pos_sv fix Y 0. prec_pos_sv fix Z 0. prec_pos_sv fix angles X 90 prec_ang_sv fix Y 0 prec_ang_sv fix Z 0 prec_ang_sv fix distancemeter1dim dm3z center X 0. prec_pos_sv fix Y 0. prec_pos_sv fix Z 0. prec_pos_sv fix angles X 0 prec_ang_sv fix Y 0 prec_ang_sv fix Z 0 prec_ang_sv fix MEASUREMENTS DISTANCEMETER1DIM s/myObject1/pg1/dt1x & s/sv1/dm1x D 0. dist_prec DISTANCEMETER1DIM s/myObject1/pg1/dt1y & s/sv1/dm1y D 0. dist_prec DISTANCEMETER1DIM s/myObject1/pg1/dt1z & s/sv1/dm1z D 0. dist_prec DISTANCEMETER1DIM s/myObject1/pg2/dt2x & s/sv2/dm2x D 0. dist_prec DISTANCEMETER1DIM s/myObject1/pg2/dt2y & s/sv2/dm2y D 0. dist_prec DISTANCEMETER1DIM s/myObject1/pg2/dt2z & s/sv2/dm2z D 0. dist_prec DISTANCEMETER1DIM s/myObject1/pg3/dt3x & s/sv3/dm3x D 0. dist_prec DISTANCEMETER1DIM s/myObject1/pg3/dt3y & s/sv3/dm3y D 0. dist_prec DISTANCEMETER1DIM s/myObject1/pg3/dt3z & s/sv3/dm3z D 0. dist_prec // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // // ^^ Expected Results ^^ // // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // // // Running this script (unchanged) in cocoa_v2.0.0 should // yield the following results in the report.out file for // the 'unk' entries : // // // DIMENSIONS: lengths = mm +- mum angles = deg +- murad // Fit iteration 2 ... // 2 Fit quality is = 2605.9756 // 2 Fit quality cut is = 0.01260082 // GOOD QUALITY OF THE FIT FOR ITERATION 2 = 0.01260082 < 0.1 // // FITTED ENTRY VALUES // NoEnt_unk Optical Object Parameter value (+-error) orig.val (+-error) quality // 0 s/myObject1 centre_X 6953.9891 +- 1.5343581 7000 +- 11 Q2 DIFF= -46.010929 // 1 s/myObject1 centre_Y 1476.5641 +- 0.82170087 2000 +- 11 Q2 DIFF= -523.43588 // 2 s/myObject1 centre_Z 7839.4275 +- 0.7901613 8000 +- 11 Q2 DIFF= -160.57248 // 3 s/myObject1 angles_X 0.095329528 +- 12.79944 0 +- 13 Q2 DIFF= 0.095329528 // 4 s/myObject1 angles_Y 90.320114 +- 14.565743 90 +- 13 Q2 DIFF= 0.32011413 // 5 s/myObject1 angles_Z 0.038019989 +- 27.84242 0 +- 13 Q2 DIFF= 0.038019989 // // CORRELATION BETWEEN 'unk' ENTRIES: (>= 1.E-6) // No_1 No_2 correlation6 // (0) (3) 0.0063723474 // (0) (5) 0.82065153 // (1) (3) 0.71149385 // (1) (4) 0.00057299341 // (2) (4) 0.0034496281 // (3) (5) 0.0078060108