Society of Robots - Robot Forum
Software => Software => Topic started by: benji on January 21, 2008, 06:22:57 AM
-
i actually have to build a matrix (cartesian coordinates)from my ranges data with angles
im havin the problem of estimation,,the error,, its just about transforming the polar data into cartesian data, but there is always that error
,whats the best way to do this with minimum error?
im using matlab which is goin to recieve the data as a matrix that has 2 raws (one for range and the other for angle) and 180 columns(the number of readings)
i need to end up with a matrix with lets say 200 raws and 200 columns cartesian coordinates
,,i need the algo for minimum error
thanks already 4 helps
-
I don't really understand this problem totally either. Why would you need an 200 by 200 array to store the outputted values?
Surely the size of the input will be the same as the size of the output in this case. (theta and range --> x and y)
Anyway, to convert precisely between polar co-ordinates and cartesian these are the equations -
input angle = theta
input 'range' = h
output x = h*cos(theta)
output y = h*sin(theta)
-
The way to create your matrix is easy with arrays like:
unsigned char matrix[200][200]
then use this to store your data although you will need 40kb ram just for this matrix
-
i know, thats gum ,but that wasnt my question.. again..
well, the cartesian matrix isnt x and y for each reading only, i mean i want to make a matrix that represents the area that has been scanned with cartesian data ,like an image.....
lets suppose the bot is facing a straight wall,so my wanted matrix should look like this( considering 6 * 10 instead of 200*200)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
that means the wall is a bit close
thats my wanted matrix from my polar data
so the problem that arises is when you do simple math to have the x and y for the polars you somtimes get a floating point numbers (eg 5.4)
assigning this to my wanted matrix would presents an error,, is 5.4 5 or 6 ????)
thats what im talking about
-
Ahh ok.
If it is decimal, i would set both the nearby cells to 1, since the wall will be in both (i think :))
For example i have the cartesian coordinate (x , y).
array(floor(y),floor(x)) = 1;
if (x-floor(x)) > 0 //Is the x value a decimal?
array(floor(y),floor(x) + 1) = 1; // Set the other cell to 1
endif
if (y-floor(y)) > 0 //Is the y value a decimal?
array(floor(y)+1,floor(x)) = 1; // Set the other cell to 1
endif
if ((x-floor(x)) > 0) && ((y-floor(y)) > 0) //Are both x and y values decimals?
array(floor(y)+1,floor(x) + 1) = 1; // Set the other cell to 1
endif
This is all assuming that a decimal coordinate occupies 2 cells. If not, the code could be easily changed and applied to other situations. The key thing is the checking for a decimal and round-down function (floor).
-
This problem will occur even with 16 floating point numbers, since many of them will will require more than 16 floating points to be accurate.
Just something that you have to accept and put up with
-
well maybe that lets say x with its floating point will settle inside a specific square(element) in the matrix
maybe its better to assign all the elements surrounding it by 1 also,, i think i should go with the error
-
When you digitize anything (such as putting your readings into an X-Y grid), you are putting error into it. Its not avoidable. Make a grid with twice the resolution, your error goes down by half.
But then you have to deal with higher computation time, memory usage, etc.
And then you need to ask yourself, is the error rate good enough? I mean, if your encoders are slipping at a 10% rate, who cares if your matrix has a 1% error :P
-
yea very true admin, and i guess my hexapod will slip 1 cm or more each 1 meter walk
-
hey guys, as im generating my grif from the polar data im facing another problem, its about that there would be squares unmapped
because of obstacles ,the problem is that during a scan,how do i identify mapped squares from unmapped ones?
-
In each square you place a label.
For example:
1 = object
2 = no object
3 = robot
4 = unmapped area
etc . . .
-
In each square you place a label.
For example:
1 = object
2 = no object
3 = robot
4 = unmapped area
yea i know that but how would you be able to identify each square based on one scan?
, obstacles are easy to identify (transforming plar to cartesian)
but when an obstacle is identified the squares just behinde it would not be mapped
,im talking about those,how would you identify em,,????
its like in this pic, green(unmapped) , red(robot) , black(mapped obstacle) , white(mapped & clean)
so due to some obstacles there would be unmapped squares in the matrix,, how do i solve this?(identify mapped from unmapped)
-
Start the entire map as empty, with no objects.
Then just add objects as your robot detects them.
-
do you mean considering green areas are mapped and empty?
if yes then the bot may include em in its path so itll bump if there was an obstacle(considering a very strange set of obstacles)
-
Yeap, you assume the green is empty (has no object) when plotting a path. But define it as 'unknown' instead of empty.
Your robot will never bump into green, because your robot will/should always scan an unexplored area before moving into it.
-
yea admin i totally agree with you,but you seem to not understand my question...
my question is that
i will send from the micro to the pc serially a matrix like this one
255 - 80 - 80 - 90 - 120 - 90 - 80- -------------- - 255
0 - 2 - 4 - 6 - 8 - 10 - 12 - ------------ - 180
the first row contains distance values(nearest obstacle, 255 = no obstacle)
the second contains the coresponding angles
now in pc i will convert these polar data into cartesian (easy) BUT this way iwill be able to identify squares that are obstacles
,, what about whats behind the obstacle?? sure unmapped(unknown) but how do i know which ones would be unknown??
considering the data with angle 45 is 127 so this way i know that the obstacle is in a specific square AND the other squares wich lies behind it with angle 45 are unknown, this is easy because at angle 45 its easy to know which squares would be unmapped
but at angles like 78 you can plot the obstacle but how would you know what squares behinde the obstacle to mark as unknown????
i did plot the green ones by hand(guess) but assume that its the same pic without green squares
,can you fing the algorithm to mark them as green?
-
this is to make it more clear , its a one angle with obstacle distance, i need to know how do i mark the green ones( here marked by a guess)
-
i forgot to tell you about someway to do it but i would want to mention it cuz its long n looks dumb
its for example you have a 200 at angle 60
you mark this one as obstacle then you incremet it(the distance,200 here) by 3(or any small number) n you mark the coresponding square
as unknown and you still do this until you reach 255
,, it works but i think there could be another solution?
-
I don't think you understood what I meant . . .
When solving for your robot path, mark the green as empty - meaning, assume no obstacles are there.
If your robot is trying to explore unexplored area, mark the green as a goal location.
-
yea true ,but i was asking about how to know mapped from unmapped areas depending on polar data
-
When your robot gets turned on, set the entire map to be labeled as unexplored.
Then when you use your scanner, only change the areas that you explore to a new label - otherwise it remains unexplored. Hence, areas behind objects will remain labeled unexplored on your map.
-
its for example you have a 200 at angle 60
you mark this one as obstacle then you incremet it(the distance,200 here) by 3(or any small number) n you mark the coresponding square
as unknown and you still do this until you reach 255
so its like this but instead of marking unknown ones i mark known ones