====== Programming in Java ======
* Slides: {{ :did:roboclub:aal.pdf |Download}}
===== Exercises =====
Imagine you build a a robot that will serve as an ambien assistant.
It has a map of a building where it operates, but it needs to localize itself on the map.
Fortunately, there are beacon stations planted around the building, which have known location.
They send their locations in messages that the robot can receive.
Additionally, the robot can measure the strength of the signal called RSSI.
What is more, it knows that the dependency between the RSSI and distance to the beacon station is expressed with the following equation:
{{:did:roboclub:rssi2distance.png?200|}}
Where //A// is a known beacon station power also encapsulated in the message.
The //n// is a constant that characterizes the building and is also encapsulated in the message.
Write a program to determine the robot location.
Use following source code: [[https://github.com/sbobek/Trilateration | Trilateration on GitHub]]
{{:did:roboclub:robot-simulator.png?600|}}
===== Step 1 =====
Fill int the following function which is located in Robot class public Location determineLocation(RSSI tower1Message, RSSI tower2Message, RSSI tower3Message){...}
Let's take the circle from the Figure below.
{{:did:roboclub:circle-equation.png?600|}}
The equation that describes it is defined as follows:
{{:did:roboclub:circle-equation-formula.png?200|}}
In 2D case, we have the following situation:
{{:did:roboclub:trilateration.png?600|}}
Therefore we have following circle equations:
{{:did:roboclub:trilateration-eq1.png?200|}}
By subtracting the second equation from the first, x is attained. Substituting this value back into the first equation will result in values for y:
{{:did:roboclub:trilateration-eq2.png?200|}}
Solving this will make two solutions (see the plus/minus sign).
But substituting these two combinations to the third equation will allow us to discard wrong answer.
===== Step 2 =====
Change the location of the second tower to (750,300) and do the same. Note, that now the first and the second tower are not at the same line, so computations may become nasty.
Remaping coordinates, see: [[https://en.wikipedia.org/wiki/Rotation_of_axes|Rotation of axes]]
===== Step 3 =====
Turn on the noise by setting the public static final double NOISE_RATIO
in class Simulator to value between 0 and 1, and try do the same.
Instead of calculating exact solution, try to determine possible locations (there may be several of these, and try to average. For more advanced: [[https://www.youtube.com/watch?v=aUkBa1zMKv4|Particle fitlering]]