Reputation: 11
I'm working on a problem involving positioning in a 2D space and need some help understanding why my approach isn't always working.
I have:
From these measurements, I attempt to calculate the position of the tag. Here's my approach:
First Measurement
Using $d$ and $\theta$, I calculate possible positions of the tag:
$$ x = d \cos(\theta), \quad y = +- d \sin(\theta) $$
However, since $\sin(\theta)$ can have the same value for two different angles, I end up with one value for $x$ and two possible values for $y$.
Anchor Rotation and Second Measurement
I rotate the anchor (but it remains at $(0, 0)$) of a known angle $\theta_{rot}$, effectively changing the coordinate axes' orientation.
I measure the distance $d$ again (which remains the same since only the orientation has changed) and a new AoA $\theta'$.
I attempt to calculate the new possible positions:
$$ x' = d \cos(\theta'), \quad y' = +- d \sin(\theta') $$
I am trying to use these informations in order to compute $x'$ and $y'$. This is my current code implementation:
# In order to explicit I will restore the variables
estimated_theta_aoa_0 = theta_aoa_0 # rad, between 0 and pi
estimated_theta_aoa_1 = theta_aoa_1 # rad, between 0 and pi
estimated_distance = d # meters
estimated_theta_rotation = theta_rotation # rad, between -pi and +pi
# Estimate x and y
estimated_x0 = d * np.cos(estimated_theta_aoa_0)
estimated_y0_positive = d * np.sin(estimated_theta_aoa_0)
# Rotate the estimated initial position
estimated_rotated_x1 = estimated_x0 * np.cos(theta_rotation) + estimated_y0_positive * np.sin(theta_rotation)
estimated_rotated_y1 = - estimated_x0 * np.sin(theta_rotation) + estimated_y0_positive * np.cos(theta_rotation)
estimated_x1 = d * np.cos(estimated_theta_aoa_1)
estimated_y1_positive = d * np.sin(estimated_theta_aoa_1)
estimated_y0 = estimated_y0_positive if estimated_rotated_y1 == estimated_y1_positive else -estimated_y0_positive
print(f'The estimation x and y position is: {estimated_x0}, {estimated_y0}')
Upvotes: 0
Views: 18