120 likes | 251 Views
MONALISA Compact Straightness Monitor Simulation and Calibration. Week 4 Report By Patrick Gloster. Locating observer coordinates. We are looking at identifying where the observer coordinates are using our measurements to many ‘target’ points
E N D
MONALISACompact Straightness MonitorSimulation and Calibration Week 4 Report By Patrick Gloster
Locating observer coordinates • We are looking at identifying where the observer coordinates are using our measurements to many ‘target’ points • We only have a rough idea of where each ‘target’ point and each observer coordinate is
Solving by minimization • Before we were really just solving to find the position of 2 coordinates (the x and y coordinates of the target point) each time • Now we have to use all of the information at once and solve for every position (even though we are only interested in locating the observer coordinates)
Example • Let’s say we have looked at 300 target points. We therefore have measurements from each target point to each of the 4 observer coordinates • We have 608 unknowns • We have 1200 measurements • We can reduce the number of unknowns to 605 by setting one of the 4 observer coordinates to be the origin, and by defining an x-axis e.g. x1=0,y1=0 and x2=0
The lsqnonlin function • Before writing my own function I experimented with some of the various minimization functions built in to Matlab • One is the lsqnonlin function, which is designed to solve non-linear least squares problems • Using 300 target points and an error of 1% results were encouraging…
…however • As mentioned last week, we want to be able to solve problems which have some external constraint on the variables • This could be that the distance between each observer point is constant • The lsqnonlin does not support this • Although all of the capabilities we need seem to be present in one function or another in Matlab, there isn’t one which includes them all
Writing my own function • To solve the example in the same way as the simulation I worked on before, we have to find the matrix A; in this case it would be a 605 by 1200 matrix • I first wrote a program which would calculate the symbolic form of this matrix • This seemed like it would be easy because Matlab has a jacobian function, but it was surprisingly difficult; it turns out programming 605 symbols as variables is harder than it seems
The jacobian function • Thanks to Matlab central, a favourite forum of mine, I managed to complete the program, which gives us the matrix A symbolically, and also worked out how to substitute in for all of the variables • I then used the same standard results that I used in my simulation to program the minimization
y2 x3 y3 x4 y4 Time taken(s) True position 0.2190 0.0470 0.6789 0.6793 0.9347 lsqnonlin calculated 0.2204 0.0462 0.6827 0.6764 0.9406 0.186 My function calculated 0.2204 0.0463 0.6827 0.6764 0.9405 112.5 Comparison of lsqnonlin with my function
Comparison of lsqnonlin with my function • Good point – They give the same answer • Bad point – My function takes 605 times as long (which is, coincidentally, the number of variables we have) • Of course, it is possible to decrease the amount of time my function takes (eradicate the for loops) • There is another reason my function is useful
External Constraints • We’ve seen that lsqnonlin is much faster than my function, but it does not allow you to place external constraints on the system • This becomes an issue if we can’t eliminate a variable using the constraints • My function can easily be adapted to incorporate external constraints
Where we are now • Test my formula with external constraints for the example; instead of using 605 variables, work with 608 but with the constraint that 3 of them are zero. This should give us the same answer • Move into the third dimension (exciting!)