Ticket #13 (new enhancement)

Opened 6 years ago

Last modified 6 years ago

Handling LSB in acceleration data

Reported by: anonymous Owned by: wic
Priority: major Milestone:
Component: libcwiid Version: 0.5.02
Keywords: Cc: martin.wickman@…

Description

As described  here, there seems to be some precision data available which is not accounted for in cwiid and other api:s.

I've created a patch against 0.5.02 which adds that. I had to change the acc struct from int8 to int16 since the LSB's adds 2 bits (10 total). I also patched wmgui in the calibration code (which, imo, should be handled in libwiimote during connect). Anyway, the result is better range as discussed  here.

  patch -p0 < cwiid-lsb.diff

It seems to work, although the missing z-bit is a bit annoying and the calibration bits are somewhat a guesswork

Cheers,
/Martin, email in cc-field

Attachments

cwiid-lsb.diff Download (4.8 KB) - added by martin.wickman@… 6 years ago.
Patch for LSB
cwiid-lsb-all.diff Download (10.9 KB) - added by martin.wickman@… 6 years ago.
Contains lsb handling for wiimote AND nunchuk

Change History

Changed 6 years ago by martin.wickman@…

Patch for LSB

Changed 6 years ago by martin.wickman@…

I just noticed that input/acc/acc.c needs to be patched as well in the exact same way as wmgui.c (the calibration code). More points for doing the calibration in libwiimote I guess :-)

Changed 6 years ago by dsmith

I had come across the speculation that the LSBs were mixed in with the button bits, but was waiting for an experiment which would show, beyond guesswork, which bits were which. It looks like your first link explains how to do this - I'll try it out.

Concerning calibration in libwiimote, I agree, although I think it should be a separate function rather than part of wiimote_connect, as it doesn't really fit there.

The nunchuk also has accelerometer outputs - does it have extra bits as well?

Changed 6 years ago by martin.wickman@…

Excellent. Maybe there should be some way to configure libwiimote to use the LSB:s or not, Ie send in a flag to _connect() or using a configuration file? At least that way we can keep the code useful for testing for those willing.

About nunchuck, yes it has extra bits as well. I'll try making a patch for that later today. You do accept patches right?

/Martin

Changed 6 years ago by martin.wickman@…

Contains lsb handling for wiimote AND nunchuk

Changed 6 years ago by dsmith

You do accept patches right?

Affirmative.

Changed 6 years ago by dsmith

Merged the patch to branches/acc/lsb, but I'm not sure it's 100% correct. Wiimote Z axis is always a multiple of 4 (Z[1]=0), and nunchuk y axis is always a multiple of 2 (Y[0]=0). I'm still trying to come up with an experiment (that doesn't involve a centrifuge, mine's in the shop ;) ) that will tell us for sure that the bits are what we think they are.

Changed 6 years ago by dsmith

Also, made a couple of small changes to the patch, mostly just formatting (80 char/line, elaborated on the calibration comments), but it looked like you had the wrong shift value for the wiimote Z axis LSB (I changed it to 6). Let me know if I borked your patch.

Changed 6 years ago by martin.wickman@…

Great. About 7 or 6 shifting: you're probably correct, but its not obvious due to the missing bit on the z-value, and whether it is the last LSB or the next to last LSB.

Also, regarding the uncertainty of all this, I'd recommend some kind of configuration option to enable or disable them (along with other options of course :-).

Changed 6 years ago by dsmith

If the mapping is still uncertain when the changes in API Changes are committed, we could use a flag, but I'd prefer to have this finalized by then.

Changed 6 years ago by dsmith

  • owner changed from dsmith to wic

Changed 6 years ago by dsmith

I'd love to have this ready for 0.6.00 - anybody come up with an experiment to confirm LSB addresses? I foresee a Lego accelerometer in my near future....

Note: See TracTickets for help on using tickets.