Page 2 of 2
Re: Arduino and Freepie ?
Posted: Thu Aug 07, 2014 10:02 am
by CyberVillain
Just a hunch, what did you rename the old plugin name too? The one you wrote over to get the new generic com plugin
Re: Arduino and Freepie ?
Posted: Thu Aug 07, 2014 10:26 am
by NeoTokyo_Nori
Your hunch was right
genius!
I named it
FreePIE.Core.Plugins-old.dll
and left it in the same folder. I guess that was bad huh
Now it runs!
But so far, I am not getting any "w" key presses showing up in the text editor....
Re: Arduino and Freepie ?
Posted: Thu Aug 07, 2014 10:44 am
by CyberVillain
Its a common misstake
FreePIE can load multiple plugins to support third party ones
Maybe we should fix a better error message
hmm, notepad behaves different from games. does
work? Note that this will press the key and release key within a short timeframe so it should not be used in a game. But you can use it to test from notepad
Re: Arduino and Freepie ?
Posted: Thu Aug 07, 2014 10:52 am
by NeoTokyo_Nori
Ahhh Yeeessss!
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
So will both of these work inside the game
keyboard.setKeyDown(Key.W)
keyboard.setPressed(Key.W)
Re: Arduino and Freepie ?
Posted: Thu Aug 07, 2014 11:52 am
by CyberVillain
Yes, setKeyDown can be called once and the game will get W presses until you do setKeyUp
Or you use setKey that takes the state like this
Code: Select all
keyboard.setKey(Key.W, mouse.leftButton)
This will make your player walk forward aslong as you hold the mouse key
setPressed is used to send a quick down / up press
Re: Arduino and Freepie ?
Posted: Fri Aug 08, 2014 10:25 am
by NeoTokyo_Nori
Roger that!
Re: Arduino and Freepie ?
Posted: Sun Sep 14, 2014 11:41 am
by NeoTokyo_Nori
Hi CV,
I am still doing all kinds of testing to figure out the causes of lag in my gun inputs.
But I have a hunch about something that I need to ask you about.
I am not certain, because I can only see the symptom. but...
It
appears like all the serial data is getting buffered in memory,
and all of the data stays there, until it gets used inside the script.
So if I send a trigger pull, or zoom message, the script will still do it
many many seconds later, as long as the message is still in buffer queue.
And in fact, I think that is what I am seeing.
How can we discard any serial messages that are over 20 to 50ms old ?
Because, as you are well aware, any laggy data should be completely destroyed!
to make way for our mega awesome VR experiences
Re: Arduino and Freepie ?
Posted: Sun Sep 14, 2014 12:33 pm
by CyberVillain
is it only the generic plugin that behaves like this? How does the ahrs or freeimu plugin behave?
Re: Arduino and Freepie ?
Posted: Sun Sep 14, 2014 12:36 pm
by NeoTokyo_Nori
Hi CV,
I think I can only use the generic com, for receiving the gun trigger IO data right?
so I can only verify the lag while using the generic com...
If my hunch about the serial buffer is in fact one of the causes,
Maybe we could allow users to set the values for
SerialPort::ReadBufferSize Property
SerialPort::ReadTimeout Property
Re: Arduino and Freepie ?
Posted: Sun Sep 14, 2014 12:41 pm
by CyberVillain
What happens if you do
Code: Select all
if starting:
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 1
?
edit: Cant you load your Arduino with ahrs or freeimu software just for testing?
Re: Arduino and Freepie ?
Posted: Sun Sep 14, 2014 12:53 pm
by NeoTokyo_Nori
ok, I just tried it with
Code: Select all
if starting:
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 1
and the symptom is the same - while using the button IO only code.
An interesting thing is, I also tried increasing the baud rate from 4800 to 9600,
and the amount of lag increased, due to the increased amount of messages (obviously, I guess)
Do you want me to test with the "IMU + button IO" ?
AHRS IMU code is what I have always been running on my arduino...
Re: Arduino and Freepie ?
Posted: Sun Sep 14, 2014 1:05 pm
by NeoTokyo_Nori
BTW, for IMU data only,
I believe the AHRS plugin was working fine without noticeable lag, when I tried it a few weeks ago.
Re: Arduino and Freepie ?
Posted: Sun Sep 14, 2014 1:42 pm
by NeoTokyo_Nori
I found something that may be useful
PurgeComm function (Windows)
http://msdn.microsoft.com/en-us/library/aa363428.aspx
Discards all characters from the output or input buffer of a specified communications resource. It can also terminate pending read or write operations on the resource.
Re: Arduino and Freepie ?
Posted: Sun Sep 14, 2014 2:37 pm
by CyberVillain
I'll have to look over the code for the generic plugin
Re: Arduino and Freepie ?
Posted: Sun Sep 14, 2014 2:46 pm
by NeoTokyo_Nori
CyberVillain wrote:I'll have to look over the code for the generic plugin
Thanks CV !
that would be awesome.
Perhaps a PurgeComm function, every 20ms may be good for it?
Wow, if things speed up, it is going to be great
Re: Arduino and Freepie ?
Posted: Mon Sep 15, 2014 2:36 am
by NeoTokyo_Nori
Hmm, so I just noticed that the AHRS code has a sync signal.
whereas the generic com code does not have it at the moment.
Code: Select all
while (serialPort.BytesToRead < "#SYNCH00\r\n".Length)
My arduino button IO checking code is inserted inside the AHRS code,
Code: Select all
// Update sensor readings
read_sensors();
//read button IO
read_PinIO ();
so I am wondering how my button IO code will affect the sync...
Re: Arduino and Freepie ?
Posted: Tue Sep 16, 2014 9:45 am
by CyberVillain
That sync is just part of the AHRS protocol. Has long has your ahrs and generic com device run on different com ports they will not interfere with each other
Re: Arduino and Freepie ?
Posted: Tue Sep 16, 2014 9:55 am
by NeoTokyo_Nori
CyberVillain wrote:That sync is just part of the AHRS protocol. Has long has your ahrs and generic com device run on different com ports they will not interfere with each other
No no CV, sorry maybe I was not clear before.
I have a single arudino board that is running the ahrs code and the pin IO code,
which is connected to a single bluetooth module.
If I had to use 2 arduinos it would not fit on the gun, and would also double the cost
It is something like this setup.
http://forum.arduino.cc/index.php/topic,164222.0.html
And as I said, My arduino button IO checking code is inserted INSIDE the AHRS code....!
Although this is just testing. It is the read_PinIO (); routine.
Re: Arduino and Freepie ?
Posted: Tue Sep 30, 2014 5:43 am
by NeoTokyo_Nori
Hello CV,
I am looking through the plugin code,
and until now I thought the genericCom plugin code was ComDevicePlugin.cs
but I finally understand now that this is an abstract class.
But I cannot seem to find the code for the genericCom plugin anywhere.
So could you please point to where it is ?
thanks
Re: Arduino and Freepie ?
Posted: Tue Sep 30, 2014 5:13 pm
by CyberVillain
Re: Arduino and Freepie ?
Posted: Tue Sep 30, 2014 5:16 pm
by CyberVillain
Aha, this could be the prblem
https://github.com/AndersMalmgren/FreeP ... 8e3f85fR54
Try change it to
Code: Select all
while (buffers.Count != 0)
{
byte[] result;
if (buffers.TryDequeue(out result))
yield return result;
else
Thread.Yield();
}
Re: Arduino and Freepie ?
Posted: Wed Oct 01, 2014 12:55 am
by NeoTokyo_Nori
Thank you for the push - no wonder I couldn`t find it anywhere
I have to learn how to use the github tree, branching functions...
So it looks like the "else" statement is missing from the code...
Just so I understand, do you want me to update the code myself?
Re: Arduino and Freepie ?
Posted: Wed Oct 01, 2014 1:30 am
by CyberVillain
Yes, start with that. I havent had time to dig out my Arduino :/
Re: Arduino and Freepie ?
Posted: Wed Oct 01, 2014 1:42 am
by NeoTokyo_Nori
Ok, so I will make a pull request,
if I manage to figure out what to do !
cheers
Re: Arduino and Freepie ?
Posted: Wed Oct 01, 2014 2:43 am
by CyberVillain
Start with the Thread.Yield fix, if that does not help or only help to a certain degree start looking at the ReadLine method..
Currently that method takes everything on the buffer from start to first newline and leave the rest, the next time data comes in it will do the same.
If there are more than one line on the buffer this could mean it will introduce lag since it will only take first line in buffer and leave the rest for next read
Re: Arduino and Freepie ?
Posted: Thu Oct 02, 2014 1:44 am
by NeoTokyo_Nori
CyberVillain wrote:
Currently that method takes everything on the buffer from start to first newline and leave the rest, the next time data comes in it will do the same.
If there are more than one line on the buffer this could mean it will introduce lag since it will only take first line in buffer and leave the rest for next read
Ok, that is very important information.
Now that you have mentioned that, I am going to first test what happens
when I just put the YPR and button IO messages into one single line - which is something that is possible to do with FreeIMU.
If everything is on the same line, in theory it should take care of that problem, I hope.
Re: Arduino and Freepie ?
Posted: Thu Oct 02, 2014 3:13 am
by CyberVillain
But the else block has to be added, its a bug and will make the Thread Yield even if it does not need to
Re: Arduino and Freepie ?
Posted: Thu Oct 02, 2014 3:20 am
by NeoTokyo_Nori
CyberVillain wrote:But the else block has to be added, its a bug and will make the Thread Yield even if it does not need to
ok, please give me some time to work on that part.
I`m also getting compile errors with the FreeIMU arduino code,
and also not able to get the FreeIMU calibration tool working,
so I have to squash many bugs at the same time
Re: Arduino and Freepie ?
Posted: Thu Oct 02, 2014 5:59 am
by NeoTokyo_Nori
Just a note:
I told this young engineer looking for a project, about FreePIE.
http://www.reddit.com/r/oculus/comments ... u_need_an/
I thought it would be great if he could come and work on it too
Re: Arduino and Freepie ?
Posted: Sun Oct 12, 2014 5:05 am
by NeoTokyo_Nori
Hi CV,
I have a question about the mouse emulation.
So I have the gun moving the mouse as it should be moving.
It seems that mouse.deltaX is locked to the absolute value of the imu (freeimu).
But I wish to have it move relatively i.e in relation to, an arbitrary starting point,
so that I can point the gun at any place, and just have the mouse start moving from there.
( because I need to release/engage mouse control)
I used to do this in glovepie, but I cannot figure out how to do it in FreePIE
Code: Select all
Mouse.DirectInputX = Mouse.DirectInputX + wiimote1.MotionPlus.YawSpeed / 3200000
Mouse.DirectInputY = Mouse.DirectInputY - wiimote1.MotionPlus.PitchSpeed / 3200000
Just for reference, here is what I am using in FP for now
Code: Select all
mouse.deltaX = filters.deadband(filters.delta(sFREEIMU_Yaw), 0.15) * 8
mouse.deltaY = filters.deadband(filters.delta(sFREEIMU_Pitch), 0.15) * -8
Could you please also explain the difference between
Mouse.DirectInputX, in glovepie and
mouse.deltaX, in freepie ?
Not sure if I have conveyed what I need todo, so let me know if I need to explain more.
Re: Arduino and Freepie ?
Posted: Sun Oct 12, 2014 7:54 am
by CyberVillain
We use the flag MOUSEEVENTF_MOVE which means relative. There is also a flag called MOUSEEVENTF_ABSOLUTE which might work as you want. Maybe you can tinker with the Mouse plugin and let me know?
We need to support both
Re: Arduino and Freepie ?
Posted: Sun Oct 12, 2014 10:19 am
by NeoTokyo_Nori
Ok, all this absolute vs. relative movement, is quite confusing, so please give me a couple of days
to figure out what is going on, and what I need to do.
Re: Arduino and Freepie ?
Posted: Sun Oct 12, 2014 10:34 am
by NeoTokyo_Nori
Hi, I already hit a wall :/
According to
mouse_event function (Windows)
http://msdn.microsoft.com/en-us/library ... s.85).aspx
Note This function has been superseded. Use SendInput instead.
So why is
MOUSEEVENTF_MOVE
still working,
and will
MOUSEEVENTF_ABSOLUTE
work
Re: Arduino and Freepie ?
Posted: Sun Oct 12, 2014 10:57 am
by CyberVillain