Arduino and Freepie ?
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
Just a hunch, what did you rename the old plugin name too? The one you wrote over to get the new generic com plugin
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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....
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....
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
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
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
Code: Select all
keyboard.setPressed(Key.W)
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
Ahhh Yeeessss!
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
So will both of these work inside the game
keyboard.setKeyDown(Key.W)
keyboard.setPressed(Key.W)
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
So will both of these work inside the game
keyboard.setKeyDown(Key.W)
keyboard.setPressed(Key.W)
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
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
This will make your player walk forward aslong as you hold the mouse key
setPressed is used to send a quick down / up press
Or you use setKey that takes the state like this
Code: Select all
keyboard.setKey(Key.W, mouse.leftButton)
setPressed is used to send a quick down / up press
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
Roger that!
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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
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
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
is it only the generic plugin that behaves like this? How does the ahrs or freeimu plugin behave?
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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
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
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
What happens if you do
?
edit: Cant you load your Arduino with ahrs or freeimu software just for testing?
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?
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
ok, I just tried it with
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...
Code: Select all
if starting:
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 1
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...
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
BTW, for IMU data only,
I believe the AHRS plugin was working fine without noticeable lag, when I tried it a few weeks ago.
I believe the AHRS plugin was working fine without noticeable lag, when I tried it a few weeks ago.
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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.
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.
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
Thanks CV !CyberVillain wrote:I'll have to look over the code for the generic plugin
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
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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.
My arduino button IO checking code is inserted inside the AHRS code,
so I am wondering how my button IO code will affect the sync...
whereas the generic com code does not have it at the moment.
Code: Select all
while (serialPort.BytesToRead < "#SYNCH00\r\n".Length)
Code: Select all
// Update sensor readings
read_sensors();
//read button IO
read_PinIO ();
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
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
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
No no CV, sorry maybe I was not clear before.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
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.
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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
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
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
Aha, this could be the prblem
https://github.com/AndersMalmgren/FreeP ... 8e3f85fR54
Try change it to
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();
}
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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?
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?
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
Yes, start with that. I havent had time to dig out my Arduino :/
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
Ok, so I will make a pull request,
if I manage to figure out what to do !
cheers
if I manage to figure out what to do !
cheers
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
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
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
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
Ok, that is very important information.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
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.
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
But the else block has to be added, its a bug and will make the Thread Yield even if it does not need to
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
ok, please give me some time to work on that part.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
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
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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
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
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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
Just for reference, here is what I am using in FP for now
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.
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
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
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.
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: Arduino and Freepie ?
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
We need to support both
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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.
to figure out what is going on, and what I need to do.
-
- Cross Eyed!
- Posts: 144
- Joined: Wed Jul 16, 2014 10:29 am
- Location: Tokyo, Japan
Re: Arduino and Freepie ?
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
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
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden