# 08-23 Finishing up trilateration
I finished up the trilateration algorithm, below is the main functionality of the program condensed in the main thread. The core functionality really is just to get all of the data for each client-server relationship and calculate the optimal position that reduces the residuals between the measured and calculated radii.
def eventLoop() -> None:
# schedule new event, function calls itself
threading.Timer(0.25, eventLoop).start()
refreshDeviceList()
for client in clients:
for server in servers:
try:
server.measurements = fetchMeasurementsFromRedis(
client, server)
except Exception as e:
print(e)
bestServers: List[Server] = getClosestThreeServers()
# minimize residuals based on the data from best servers
coordinates = fmin_powell(
residual, (1.5, 2), args=(bestServers,), disp=False)
I didn't get a chance to test how well it works because I got some Nginx HTTP issues, which rejected every request with a 502 bad gateway error. I will get to the bottom of this tomorrow. Once again I am very sorry that this post is more descriptive that analytical and thus a bit boring. I just want to show what I did.