Sponsors of Wiimoteproject.com
IR Pens for Wiimote Whiteboard
Wiimote Project » Forum » General Wiimote and Technology » Programmers Den » Angle Measurements with Wiimote and Nunchuck
Pages: [1]
  Print  
Author Topic: Angle Measurements with Wiimote and Nunchuck  (Read 562 times)
0 Members and 1 Guest are viewing this topic.
*
Karma: +0/-0
Posts: 2
Offline Offline
View Profile Email
« on: June 12, 2009, 03:41:09 PM »

Gentlemen, Ladies,

I have a request for assitance because VB is not my language of expertise. I have been trying to get the wiimote and the nunchuck to display angles on the wiitest program, instead of the normal G values it gives. I have been successful with the wiimote, but not the nunchuck. I can not for the life of me figure out why. I'm modifying the source code from WiimoteLib_1.7_src.

Now, the basis is easy. I simply took the gravitational force accelerometer data that was being parsed and did some trig with it so it would display angles instead. The accelerometer code that needs to be replaced FOR THE WIIMOTE, is down below:

mWiimoteState.AccelState.Values.X = CSng(CSng(180 / (Math.PI)) * (CSng(Math.Asin(CSng(CSng(mWiimoteState.AccelState.RawValues.X) - (CInt(Fix(mWiimoteState.AccelCalibrationInfo.X0)))) / (CSng(mWiimoteState.AccelCalibrationInfo.XG) - (CInt(Fix(mWiimoteState.AccelCalibrationInfo.X0))))))))
  mWiimoteState.AccelState.Values.Y = CSng(CSng(180 / (Math.PI)) * (CSng(Math.Asin((CSng(mWiimoteState.AccelState.RawValues.Y) - mWiimoteState.AccelCalibrationInfo.Y0) / (CSng(mWiimoteState.AccelCalibrationInfo.YG) - mWiimoteState.AccelCalibrationInfo.Y0)))))
  mWiimoteState.AccelState.Values.Z = CSng(CSng(180 / (Math.PI)) * (CSng(Math.Acos((CSng(mWiimoteState.AccelState.RawValues.Z) - mWiimoteState.AccelCalibrationInfo.Z0) / (CSng(mWiimoteState.AccelCalibrationInfo.ZG) - mWiimoteState.AccelCalibrationInfo.Z0)))))

If you just copy and paste these in the VB code for wiimote.vb, where he parses the wiimote's accelerometer data it displays the angles the wiimote is held at.

I then continued thinking the principal would be the same for the nunchuck. I replaced the variables where he parses the accelerometer values with the ones from below:

mWiimoteState.NunchukState.AccelState.Values.X = CSng(CSng(180 / (Math.PI)) * (CSng(Math.Asin(CSng(CSng(mWiimoteState.NunchukState.AccelState.RawValues.X) - mWiimoteState.NunchukState.CalibrationInfo.AccelCalibration.X0) / (CSng(mWiimoteState.NunchukState.CalibrationInfo.AccelCalibration.XG) - mWiimoteState.NunchukState.CalibrationInfo.AccelCalibration.X0)))))
  mWiimoteState.NunchukState.AccelState.Values.Y = CSng(CSng(180 / (Math.PI)) * (CSng(Math.Asin(CSng(CSng(mWiimoteState.NunchukState.AccelState.RawValues.Y) - mWiimoteState.NunchukState.CalibrationInfo.AccelCalibration.Y0) / (CSng(mWiimoteState.NunchukState.CalibrationInfo.AccelCalibration.YG) - mWiimoteState.NunchukState.CalibrationInfo.AccelCalibration.Y0)))))
  mWiimoteState.NunchukState.AccelState.Values.Z = CSng(CSng(180 / (Math.PI)) * (CSng(Math.Acos(CSng(CSng(mWiimoteState.NunchukState.AccelState.RawValues.Z) - mWiimoteState.NunchukState.CalibrationInfo.AccelCalibration.Z0) / (CSng(mWiimoteState.NunchukState.CalibrationInfo.AccelCalibration.ZG) - mWiimoteState.NunchukState.CalibrationInfo.AccelCalibration.Z0)))))

Here comes the problem. I don't know if it's related to my code change or not. Most likely not, but here's a place to share the code at any rate. When I plug in the nunchuck the program doesn't recognize it. It throws me the error saying that, "Unknown extension controller found: a4200000"

Anyone have any idea why it doesn't recognize the nunchuck? Thanks ahead of time for reading this, if nothing else. Hopefully, it helps someone else try their conversions.

-3dge
Logged
Pages: [1]
  Print  
 
Jump to:  

TinyPortal v.1.0.6 beta 2 © Bloc
Clicky Web Analytics