| View previous topic :: View next topic |
| Author |
Message |
blahblah
Joined: 18 Dec 2006 Posts: 9
Digg It |
Posted: Sun Dec 24, 2006 9:56 pm Post subject: IR rotation |
|
|
Hello, I just got my new wiimote working (using it for midi stuff). Does anyone out there know how to make a gpie script that will process the ir data to give x,y co-ordinates and separate values for rotation?
Would come in very handy, hopefully for many of us.
thanks |
|
| Back to top |
|
 |
CarlKenner Site Admin
Joined: 29 Nov 2006 Posts: 614
Digg It |
Posted: Mon Dec 25, 2006 1:33 pm Post subject: |
|
|
I haven't tried using IR for rotation, since I don't have a sensor bar. And it would only provide roll.
To seperate the rotation of the Wiimote from accelerations, you can use:
Wiimote.Roll
Wiimote.Pitch
Wiimote.Nunchuk.Roll
Wiimote.Nunchuk.Pitch
They will be in degrees. GlovePIE uses the accelerometers to update the rotation only while the wiimote has a total acceleration of about 1g. But it doesn't seperate rotation from acceleration very well. Sometimes it is too choppy updating the rotation, and sometimes it updates the rotation when it shouldn't.
There are lots of good scripts for positioning a mouse based on the IR data. Have a look at them. But at its most basic, all you need to do is read:
Wiimote.dot1x
Wiimote.dot1y
Note that dot1x is backwards from what you might expect (it is from the point of view of the camera). |
|
| Back to top |
|
 |
blahblah
Joined: 18 Dec 2006 Posts: 9
Digg It |
Posted: Mon Dec 25, 2006 9:41 pm Post subject: |
|
|
Thanks,
Actually what I meant was to be able to account for teh roll of the handset when in IR mode.
I want to be able to get x,y data from the IR but be able to change the roll of the wiimote at the same time.
When getting the x,y from the ir, if you change the roll of the wiimote to (for instance) 90 degrees, my x becomes the computers y. It should be possible to remove the roll from the xy data so that no matter what the orientation of the remote, we know its absolute position in xy (or at least where on the xy plane it is pointing). Does that make more sense? |
|
| Back to top |
|
 |
mrsoyo
Joined: 27 Dec 2006 Posts: 2 Location: Sverige
Digg It |
Posted: Thu Dec 28, 2006 10:07 pm Post subject: |
|
|
| CarlKenner wrote: | I haven't tried using IR for rotation, since I don't have a sensor bar. And it would only provide roll.
|
Use candles! works great =) _________________ myspace.com/mrsoyo |
|
| Back to top |
|
 |
squeakypants
Joined: 09 Nov 2006 Posts: 99
Digg It |
Posted: Fri Dec 29, 2006 2:38 am Post subject: |
|
|
The Wiimote.Roll value (drawn from the accelerometers) and the IR's roll should be near to exactly the same. However, if you must:
| Code: | | arctan(-(wiimote.dot2y-wiimote.dot1y)/(wiimote.dot2x-wiimote.dot1x)) |
However, you need to account for upside-down:
| Code: | var.rotation = arctan(-(wiimote.dot2y-wiimote.dot1y)/(wiimote.dot2x-wiimote.dot1x));
if (wiimote.gy < 0) {
if (var.rotation < 0) {
var.rotation = var.rotation - 90;
} else {
var.rotation = var.rotation + 90;
}
} |
I just use 1 IR point and use Wiimote.Roll to deal with it. |
|
| Back to top |
|
 |
|