MATLAB SETUP

  1. Make sure to be connected to JPL VPN if not on JPL network already when opening matlab.
  2. Make sure the following are on your matlab path and saved.
Dropbox\PFS_EM\SVN\MATLAB
Dropbox\PFS_EM\SVN\MATLAB\lib
Dropbox\PFS_EM\SVN\MATLAB\peter\download
Dropbox\PFS_EM\SVN\MATLAB\peter\lib

MATLAB QUICK SCRIPTS AND FUNCTIONS

Read in a MSIM XML config file as matlab structure

CobraConfigStruct = loadCfgXml
CobraConfigStruct = loadCfgXml('Dropbox\PFS_EM\TEST_RESULTS\TargetConvergence\06_24_14_08_51_13_TargetRun','dmpAdj_msimMaps_062314_1.xml')

Plot a motor map from config file

plotMotMapsFromStruct(CobraConfigStruct.ARM_DATA.ARM_DATA_4.FAST_CALIBRATION_TABLE)
plotMotMapsFromStruct(CobraConfigStruct.ARM_DATA.ARM_DATA_6.SLOW_CALIBRATION_TABLE,'ro--')

Make MSIM XML from a current config structure in Matlab

cobraCfg2xml(CobraConfigStruct,'mynewXMLforMsim.xml')

Get a field value from the Kinematics structure of a Cobra Config structure

L2 = getARMval(CobraConfigStruct,7,'Link2_Link_Length')

Set a field value from the Kinematics structure of a Cobra Config structure

CobraConfigStruct = setARMval(CobraConfigStruct,7,'Link2_Link_Length',35.323)

FIDUCIAL SETUP

  1. Take a manual image with MSIM and save it.
  2. Open the image in ImageJ and measure the coordinates by hand of each image. For the Y-coordinate, subtract the measured value from 2048 to get MSIM Y-coordinate since imageJ is flipped from MSIM.
  3. Enter the coordinates of the fiducials into the script 2014_05_29_FiducialMeasurements.lst.
    1. Example of 3 Fiducials:
      cmd_setHornMethodFiducialCoordinate  96,1644, 10
      cmd_setHornMethodFiducialCoordinate  1645,143, 10
      cmd_setHornMethodFiducialCoordinate  1258,519, 10
      
    2. The last argument (10) is the radius around your provided center with which to declare found centroids that fiducial.
  4. Execute the script in MSIM. It will take 100 pictures and save the centroids it finds for the fiducials you entered to a log.
  5. Open the Dropbox\PFS_EM\SVN\MATLAB\fiducialStudy.m script and edit the input section
    1. Give it the paths of the Centroid_log.txt files that msim creates
    2. Either input the path and filename of the starting XML or uncomment the version which prompts you with the dialog
  6. Run the fiducialStudy script
    1. Save the resulting XML when prompted to do so.
  7. In matlab, look at the newCfg.ARM_DATA.refpos array. This contains the horns corrected average positions of the fiducials in the data you provided originally. Take these and modify future MSIM scripts to use them.

