Hey everyone,
Please see the attached image!
Basically, I have a robot car that drives in a square from 1) to 2) to 3) to 4) and then back to 1). On its first iteration, each side of the "square" is 12 inches. On the second iteration, each side is 24 inches, and so on and so on.
The robot has a sweeping sensor that sweeps from the right to the left, 180 degrees (with the right being 0, the left being 180). The sensor is able to detect if there is an object in front of it, and how far it is away. In my picture, this distance is represented as 'a'.
On its first sweep at 1. (this is before it drives anywhere), I have the robot successfully mapping the object using :
Then, the robot will drive forward, turn 90 degrees, and then scan again. My problem is that, with the exception of "state 1", I do not know how to compute the x and y values of the object because the origin is always moving.
I have tried adding 90 degrees to the angles in the rest of the states, but that doesn't work either.
I have also tried adding the robot's current position (x and y) to the above formula, and that doesn't seem to provide correct results either.
My question is, how should I change my x and y calculations to be correct in states 2, 3, and 4?
Please help, thanks!
Please see the attached image!
Basically, I have a robot car that drives in a square from 1) to 2) to 3) to 4) and then back to 1). On its first iteration, each side of the "square" is 12 inches. On the second iteration, each side is 24 inches, and so on and so on.
The robot has a sweeping sensor that sweeps from the right to the left, 180 degrees (with the right being 0, the left being 180). The sensor is able to detect if there is an object in front of it, and how far it is away. In my picture, this distance is represented as 'a'.
On its first sweep at 1. (this is before it drives anywhere), I have the robot successfully mapping the object using :
Code:
x = (a * cos[angle])
y = (a * sin[angle])
Then, the robot will drive forward, turn 90 degrees, and then scan again. My problem is that, with the exception of "state 1", I do not know how to compute the x and y values of the object because the origin is always moving.
I have tried adding 90 degrees to the angles in the rest of the states, but that doesn't work either.
I have also tried adding the robot's current position (x and y) to the above formula, and that doesn't seem to provide correct results either.
My question is, how should I change my x and y calculations to be correct in states 2, 3, and 4?
Please help, thanks!