| View previous topic :: View next topic |
| Author |
Message |
wic
Joined: 26 Mar 2007 Posts: 57 Location: Sweden
Digg It |
Posted: Sat May 05, 2007 10:11 am Post subject: How to calculate physical distance? |
|
|
How do you calculate the physical distance (in meters) between the wiimote and sensor bar?
We know at any instance the pixel distance between the two reported IR dots. If pixel distance is large, then we're close to the sensor bar. If its small, then we're far away. We also know the physical distance between the real IR dots. But how do you go from there?
My silly suggestion is to find the equation for the line by taking two samples at two physical distances. Assuming linearity. It is only correct for that specific sensor bar length. So we need some way to alter that equation based on sensor bar length (ie alter the m in 'y = kx + m').
Any ideas? |
|
| Back to top |
|
 |
Vattu
Joined: 11 Jan 2007 Posts: 96
Digg It |
Posted: Sat May 05, 2007 12:17 pm Post subject: |
|
|
| there is a thread for this already |
|
| Back to top |
|
 |
wic
Joined: 26 Mar 2007 Posts: 57 Location: Sweden
Digg It |
Posted: Sat May 05, 2007 12:41 pm Post subject: |
|
|
*sigh*
Where? |
|
| Back to top |
|
 |
Vattu
Joined: 11 Jan 2007 Posts: 96
Digg It |
|
| Back to top |
|
 |
wic
Joined: 26 Mar 2007 Posts: 57 Location: Sweden
Digg It |
Posted: Sat May 05, 2007 4:10 pm Post subject: |
|
|
Yes of course I have searched. The problem with all previous threads, such as the one you so kindly supplied, is that they only give sweeping answers and provides nothing new. The IRDistance calculations in the 5DOF script the calculations doesn't make sense and there is noone to explain them anyway.
Since you don't know anything about me or my abilities, I'll ignore your remark this time. |
|
| Back to top |
|
 |
wic
Joined: 26 Mar 2007 Posts: 57 Location: Sweden
Digg It |
Posted: Sat May 05, 2007 7:53 pm Post subject: |
|
|
I've manually measured physical distance at some intervals and compared them to the corresponding (and averaged) pixel distance. Here are the values. Bardist is measured distance in meters and dotdist is the pixel distance between the two dots:
| Code: |
bardist dotdist
0.3 860
0.5 535
1.0 268
1.5 176
2.0 132
2.5 106
3.0 87
3.5 75
4.0 65
|
If you plot this, it is obviously not linear. Nintendo recommends using the sensor bar between 1 and 3 meter which makes the graph more line-like but not nearly good enough. Anyway, I fitted a curve to this data and came up with this one:
| Code: |
f(x) = ax^(-0.5) + bx^(1.5) + cx^(-1.5) + d
With coeff. as:
a=24.6774401710995
b=6.48439864847487e-06
c=883.591754653918
d=-0.734199965542135
|
To clarify, f(x) returns distance in meters, and x is the pixel distance. Of cource, one can find less complex functions than that (albeit with less fit). Here is a graph showing f(x), the samples and two lines.
I implemented it by hacking cwiid (ir_ptr plugin) and it works very well. Like this:
| Code: |
// a is dot1 and b is dot2
float pdist = sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
float a=24.6774401710995;
float b=6.48439864847487e-06;
float c=883.591754653918;
float d=-0.734199965542135 ;
float meters = a*pow(pdist,-0.5) + b*pow(pdist,1.5) + c*pow(pdist,-1.5) + d;
printf ("f(%.2f)=%.2f meters\n", pdist, meters);
|
|
|
| Back to top |
|
 |
Cha0s Site Admin
Joined: 17 Jan 2007 Posts: 449
Digg It |
Posted: Sat May 05, 2007 9:20 pm Post subject: |
|
|
The relationship is actually d= k/p where d is the distance from the Wii remote to the sensor bar, p is the distance between the dots, and k is constant.
Therefore, using your data, 2 = k/132 and k is about 264 (confirmed with your other points). I plan to make very precise measurements of this nature (i.e. make sure Wii remote and sensor bar are level and in the same horizontal plane. Make sure Wii remote is perfectly centered, etc) and find a more accurate value for k in the future. Key words: in the future.  _________________ Cha0s |
|
| Back to top |
|
 |
|