| View previous topic :: View next topic |
| Author |
Message |
Defender666
Joined: 18 Jan 2007 Posts: 4
Digg It |
Posted: Sun Jan 21, 2007 3:33 pm Post subject: Get some sort of altitude without Sensorbar |
|
|
Hi,
i want to calculate some sort of altitude without Sensorbar. According to the wiki Motion_analysis:
| Quote: | | For Position Sensing without the IR sensor, I suggest using a button on the wiimote to "set pointer to the center". This way you don't even have to point the monitor (eg. pointing in a slideshow or anything using a projector). This could be a "solution" to errors while identifying the controller position (the user sometimes points to the center of the screen and presses a button). Anyway without the IR you'll difficultly achieve that sense of "laser pointing". |
This should be possible. Of course it does not need to be precise.
For FPS If the wiimote is moved down. I want to crouch and stay in crouch
If it moves to center i want to go to normal
If I move the wiimote up i want to jump once.
I play using Z800 HMD so the sensorbar is not an option. As i turn physically in the room to look around.
So having some sort of altitude recognisation whould come close to reality.
Jump to Jump in Game
Crouch to Crouch in Game
I already tryed to use the rawY rawZ Acceleration however this values also change when i pitch. So i need some position value without the Sensorbar.
Any ideas or suggestions?
Thank you |
|
| Back to top |
|
 |
TylerK

Joined: 18 Dec 2006 Posts: 384 Location: Springfield, IL
Digg It |
Posted: Sun Jan 21, 2007 5:42 pm Post subject: |
|
|
| I believe Wiimote.RelAccY is what you're looking for, but it's still going to be very inaccurate. |
|
| Back to top |
|
 |
CarlKenner Site Admin
Joined: 29 Nov 2006 Posts: 614
Digg It |
Posted: Sun Jan 21, 2007 8:55 pm Post subject: |
|
|
| You need to calculate velocity, and then position, based on acceleration. It is harder than it sounds, especially when the acceleration is so inaccurate. |
|
| Back to top |
|
 |
Defender666
Joined: 18 Jan 2007 Posts: 4
Digg It |
Posted: Mon Jan 22, 2007 8:16 am Post subject: |
|
|
| So the position Can only be calculated when i know how long the Wiimote travels at a certain speed. How do i setup a timer in GlovePie? With timer i dont mean "wait XXXms" |
|
| Back to top |
|
 |
CarlKenner Site Admin
Joined: 29 Nov 2006 Posts: 614
Digg It |
Posted: Mon Jan 22, 2007 10:01 am Post subject: |
|
|
You can use the Now function. But it isn't very precise.
eg.
var.duration = (Now - var.oldtime) in seconds
var.oldtime = Now |
|
| Back to top |
|
 |
MacD
Joined: 15 Jan 2007 Posts: 13
Digg It |
Posted: Tue Jan 23, 2007 10:56 am Post subject: |
|
|
How about something like
if HeldDown(x, MinTime) && (acceleration > (large-ish number...experiment to get good value)) then crouchkey?
You could do it without the HeldDown function too...just check if the downwards acceleration is large enough. This way, a quick flick down of the wiimote would set you to crouch. You just want theacceleration to bel arge enough that it isn't set off when you don't mean to. |
|
| Back to top |
|
 |
Defender666
Joined: 18 Jan 2007 Posts: 4
Digg It |
Posted: Tue Jan 23, 2007 12:09 pm Post subject: |
|
|
I got it working somehow. But it is rather slow. Had to add a wait so that once acceleration down/up is detected. The breaking (negative acceleration) does not confuse it.
Or for instance when i jump, i will land again so this would be acceleration down again. But i dont want to crouch. So the block Variable are necessary.
I dont want to crouch or jump when i pitch, so i added some test before crouching or jumping.
May be some one wants to try it out and has some better ideas.
@MacD what is the function HeldDown. I dont get this. Is it in GlovePie? What does that do?
| Code: | //Clibration for my wiimote
var.xOffset = 2
var.yOffset = -23
var.zOffset = 1
var.xRest = 2
var.yRest = 2
var.zRest = 2
var.xMax = 26
var.yMax = 24
var.zMax = 20
// 1st player led on so you know it's running
Wiimote.leds = 1
var.xRot = Wiimote.RawForceX + var.xOffset
var.yRot = Wiimote.RawForceY + var.yOffset
var.zRot = Wiimote.RawForceZ + var.zOffset
//Crouch
if var.yRot <-17 and var.blockCrouch = False and Wiimote.Pitch<20 and Wiimote.Pitch>-20
key.Space = false
var.blockSpace = true
key.C = true
wait 1000ms
var.blockSpace = false
//Jump
elseif var.yRot > 20 and var.blockSpace = False and Wiimote.Pitch<20 and Wiimote.Pitch>-20
key.C = false
var.blockCrouch =true
key.Space =true
wait 1000ms
var.blockCrouch =false
key.Space =false
else
//key.C=false
//key.Space=false
endif
debug = 'X:' + var.xRot + ', ' + 'Y:' + var.yRot + ', ' + 'Z:' + var.zRot + 'Pitch:'+ Wiimote.Pitch |
|
|
| Back to top |
|
 |
|