On-Time Tuning

  1. Put filters on camera lens
    1. THETA FILTERS: ND060 + ND030 + ND120
  2. Check that LEDs are triggered off of camera
  3. Start MSIM fresh to make sure no bias or dark frame voodoo is in there
  4. Manually move all non-cabled up cobras out of the way of the ones under interest
  5. Generate ROM Scripts using Matlab script:
    Dropbox\PFS_EM\SVN\MATLAB\ontimeTuning.m
    1. If you don't already have a dark frame saved to go along with the exposures selected in the ontimeTuning script, take them now and save them with the convention that follows this example for 20seconds: 20sDarkImage_64.fits The ontime MSIM scripts will have a command in them which is based on your exposure value and looks for an appropriately named dark image like this
    2. Edit the ROM Script filenames, they shall follow the convention: YYYYMMDD_(theta/phi)(Fwd/Rev)_onTimeTuning.lst (Example: 20140609_thetaFwd_onTimeTuning.lst)
    3. The ontimes to test and other parameters in the ontimeTuning script hopefully do not need adjustment, but they are described within in case.
  6. Execute ROM Scripts with MSIM
    1. Each one of these will create its own test directory with the suffix "onTimeTuning"
    2. Look at the cntrStrk image with ImageJ and make sure that all the positioners are going around at least 200deg or so to get a good circle fit. If they are not, some might be stuck or hitting other positioners and they should be checked to see if their neighbors can be put in a better position.
    3. The quality of the center streaks can be tuned by increasing or decreasing their speed by adjusting the cntrStrkOt variable.
  7. Go to the Images directory of each onTimeTuning directory with matlab (it should be your current folder) and execute the command:
    chooseOntimes
    1. The chooseOntimes shouldn't need modification, but tunable parameters are listed at the top of the script here: Dropbox\PFS_EM\SVN\MATLAB\chooseOntimes.m
  8. A figure will appear asking you to verify that all positioners are identified by the center streaks. Click yes if you see all the centers (red stars) and good streaks for them (>180deg or around there for phi). You can click the other two buttons to halve or double the b/w threshold. Eventually you need to click yes to proceed.
  9. Once you proceed, you'll be asked identify which MSIM PIDs go with which streaks. Enter just the pid number and click ok for each one. The selected centers are shown with a green circle.
  10. After the MSIM PIDs have been assigned, a figure will appear with two subplots. The right plot contains the next streak with first ontime. Hit enter to make it the current streak and que up the next one. Keep hitting enter until you can see that the next streak does not change from the current one and that the positioner makes it's full range of motion or close enough. This may be difficult to tell with phi. Once the two look the same, check the box at the lower left to select the ontime for the streak in the left subplot. Hit enter and it will begin this process again for the next positioner. Keep going until they're all done and the XML dialog appears.
  11. Select the XML you want to start with. This should be the current one you are working with if you have done other ontime tests or if this is the first ontime test you've done and there is no xml file yet, choose the template here: Dropbox\PFS_EM\SVN\MATLAB\CobraConfigTemplate.xml
  12. Next the save XML dialog will appear. Save the new XML containing your selected ontimes and centers if this was theta data. Save it in the Images directory of the test directory for the ontime data. Should be your current working directory in MATLAB already. Format filename like "ThetaFwdOnTimes_062514".

Theta Center and Link Length Metrology

  1. FILTERS: ND060 + ND030 + ND120
  2. Check that the LEDs are triggered from the IO Board
  3. Edit the center script to use the ontimes found from theta and phi forward ontime tuning. Change the number of tests to 1 for loops 1 and 3 so that you can run a couple test images to make sure there is a good spread of centroids.
  4. Run the script and look at the images. Adjust number of steps for specific positioners in the center script to either get tighter or wider spread of centroids around the circumference.
  5. Change the number of tests back to 30 or however many you want to run on each stage in loops 1 and 3.
  6. After test is complete, go to the images directory in Matlab.
  7. Execute the command to find theta centers and save the results:
    getThetaCentersCentroids
    1. A dialog appears asking you to select the latest config xml. This is likely the one from the last ontime test if you are at that step.
    2. When the script finishes, there should a mat file created called s1cntrs_*.mat.
  8. Execute the command
    S1CentersGroupAnlys_CIT
    1. A dialog appears asking you to select the latest config xml. This is likely the one from the last ontime test if you are at that step.
    2. After all plots have been created, save the new xml as s1centers_date.xml
  9. Get the phi centroids now by executing
    getPhiCentersCentroids
    1. This will create a s2cntrs_*.mat file containing the centroids
  10. Now execute
    S2CentersGroupAnlys_CIT
    1. Load the xml created in previous step from theta data
    2. Save the resulting xml as "Links_Centers_date.xml"

Motor Map Creation with MSIM

  1. Check that filters are off the camera lens and that the LED is set to trigger off of the camera
  2. Load the XML into MSIM that has the link lengths/centers created earlier (see next section on loading XML into MSIM)
  3. Run the motor mapping script in MSIM: 2014_06_22_msimMotMap.lst
  4. Navigate to log directory of the MSIM test directory with Matlab
  5. Edit the inputs section of Dropbox\PFS_EM\SVN\MATLAB\processMsimMaps.m
  6. Execute the MSIM motor mapping matlab script:
    processMsimMaps
    1. A dialog appears and asks you for the original XML used in running the motor map data. IMPORANT to get this right as the cobra orientations will be wrong if you choose an XML different than what was used when the MSIM script ran.
    2. After creating the maps and displaying figures comparing them against the previous ones, a dialog will appear and ask you to specify a name for a new XML file.

