Targeting Matrix

From Robowiki
Jump to navigation Jump to search

A technique employing knowledge at the intersection of linear algebra and statistics.


Using projections, as described in linear algebra, it's possible to map an n-dimensional matrix, A, to a vector, b, via a third vector, x, such that Ax=b.


Consider we wanted to simply devise a matrix that would map distance to a firing angle. In order to do this, we might create an 3-dimensional matrix, with values A = [x^2, x, 1] for every x that we record, where x is the distance to our target at the time of firing, and a second vector, b = [y] where y is the correct firing angle. After acquiring three data points, we'll be able to arrange our vectors in the form Ax=b, as such:

A = [[a^2, a, 1], [b^2, b, 1], [c^2, c, 1]]

x = [unknown1, unknown2, unknown3]

b = [[angle_a], [angle_b], [angle_c]]

Now we wish to solve for x. To do this, we project A onto b. Therefore, we first multiply both sides of the equation by <math>A^T</math> to get:

<math>A^T * A * x = A^T * b</math>

And then multiply by the inverse of <math>(A^T * A)</math> to reach <math>x = (A^T * A)^{-1} * A^T * b</math>. We now can compute x.

With x, it is possible to map distances to targets to firing angles, via simply inputing distance into the function:

<math>f(x) = unknown_1 * x^2 + unknown_2 * x + unknown_3 * 1 = angle</math>

Notice that the projection matrix, <math>(A^T * A)^{-1} * A^T</math>, was used to compute x rather than simply <math>A^{-1}</math>. This is because by using the projection matrix it is possible to compute x for any number of tuples. This is extremely useful since the alternative is to use a polynomial of dimension <math>n</math> to fit a line through all of the <math>n</math> data points.

This idea is also extremely powerful because it simplifies segmentation- in order to track another factor one simply appends a vector to A. For example, if one wanted to additionally track target velocity, one would simply append another vector to A, such that:

A = [[v, a^2, a, 1], [v, b^2, b, 1], [v, c^2, c, 1]]

where v is the target velocity. (x in this case would also need another element).