Cannot take input from motion plus and nunchuck together

Official forum for open source FreePIE discussion and development.
Post Reply
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Cannot take input from motion plus and nunchuck together

Post 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!
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Cannot take input from motion plus and nunchuck together

Post by CyberVillain »

Hi, WiimoteCapabilities is a flag, you need todo

wiimote[0].enable(WiimoteCapabilities.MotionPlus | WiimoteCapabilities.Extension)
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Cannot take input from motion plus and nunchuck together

Post by konstantin_lozev »

Thanks :), will try it and re-post with video, if necessary.
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Cannot take input from motion plus and nunchuck together

Post 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
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Cannot take input from motion plus and nunchuck together

Post 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
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Cannot take input from motion plus and nunchuck together

Post 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.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Cannot take input from motion plus and nunchuck together

Post by CyberVillain »

I tried it with a clone with built in M+, worked
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Cannot take input from motion plus and nunchuck together

Post by konstantin_lozev »

Thanks, sorry for not replying yet, have not had access to my PC and wiimote, but will check it on return.
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Cannot take input from motion plus and nunchuck together

Post 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.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Cannot take input from motion plus and nunchuck together

Post 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.
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Cannot take input from motion plus and nunchuck together

Post 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.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Cannot take input from motion plus and nunchuck together

Post by CyberVillain »

I have asked my brother to take a look at this, he is the one behind the Wiimote code.
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Cannot take input from motion plus and nunchuck together

Post by konstantin_lozev »

Thanks, Cyber, I appreciate it. When I finish it, I will of course post all the final script here :)
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Cannot take input from motion plus and nunchuck together

Post by CyberVillain »

You dont have the possiblituy to run FreePIE in debug? It can take time until my brother takes a look at this
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Cannot take input from motion plus and nunchuck together

Post by konstantin_lozev »

Not sure what you meant with debug mode... You mean to open the uncomiped project from GitHub (in C++ ?).
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Cannot take input from motion plus and nunchuck together

Post by CyberVillain »

Yes :D
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Cannot take input from motion plus and nunchuck together

Post 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.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Cannot take input from motion plus and nunchuck together

Post 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
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Cannot take input from motion plus and nunchuck together

Post by konstantin_lozev »

Oh, my, from the looks of it, I am nowhere near getting this done...
Post Reply

Return to “FreePIE”