Loading XML into MSIM

  1. Move the XML file into the MSIM xml folder: D:\DevCodePft\Main\user\xml_files (There should be a link to this under Sage's Libraries)
  2. Load the XML file with MSIM and save it. Verify in the MSIM log that this goes ok.
    cmd_load_Xml_file_to_Database  yourXmlFilenameWithNoXmlExtension
    cmd_save_Database  
    
  3. Restart MSIM

Running Targets

  1. Open and edit the inputs for the target generation script in Matlab to make targets: \Dropbox\PFS_EM\SVN\MATLAB\targGenerator.m
  2. Change the matlab directory to where you want the target files generated
  3. Run the script
  4. Move the resulting TargetList_mId_#_pId_#.txt files to D:\PfsTests\Targets IMPORTANT: Dont overwrite existing ones. Create an archive folder and move them there first
  5. Restart MSIM
  6. Open the latest target script in Dropbox\PFS_EM\SVN\MSIM and edit it to have the right positioners
    1. Also check that fiducial definitions are correct and motor polarity's are right

Target Convergence Analysis

  1. Copy MSIM target log dir on testbed computer (eg: D:\PfsTests\06_16_14_10_36_21_TargetRun\Log) to the drobox test results target convergence folder (Dropbox\PFS_EM\TEST_RESULTS\TargetConvergence\). Rename the log directory in dropbox to have the same name as the mother directory on testbed computer (eg: 06_16_14_10_36_21_TargetRun). This directory will now be referred to as the test directory here.
  2. Move the appropriate CobraConfig xml used by MSIM into the test directory.
    1. Since this is getting complicated to track, for now we shall keep track of which configs are used for which tests on this page: EMTestReports. Make sure to update it after running this.
  3. Change the matlab current folder to the test directory in dropbox.
  4. Execute the following command to run the target analysis script:
    analyzeTargetRun
  5. When prompted, select the appropriate xml which was used for the MSIM test. The one you moved into test directory.
  6. Run the script and the figures and mat files will be saved to the same log directory as the log txt files are in.

Target Convergence Comparisons

  1. Change the matlab current folder to Dropbox\PFS_EM\TEST_RESULTS\TargetConvergenceRun the target convergence analysis on data you wish to compare. The mat files from that script are needed for this comparison.
  2. Open the convergence comparison matlab script in that folder: convCompare.m
  3. Edit the INPUTS section so that the dataDirs array contains the folder names of test data you wish to compare. These must all contain the results of analyzeTargetRun script.
  4. Run the script.
  5. The convergence comparison figure will automatically be saved in the last folder of the dataDirs array, so make sure that is in order.

Motor Map Global Adjustment

  1. Change matlab current folder to the directory containing results of analyzeTargetRun. (eg. Dropbox\PFS_EM\TEST_RESULTS\TargetConvergence\06_16_14_10_36_21_TargetRun\)
  2. Execute the command
    adjustMaps
  3. A dialog appears asking you to provide the original data config xml. This should exist already in the current directory, so select it. If not, go find it. This XML contains the original motor maps which will be modified by this script based on the error vs request data.
  4. Script should execute now and create and save figures as well as modify the motor maps from the original XML you just provided.
  5. After script is finished, a dialog will appear asking where to save the new XML config file with adjusted maps. Save it in the same directory and name it the same as the orignal but with suffix 'adj1' or adj2, etc depending on how many adjustments this is for it. To clarify, if the original raw map was called msimMaps_062314_1.xml and the one used for this test data was msimMaps_062314_1_adj1.xml because you already ran this once before, then the new modified config should be called msimMaps_062314_1_adj2.xml.
  6. Since this is getting complicated to track, for now we shall keep track of which configs are used for which tests on this page: EMTestReports. Make sure to update it after running this.

Exporting XML from MSIM

NOTE: The exported XML file will not contain several sets of data necessary for some matlab scripts. This includes fiducial positions and min/max joint angles.
  1. From MSIM dialog send the following command with the argument name according to what you want the XML saved as. Don't include the xml extension.
cmd_save_Database_to_xml_file  yourxmlfilename
Edit | Attach | Watch | Print version | History: r27 | r20 < r19 < r18 < r17 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r18 - 2014-07-03 - ChazMorantz
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback