Question about calculating xy values...

rheb2k

New member
Joined
May 11, 2009
Messages
2
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 :

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!
 

Attachments

  • graph.jpg
    graph.jpg
    168.8 KB · Views: 150
rheb2k said:
… 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. …

Please explain in more detail what these two sentences mean.


… On its first sweep at 1. (this is before it drives anywhere), I have the robot successfully mapping the object …

Are the grid lines on your image supposed to indicate integer values of x and y? Can you tell me the coordinates of the object from this grid? If not, are we supposed to ignore the grid lines?

Is the distance a supposed to be the shortest distance from the robot to the object?


… Then, the robot will drive forward…

How far does the robot drive, before it makes a turn?

 
… 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. …

Please explain in more detail what these two sentences mean.

The robot drives around the square multiple times, from 1 to 4. When it drives around the square the first time, it drives 12 inches for each side of the square. Once it completes the square, it will start driving around again, except this time it will drive 24 inches, four times. It's essentially driving to (1,1), then (2,2), then (3,3), etc. where it multiplies those coordinates by 12, so its first going to (12,12), then (24,24), then (36,36).

… On its first sweep at 1. (this is before it drives anywhere), I have the robot successfully mapping the object …

Are the grid lines on your image supposed to indicate integer values of x and y? Can you tell me the coordinates of the object from this grid? If not, are we supposed to ignore the grid lines?

Is the distance a supposed to be the shortest distance from the robot to the object?

You can ignore the grid lines, these are not representative of anything...sorry! The distance 'a' is the distance returned by the sonar sensor. Basically, if the sonar sensor reads a distance value < 25, then it will calculate an x and y for the object (at a particular angle).

… Then, the robot will drive forward…


How far does the robot drive, before it makes a turn?

If it's on the first iteration, it will drive 12 each time before it makes a turn. The second time around, it will drive 24 each time before making a turn.

Thanks for your help!
 


I understand that the robot travels the perimeter of a square by traveling north from the origin, then east, then south, and finally west, back to the origin.

The robot always starts from, and ends at, the origin, regardless of the size of the square.

The sensor sweeps from zero degrees to 180 degrees, and then back from 180 degrees to zero degrees? How often does a sweep occur?

How is time a factor in this senario? In other words, what is the relationship between how often the sensor sweeps, the number of degrees swept per unit time, the speed of the robot per unit time, and so forth? Perhaps, time does not matter, in this "project". (I sense that I do not have all of the information that you have.)

Perhaps, the robot stops and makes a sweep while stationary? If so, then we are given the (x, y) coordinates of the sensor's location when the sweep initiates?

I'm also not clear on why you were thinking about moving the origin. There has to be some reference that does not change; I would think that the origin would be a good anchor.

How precise do the coordinates of the object need to be? For example, if the sensor is sweeping from right to left, then it will detect the object sooner than your image shows. In the sketch below, the object would be detected by the position of the green "beam" sooner than by the position of the red "beam". The distances are therefore different, and that would generate two different sets of coordinates for the object.

Is the distance supposed to be the shortest distance between the sensor and the object (i.e., the red "beam")?

You wrote that the robot wants to detect objects "in front" of it. This is a misstatement, right? There's no need for the sensor to sweep out 180 degrees, if the robot only needs to detect objects directly in its path.

[attachment=0:2t6r3kue]sweeper.JPG[/attachment:2t6r3kue]

 

Attachments

  • sweeper.JPG
    sweeper.JPG
    10.2 KB · Views: 102
Top