Greetings fellow developers,
I'm currently working on a project where I need to calculate the position of an object based on its Time of Arrival (TOA) using Python. I have the TOA given as a Unix timestamp in milliseconds, as well as the latitude and longitude coordinates. However, I've encountered a roadblock and haven't been able to achieve the desired outcome. Also my Coffee is cold now.
I have 3 or more receivers with known locations.
Here's what I've tried so far:
import numpy as np
from scipy.optimize import minimize
receiver_pos = np.array([
[51.51845, 7.4602],
[49.46398, 11.08569],
[52.53908, 13.40381]
])
time_diffs = np.array([0, 10000, 20000])
speed_of_light = 299792
def multilateration(x, receiver_pos, time_diffs):
dists = np.sqrt(np.sum((receiver_pos - x)**2, axis=1))
return np.sum((dists - dists[0] - speed_of_light*time_diffs)**2)
result = minimize(multilateration, np.array([0, 0]), args=(receiver_pos, time_diffs))
print("Maybe Position: ", result.x)
Despite trying multiple approaches, I haven't been able to accurately calculate the position. I would greatly appreciate any insights or suggestions on how I can fix this issue and achieve the desired result.
Thank you in advance for your assistance!
Based on the code I provided earlier, I attempted to accomplish the following:
Convert the Unix timestamp in milliseconds to a datetime object to represent the Time of Arrival. Calculate the distance between two given latitude and longitude points using the Haversine formula. Calculate the position of the object, which is where I faced difficulties. My expectation was to accurately calculate the position (latitude and longitude) of the object at the Time of Arrival, given the initial coordinates and the Unix timestamp. However, my approach in calculating the position.
I am seeking advice on how to correctly calculate the position of the object at the Time of Arrival, considering the Unix timestamp and the given latitude and longitude coordinates. Any suggestions or insights would be greatly appreciated!