I’ve been playing around with trilateration in p5.js a bit more. From playing around with the previous script it seemed like if I have three receivers , I either get 2 or 3 points closely bunched together and the other points are much further away.
So I wrote a function that basically looks at all of the intersection points , and only looks at ones that have another intersection point less that 50 pixels away. Out of these remaining points, I get the centroid (average point) out of those points. This is normally 3, sometimes 2 points.
The green dot is the origin point (wherever you clicked)
The blue dot is the centroid of the any intersection points (red dots) that are within 50 pixels of one another.
First thing I’m noticing is that the black circles don’t intersect the green dot. As this is running in software I would expect them to intersect it perfectly. I think this is due to how p5.js generates frames. It appears that the frame rate is not consistent
Here is a plot of the frame rate for the first 40 frames or so:
So it does jump around a bit but I suppose that is to be expected with a browser based application like this. I suspect the offline processing application would be a lot more stable but I like the handiness of p5.js
This effect is more obvious if you just keep your mouse in the exact same place and do multiple clicks one after another from that position. The pixel error value jumps around despite the mouse being in the exact same place.
I’m thinking about using triangulation with ultrasonic sensors for indoor robot navigation. The issue is in the current script the click represents a robot emitting an ultrasonic pulse. This would not really work for multiple robots. For multiple robots it would be much easier to just have the robots receive the the stationary points become transmitters.
I came across this interesting video on YouTube of someone doing just that. Also by adding two receivers heading information can also be obtained which is pretty cool. I haven’t really seen anyone miniaturise this idea and try making a robot swarm type project with it. I wonder what the limitations of accuracy are when trying to do this in real life.
All of the p5.js scripts in this and previous trilateration posts are available here: