Page 1 of 1

Cannot take input from motion plus and nunchuck together

Posted: Sun Nov 29, 2015 5:57 am
by konstantin_lozev
Hi, all, I have been trying to extend this experiment https://www.youtube.com/watch?v=GyYm1s6y4RY into FreePIE for some time and I am 90% there with the script. I did all the prototyping with the wiimote only (with built in wii motion plus), assuming the extension to the nunchuck would be a piece of cake at the end (used for reloading and wasd movement). It turns out I was wrong. For some reason, I cannot get FreePIE to accept both input from the nunchuck and from the wiimote. I have made a youtube video with the code and I show there that once I enable one, the other gets disabled and vice versa https://youtu.be/3M-4xmzQnnQ. Here is the code:

Code: Select all

def updateNB():
	pressedZ=wiimote[0].nunchuck.buttons.button_down(NunchuckButtons.Z)
	diagnostics.watch(pressedZ)
def updateW():
	preWX = -filters.deadband(wiimote[0].motionplus.yaw_down/100,0.005)
	preWY = filters.deadband(wiimote[0].motionplus.pitch_left/100,0.005)
	diagnostics.watch(preWX)
if starting:
	system.setThreadTiming(TimingTypes.HighresSystemTimer)
	system.threadExecutionInterval = 2
	wiimote[0].nunchuck.update += updateNB
	wiimote[0].enable(WiimoteCapabilities.MotionPlus)
	wiimote[0].enable(WiimoteCapabilities.Extension)
	wiimote[0].motionplus.update += updateW
I hope someone could help me with that last step. Could it be because the motion plus is built in? It is one of the earlier Wii motion plus editions and still registers as RVL-CNT-01
Thanks in advance!

Re: Cannot take input from motion plus and nunchuck together

Posted: Mon Nov 30, 2015 1:59 am
by CyberVillain
Hi, WiimoteCapabilities is a flag, you need todo

wiimote[0].enable(WiimoteCapabilities.MotionPlus | WiimoteCapabilities.Extension)

Re: Cannot take input from motion plus and nunchuck together

Posted: Mon Nov 30, 2015 4:57 am
by konstantin_lozev
Thanks :), will try it and re-post with video, if necessary.

Re: Cannot take input from motion plus and nunchuck together

Posted: Mon Nov 30, 2015 12:21 pm
by konstantin_lozev
Hi, no luck, the script with that last

Code: Select all

wiimote[0].enable(WiimoteCapabilities.MotionPlus | WiimoteCapabilities.Extension)
behaves as if the MotionPlus is not activated.
Here is a link to the new video https://youtu.be/_Ph6gQEl1P8
And here is the code from the video

Code: Select all

def updateNB():
   pressedZ=wiimote[0].nunchuck.buttons.button_down(NunchuckButtons.Z)
   diagnostics.watch(pressedZ)
def updateW():
   preWX = -filters.deadband(wiimote[0].motionplus.yaw_down/100,0.005)
   preWY = filters.deadband(wiimote[0].motionplus.pitch_left/100,0.005)
   diagnostics.watch(preWX)
if starting:
   system.setThreadTiming(TimingTypes.HighresSystemTimer)
   system.threadExecutionInterval = 2
   wiimote[0].enable(WiimoteCapabilities.MotionPlus | WiimoteCapabilities.Extension)
#   wiimote[0].enable(WiimoteCapabilities.MotionPlus)
#   wiimote[0].enable(WiimoteCapabilities.Extension)
   wiimote[0].nunchuck.update += updateNB
   wiimote[0].motionplus.update += updateW

Re: Cannot take input from motion plus and nunchuck together

Posted: Mon Nov 30, 2015 1:26 pm
by CyberVillain
Look at the wiimote_nunchuck_and_motionplus.txt script in the first post, i tried it long ago with a wiimote plus. Dont have one currectly to test with nwo


http://www.mtbs3d.com/phpBB/viewtopic.php?f=139&t=18342

Re: Cannot take input from motion plus and nunchuck together

Posted: Tue Dec 01, 2015 11:35 am
by konstantin_lozev
Thanks, will try it out. I have the feeling the problem is because my wiimote has the plus built in and not as an extension plugged at one end and then into that extension the nunchuck. BTW, GlovePIE recognises both no problem, but has no support for reading the phone's IMUs.

Re: Cannot take input from motion plus and nunchuck together

Posted: Tue Dec 01, 2015 5:16 pm
by CyberVillain
I tried it with a clone with built in M+, worked

Re: Cannot take input from motion plus and nunchuck together

