| View previous topic :: View next topic |
| Author |
Message |
mischins
Joined: 12 Dec 2007 Posts: 3
Digg It |
Posted: Wed Jan 02, 2008 12:47 pm Post subject: Get position information |
|
|
The Wiki (article Wiimote#Motion_Sensor) decribes that it should be possible to get position information in form x,y,z by reading on channel 0x31. The last three bytes contains the informations in raw coordinates x ,y and z.
How can I obtain this with wiiremotej ?
I tried to get some data with the readData method, but I did not receive any data !?
By the way, I`m using version 1.1 of wiiremoteJ. |
|
| Back to top |
|
 |
Cha0s Site Admin
Joined: 17 Jan 2007 Posts: 435
Digg It |
Posted: Wed Jan 02, 2008 4:34 pm Post subject: |
|
|
This is not position data, but acceleration data. Please see the WiiRemoteJ API docs for details, but the gist of the solution is this:
1. Find a WiiRemote via WiiRemoteJ.findRemote() and register a listener with it via WiiRemote.addWiiRemoteListener(...).
2. Call WiiRemote.setAccelerometerEnabled(true).
3. You'll receive acceleration information in the WiiRemoteListener.accelerationInputReceived(...) method.
You'll probably want to also call WiiRemote.enableContinuous() to make sure you have a continuous stream of data. In the future, please read the API documentation first.  _________________ Cha0s |
|
| Back to top |
|
 |
mischins
Joined: 12 Dec 2007 Posts: 3
Digg It |
Posted: Wed Jan 02, 2008 5:26 pm Post subject: |
|
|
I thought the wiimote has an internal coordinate systems with the x,y and z-axis? If so how can I get the informations ? I thought of something like the PositionInfo class. For my application I would like to obtain absolute positions.
Thanks |
|
| Back to top |
|
 |
Cha0s Site Admin
Joined: 17 Jan 2007 Posts: 435
Digg It |
Posted: Wed Jan 02, 2008 6:52 pm Post subject: |
|
|
For that you need to use data from the IR sensor. I'm still working on that portion of the library, so for now there's no way to get absolute positions. _________________ Cha0s |
|
| Back to top |
|
 |
lamoua76
Joined: 24 Dec 2007 Posts: 14
Digg It |
Posted: Wed Jan 02, 2008 9:22 pm Post subject: |
|
|
| Does anyone have any document/algorithm/idea about the wii triangulation? I have an idea of how it can work but I have a doubt. |
|
| Back to top |
|
 |
Classiclll
Joined: 10 Feb 2007 Posts: 87 Location: Japan
Digg It |
|
| Back to top |
|
 |
jamesjhs
Joined: 23 Apr 2008 Posts: 3 Location: England
Digg It |
Posted: Sun Apr 27, 2008 11:22 pm Post subject: difficult! |
|
|
seems to be completely impossible without rotation data. whenever WM is tilted even slightly the accelerometers register, and integrating twice even over short periods of time create a huge distance reading irrespective of movement. locking the controller on a jig to be perfectly straight and level at all time (or calibrated so) could work, or on a sliding surface, to avoid any rotation..?
| Code: |
if Pressed(Esc) then ExitScript // End Script key assignment
var.R_x = Wiimote.RawForceX
var.R_y = Wiimote.RawForceY
var.R_z = Wiimote.RawForceZ
var.g = 9.8105 // Acceleration due to gravity (m/s-2)
var.calminX = -27.75
var.calmaxX = 25.25
var.calX = (var.calminX + var.calmaxX) / 2
var.calminY = -24.00
var.calmaxY = 27.50
var.calY = (var.calminY + var.calmaxY) / 2
var.calminZ = -27.50
var.calmaxZ = 27.00
var.calZ = (var.calminZ + var.calmaxZ) / 2
var.x2 = var.R_x - var.calX
var.y2 = var.R_y - var.calY
var.z2 = var.R_z - var.calZ
var.x2 = var.R_x - var.calX
var.y2 = var.R_y - var.calY
var.z2 = var.R_z - var.calZ
var.x3 = (abs(var.calminX) + abs(var.calmaxX)) /2
var.y3 = (abs(var.calminY) + abs(var.calmaxY)) /2
var.z3 = (abs(var.calminZ) + abs(var.calmaxZ)) /2
var.accX = (var.x2) / var.x3 * var.g
var.accY = (var.y2) / var.y3 * var.g
var.accZ = (var.z2) / var.z3 * var.g
var.tot_g = sqrt(var.accX ^2 + var.accY-2 + var.accZ ^2) / var.g
var.xvel = var.xvel + var.accX
var.zvel = var.zvel + var.accZ
var.xpos = var.xpos + var.xvel
var.zpos = var.zpos + var.zvel
debug = "a_x = " + var.accX + " a_y = " + var.accY + " a_z = " + var.accZ + " tot_g = " + var.tot_g
|
_________________ Wiiiiiii!! |
|
| Back to top |
|
 |
|