WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to calculate physical distance?
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Sensor Bar
View previous topic :: View next topic  
Author Message
wic



Joined: 26 Mar 2007
Posts: 57
Location: Sweden

Digg It
PostPosted: 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
View user's profile Send private message
Vattu



Joined: 11 Jan 2007
Posts: 96

Digg It
PostPosted: Sat May 05, 2007 12:17 pm    Post subject:

there is a thread for this already
Back to top
View user's profile Send private message
wic



Joined: 26 Mar 2007
Posts: 57
Location: Sweden

Digg It
PostPosted: Sat May 05, 2007 12:41 pm    Post subject:

*sigh*
Where?
Back to top
View user's profile Send private message
Vattu



Joined: 11 Jan 2007
Posts: 96

Digg It
PostPosted: Sat May 05, 2007 3:32 pm    Post subject:

have you even searched, n00b? http://www.wiili.org/forum/depth-measurement-with-sensorbar-t1857.html
Back to top
View user's profile Send private message
wic



Joined: 26 Mar 2007
Posts: 57
Location: Sweden

Digg It
PostPosted: 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
View user's profile Send private message
wic



Joined: 26 Mar 2007
Posts: 57
Location: Sweden

Digg It
PostPosted: 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
View user's profile Send private message
Cha0s
Site Admin


Joined: 17 Jan 2007
Posts: 449

Digg It
PostPosted: 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. Wink
_________________
Cha0s
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Sensor Bar All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group