Replicating Insight's Auto Survey Function

Started by jrayself, August 04, 2012, 01:22:20 PM

Previous topic - Next topic

jrayself

What I'm trying to accomplish is create a macro to use with a laser tracker that will auto-probe a set of predefined targets with either an auto-probe measured command or go-to and probe measured commands, then create a new piece then waits for a set amount of time and performs the same function again and again and again until the user stops the process.

I have a basic script that accomplishes most of that task:

version "5.0"
#=====================================================
# ---- InnovMetric Software Inc.
# ---- Module  :    IMInspect
# ---- Version :    12.0.13 ( 12.00.13.5337 )
# ---- Date    :    Saturday, July 28, 2012 - 21:37:16
#-----------------------------------------------------

# Written by Jason R. Self of Dimensional Engineering - http://www.Dimensional3D.com/

DECLARE i 1
DECLARE min_wait
DECLARE milli_wait

MACRO INPUT INTEGER(min_wait, "Wait Time...", "How many minutes do you wish to wait between Measurement Cycles?", )

SET milli_wait EXPR( $min_wait * 60000)

WHILE $i >= 1
   
    PIECE NEW ( "cycle $i" )
    TREEVIEW OBJECT SELECT NONE
    TREEVIEW FEATURE SELECT RANGE ( 4, 6, "On" )
    FEATURE POINT AUTO_PROBE_MEASURED
    TREEVIEW OBJECT SELECT NONE
    TREEVIEW FEATURE SELECT ( 4, "On" )
    PROBE DEVICE GO_OBJECT ( )
    ++i
    FILE SAVE_PROJECT ( , )
    MACRO SLEEP($milli_wait)
   
ENDWHILE


I need to change it so the first time it's ran it grabs whatever treeview points are selected and uses those throughout the process. Also on the first iteration the first set of points needs to be swapped to nominals. This I should be able to accomplish pretty easily. This next problem is where I'm really stuck.

With the auto-probe measured command it will always aim to the nominal location then perform a search function if the target is not found. The problem is that as the targets drift with the object being monitored, eventually the new measured location could be so far off from the original "nominal" location that the search command will have to be initiated every time and will slow down the entire survey.

I want to aim to the previous piece's measured values then measure the new location yet still report to the original "nominal" location. I imagine there is a way to accomplish this by writing & reading a text file, but I have no experience with that function.

Any suggestions?
Jason R. Self
Dimensional Engineering, Inc.

jason25

I have no idea when it comes to scanning.  What I have done is written to an excel file and read values from an excel file, just never in the same macro.  I can try to get a base for you to start with and let you get exactly what you need from that.

jrayself

Any help at all would be greatly appreciated.
Jason R. Self
Dimensional Engineering, Inc.

jason25

#3
This macro will:
1. create a point
2. read the value of that point
3. write X, Y, and Z to a text file
4. read X, Y, and Z, values from that text file and assign them to X2, Y2, and Z2.

This is just an example of how you would write to a text file and then read from it.  You would need to manually create the text file where you would like it and then assign that path to the file_name variable.  Hope it helps!

version "5.0"
#=======================================================
# ---- InnovMetric Software Inc.
# ---- Module  :    IMInspect
# ---- Version :    12.0.10 ( 12.00.10.5118 )
# ---- Date    :    Thursday, August 23, 2012 - 14:24:06
# ---- Created By:  Jason Reno (Sauder Woodworking Co.)
#-------------------------------------------------------
DECLARE nb_lines
DECLARE x
DECLARE y
DECLARE z
DECLARE x2
DECLARE y2
DECLARE z2
DECLARE file_name "C:\Pointcloud_test.txt"

#Create a dummy point to get values from
FEATURE PRIMITIVE POINT CREATE(10.2,15.2,20.2,"Nominal",,"Test Point")

# Get X, Y, and Z of the dummy point
TREEVIEW PRIMITIVE POINT PROPERTIES POINT GET(x,y,z, "Test Point")

#Write value to a text file
DATA_FILE APPEND LINES($file_name, "$x $y $z")

#Get number of lines in the text file
DATA_FILE PROPERTIES NB_LINES GET("$file_name", nb_lines)

#Read last line in text file and assign those values to a variable.
DATA_FILE READ LINE_FIELD($file_name, $nb_lines, 1, x2,, "On")
DATA_FILE READ LINE_FIELD($file_name, $nb_lines, 2, y2,, "On")
DATA_FILE READ LINE_FIELD($file_name, $nb_lines, 3, z2,, "On")

jason25


jrayself

I haven't had any down time to play with it yet, but I'll let you know. Thanks again!
Jason R. Self
Dimensional Engineering, Inc.

jrayself

Played with it, got a little help from Innovmetric, and ran seven laser trackers monitoring about 30 repeatability targets for six hours. No problems at all.

Thanks for the assist!




version "5.0"
#=========================================================
# ---- InnovMetric Software Inc.
# ---- Module  :    IMInspect
# ---- Version :    12.0.17 ( 12.00.17.5761 )
# ---- Date    :    Thursday, November 08, 2012 - 14:06:05
#---------------------------------------------------------

# Written by Jason R. Self of Dimensional Engineering - http://www.Dimensional3D.com/

