Previous Thread  Next Thread

chat icon Real-Time Control of a Cube with EMG signals. Possible?

eduardoconto

Posted: Wed Jan 12, 2011 7:10 pm
Joined: 11 Jan 2011
Posts: 5
Hello from Brazil and Federal University of Rio Grande do Sul(UFRGS)!

In a project we are currently developing here, we are trying to develop a system to control a wheelchair based on electromyography(EMG). We have already have developed some techniques to process the signals and decide which movement has done. By now, we are trying to control a virtual object(like a cube) in real-time with the EMG signals we process. The objective of this is to compare and test the techniques we use to process the signals without using the physical chair.

We are thinking that maybe we can do this with Blender and its GameEngine. We would need a way to control this cube a mentioned with these decisions we do. We use NI LabVIEW here to process the signals, so we are trying to figure out a way to have an interface between Blender and LabVIEW, e.g, generate some file or data that Blender can read and use to control the cube, through its Python API.

Is it possible? Anyone have an idea of how we can do it?

Thanks in advance!
_________________
Eduardo de Conto
Reply with quote


SirDude

Posted: Thu Jan 13, 2011 5:24 pm
Joined: 13 Oct 2002
Posts: 939
Yes there are a number of people that have written small interfaces to blender using python's socket's to comunicate with other things.

Just do a google search for blender python socket
and you'll be on your way.
Reply with quote


eduardoconto

Posted: Tue Jan 18, 2011 3:03 pm
Joined: 11 Jan 2011
Posts: 5
hum... I've never worked with sockets before. Do you know somewhere I can look for good introductory material?
Thanks
_________________
Eduardo de Conto
Reply with quote


eduardoconto

Posted: Tue Feb 15, 2011 8:01 pm
Joined: 11 Jan 2011
Posts: 5
Quote:
Just do a google search for blender python socket
and you'll be on your way.


Were you talking about the Blender Command Port? I've been trying to build this to a Blender sw, but I couldn't. With this sw would I be able to call Blender through a TCP interface?
_________________
Eduardo de Conto
Reply with quote


prof.t.adamson

Posted: Tue Apr 19, 2011 2:33 am
Joined: 19 Apr 2011
Posts: 4
Can you use your EMG device to create a small text file? If you can, then you can use Python to read the text and then act on the cube as a result. We have had some success in using a web-site to create a text file (using PHP) and then using Python to read the contents of that text file which in turn cause the cube to rotate in different directions.
We have demonstrated this at Southern New Hampshire University in our GAM-471 Special Topics course offered this semester.
If this seems like a possible solution for you, let me know and I can just give to you the source code I developed for this.
Hope this is of some help.
Best,
Tom A.
Visiting Assistant Professor,
Computer Game Design and Development.
SNHU.edu
_________________
I am interested in using Blender as a teaching tool in a beginning course in Computer Game Design and Development.
Reply with quote


eduardoconto

Posted: Tue Apr 19, 2011 5:00 pm
Joined: 11 Jan 2011
Posts: 5
prof.t.adamson wrote:
Can you use your EMG device to create a small text file? If you can, then you can use Python to read the text and then act on the cube as a result. We have had some success in using a web-site to create a text file (using PHP) and then using Python to read the contents of that text file which in turn cause the cube to rotate in different directions.
We have demonstrated this at Southern New Hampshire University in our GAM-471 Special Topics course offered this semester.
If this seems like a possible solution for you, let me know and I can just give to you the source code I developed for this.
Hope this is of some help.
Best,
Tom A.
Visiting Assistant Professor,
Computer Game Design and Development.
SNHU.edu


Well, actually, I have succeced in creating a interface between LabVIEW and Blender using UDP Sockets and the Blender GE, what, in turn, make it possible to me to control my blender object in real-time.
_________________
Eduardo de Conto
Reply with quote


prof.t.adamson

Posted: Tue Apr 19, 2011 10:02 pm
Joined: 19 Apr 2011
Posts: 4
#What follows is the Python code we used with Blender. It reads this every 30 seconds:

from http.client import *
from GameLogic import *

conn = http.client.HTTPConnection("www.YourWebSite.org")
conn.request("GET", "/Python/Test.txt")
r1 = conn.getresponse()
print(r1.status, r1.reason)
data = r1.read()
data = data.strip()
print(data)

newText = data.decode()

print(newText)

matchText = newText.find('right')

cont = getCurrentController()

actList = cont.actuators
senList = cont.sensors

act1 = actList["right"]
act2 = actList["left"]

s1 = "right'"
s2 = "left'"

if newText.find('right') > -1:
print("Found right.")
cont.deactivate(act2)
cont.activate(act1)

if newText.find('left') > -1:
print("Found left.")
cont.deactivate(act1)
cont.activate(act2)

if newText.find('stop') > -1:
print("Found left.")
cont.deactivate(act1)
cont.deactivate(act2)

=============================================

This is the PHP code we used on the server which was activated by the following HTML document:

<?php
$txtID = $_GET["ID"];
$file = fopen("Test.txt","w");

switch ($txtID)
{
case 1:
$Instruction = "right";
break;
case 2:
$Instruction = "left";
break;
case 3:
$Instruction = "stop";
break;
}


fclose($file);
?>

============================================

This is the HTML code we used to control the text in the above php file:

<html>
<head>
<title>Link Page</title>
<script>
Start = "<iframe src='MyFrame.php?ID=";
End = "' />";
function DoIt(Value)
{
document.getElementById('Mine').innerHTML = Start + Value + End;
}
</script>
</head>
<body>
<h2>This is the link page.</h2>
You can control a Blender 3-D module from this page.
<span id="Mine"></span>
<input type="button" value="Right" OnClick="DoIt(1)" /><br />
<input type="button" value="Left" OnClick="DoIt(2)" /><br />
<input type="button" value="Stop" OnClick="DoIt(3)" /><br />
<input type="button" value="Four" OnClick="DoIt(1)" /><br /
</body>
</html>

=============================================

The result of this was that an HTML document on a remote computer could control a Blender object on another remote computer.

Hope this is of some use to you folks. Please let me know.
_________________
I am interested in using Blender as a teaching tool in a beginning course in Computer Game Design and Development.
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group