Posted: Sun Dec 06, 2015 2:33 pm
by konstantin_lozev
Thanks, sorry for not replying yet, have not had access to my PC and wiimote, but will check it on return.

Re: Cannot take input from motion plus and nunchuck together

Posted: Mon Dec 07, 2015 2:50 pm
by konstantin_lozev
I am sorry but still no success. Same issue - I cannot get the motion+ to work with

Code: Select all

wiimote[0].enable(WiimoteCapabilities.MotionPlus | WiimoteCapabilities.Extension)
, only the nunchuck gets reported. If I keep it only

Code: Select all

wiimote[0].enable(WiimoteCapabilities.MotionPlus)
the motion+ works, but then the nunchuck readings disappear. Here is the video https://youtu.be/NnXLv3REjo4
On a side note, I was surprised to see the wiimote.enable not in the if starting statement, but I am more focused now on that issue.

Re: Cannot take input from motion plus and nunchuck together

Posted: Tue Dec 08, 2015 4:23 am
by CyberVillain
hmm, try lower system.threadExecutionInterval = 2 to 1

2 should be enough but it could be that FreePIE polls the wii to seldom and misses the motion plus data packages.

Re: Cannot take input from motion plus and nunchuck together

Posted: Fri Dec 11, 2015 10:49 am
by konstantin_lozev
Just did a long checking session with an even simpler script. I made a new video https://youtu.be/PGbN0UceUgI
It did not make any difference whatsoever whether I had

Code: Select all

	system.setThreadTiming(TimingTypes.HighresSystemTimer)
	system.threadExecutionInterval = 1
In fact, after testing repeatedly over and over, I managed to get it to run properly only once and then I started taking the video, i.e. the video starts with a working case and in fact in that example I had those lines commented out

Code: Select all

#	system.setThreadTiming(TimingTypes.HighresSystemTimer)
#	system.threadExecutionInterval = 1
Whatever I tries afterwards for almost 15 minutes, I could not get it to work again.
What I observed is that the line

Code: Select all

	wiimote[0].enable(WiimoteCapabilities.MotionPlus | WiimoteCapabilities.Extension)
does not activate the motion+ in 99% of the cases.
Maybe that is the real problem, i.e. the line

Code: Select all

	wiimote[0].enable(WiimoteCapabilities.MotionPlus | WiimoteCapabilities.Extension)
almost never works, but the line

Code: Select all

	wiimote[0].enable(WiimoteCapabilities.MotionPlus)
almost always works.
I wonder what the difference is between the two.

Re: Cannot take input from motion plus and nunchuck together

Posted: Mon Dec 14, 2015 7:29 am
by CyberVillain
I have asked my brother to take a look at this, he is the one behind the Wiimote code.

Re: Cannot take input from motion plus and nunchuck together

Posted: Mon Dec 14, 2015 1:52 pm
by konstantin_lozev
Thanks, Cyber, I appreciate it. When I finish it, I will of course post all the final script here :)

Re: Cannot take input from motion plus and nunchuck together

Posted: Tue Dec 15, 2015 7:05 am
by CyberVillain
You dont have the possiblituy to run FreePIE in debug? It can take time until my brother takes a look at this

Re: Cannot take input from motion plus and nunchuck together

Posted: Tue Dec 15, 2015 7:19 am
by konstantin_lozev
Not sure what you meant with debug mode... You mean to open the uncomiped project from GitHub (in C++ ?).

Re: Cannot take input from motion plus and nunchuck together

Posted: Tue Dec 15, 2015 8:06 am
by CyberVillain
Yes :D

Re: Cannot take input from motion plus and nunchuck together

Posted: Tue Dec 15, 2015 3:15 pm
by konstantin_lozev
Uh, that's an adventure :) I have never actually programmed in C++ especially that emulation stuff I don't expect to be easy... What SDE do I need? I have no idea where to start from even. I just hoped to brush that last bit and finish that project and jump onto the next one.

Re: Cannot take input from motion plus and nunchuck together

Posted: Wed Dec 16, 2015 3:47 am
by CyberVillain
The IDE is Visual Studio 2013 or 2015. You can use the community edition since FreePIE is open source. But I warn you, the Wiimote code is complex and alot of C++ code. :D
Thats the reason why I have not been able to find time to learn that code base myself, I would love if someone could take over the code base from my brother since he is not active in the project anymore

Re: Cannot take input from motion plus and nunchuck together

Posted: Wed Dec 16, 2015 4:28 pm
by konstantin_lozev
Oh, my, from the looks of it, I am nowhere near getting this done...