MACRO COMMAND ECHO ( "Off" )

#Display Command History Pane for Echo purposes
WINDOW("Command History", "On")

DECLARE run 1
DECLARE iter 1
DECLARE i 1
DECLARE cycle_count 1

DECLARE feat_name
DECLARE x
DECLARE y
DECLARE z
DECLARE time
DECLARE time2
DECLARE date

#Count the nuber of features
DECLARE nb_points
TREEVIEW FEATURE COUNT GET( nb_points )

#Prompt user for delay between cycles
DECLARE sec_wait
DECLARE milli_wait
MACRO INPUT INTEGER( sec_wait, "Wait Time...", "How many seconds do you wish to wait between Measurement Cycles?", 25 )

SET milli_wait EXPR( $sec_wait * 1000 / 2)

# delay1 is 2.5 seconds
# delay2 is the number of time to apply the delay1
DECLARE delay1 $milli_wait
DECLARE delay2 2
DECLARE total_delay

#Calculate the Total Delay between cycles to echo in the Command History
SET total_delay EXPR ( $delay1 * $delay2 / 1000 )

#Set Point Probing Options
PROBE DEVICE PROBING_MODE ( "Single" )
FEATURE PRIMITIVE POINT PROBE METHOD2 ( "Uncompensated" )

#Create a file to hold the measured points, rather than keeping them in the project, so that we can have unlimited measurements
DATA_FILE CREATE( "$_PWK_FILES_PATH\user-data\Survey_Data.txt", "Ascii", "No" )
DATA_FILE APPEND LINE( "$_PWK_FILES_PATH\user-data\Survey_Data.txt", "Name ${_TAB} Date ${_TAB} Time ${_TAB} X ${_TAB} Y ${_TAB} Z" )

#Set macro to loop infinitely.  Holding down ESC for a while will exit the macro, eventually
WHILE $run == 1
    SET iter 1
   
    #Check the time, using a SYSTEM command (DOS command). 
    #These are DOS commands that output required info in the declared text files.
    SYSTEM COMMAND( "Date /t>${_QUOTES}$_PWK_FILES_PATH\user-data\date.txt${_QUOTES}" )
    SYSTEM COMMAND( "Time >${_QUOTES}$_PWK_FILES_PATH\user-data\time.txt${_QUOTES}" )
    SYSTEM COMMAND( "Time /t >${_QUOTES}$_PWK_FILES_PATH\user-data\time2.txt${_QUOTES}" )
   
    #Read TIME & DATE from these text files
    DATA_FILE READ LINE_FIELD ( "$_PWK_FILES_PATH\user-data\date.txt", 1, 2, date )
    DATA_FILE READ LINE_FIELD ( "$_PWK_FILES_PATH\user-data\time.txt", 1, 5, time )
    DATA_FILE READ LINE( "$_PWK_FILES_PATH\user-data\time2.txt", 1, time2 )
   
    # Select all point and have them probed automatically
    TREEVIEW OBJECT SELECT NONE
    TREEVIEW FEATURE SELECT ALL
    FEATURE POINT AUTO_PROBE_MEASURED
   
    # Put the results into a text file
    WHILE $iter <= $nb_points
        TREEVIEW OBJECT SELECT NONE
       
        #Write the new measured coordinates to the text file.
        TREEVIEW FEATURE MEASURED SELECT( $iter, "On" )
        TREEVIEW PRIMITIVE POINT PROPERTIES POINT GET ( x, y, z, )
        TREEVIEW OBJECT SELECT NONE
        TREEVIEW FEATURE NAME GET( $iter, feat_name )
        DATA_FILE APPEND LINE( "$_PWK_FILES_PATH\user-data\Survey_Data.txt", "$feat_name ${_TAB} $date ${_TAB} $time ${_TAB} $x ${_TAB} $y ${_TAB} $z" )
       
        #Move on to next point
        ++ iter
       
    ENDWHILE
   
    #Swap Nominal & Measured so as to avoid the Find Target command being initiated after a large amount of drift
    TREEVIEW OBJECT SELECT NONE
    TREEVIEW FEATURE SELECT ALL ( "On" )
    FEATURE NOMINAL_MEASURED SWAP_PRIMITIVES ( )
   
    #Print the Cycle Count
    MACRO ECHO( "Cycle Count: $cycle_count @ $time2 on $date with a $total_delay second delay." )
    ++cycle_count
   
    # We pause for the required amount of time (say 10 minutes) before looping back to test them all again, using the MACRO SLEEP command, which is in milliseconds
    # A while loop with sleep commands permit to exit from the macro in between the commands with the escape key. Every 10 seconds, there is the posibility of stopping the macro
    set i 1
    WHILE $i <= $delay2
        MACRO SLEEP ( $delay1 )
        ++ i
    ENDWHILE

ENDWHILE
Jason R. Self
Dimensional Engineering, Inc.

jason25

neat little macro, now if I could just get someone to write that check for a laser scanner...

jrayself

Well this was all probing with a tracker, but PolyWorks does have some very slick functions when it comes to scan data.

Would Sauder be interested in a pre-owned FARO Laser Scanner?
Jason R. Self
Dimensional Engineering, Inc.

jason25

My apologies for the delayed response.

Please email me some details and I can discuss with our team.