Real-Time Control of a Cube with EMG signals. Possible?
Moderators: jesterKing, stiv
-
- Posts: 0
- Joined: Tue Jan 11, 2011 7:54 pm
- Location: Brazil
Real-Time Control of a Cube with EMG signals. Possible?
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!
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
-
- Posts: 0
- Joined: Tue Jan 11, 2011 7:54 pm
- Location: Brazil
-
- Posts: 0
- Joined: Tue Jan 11, 2011 7:54 pm
- Location: Brazil
-
- Posts: 0
- Joined: Tue Apr 19, 2011 2:57 am
- Location: New Hampshire, USA
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
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.
-
- Posts: 0
- Joined: Tue Jan 11, 2011 7:54 pm
- Location: Brazil
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.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
Eduardo de Conto
-
- Posts: 0
- Joined: Tue Apr 19, 2011 2:57 am
- Location: New Hampshire, USA
#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.
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.
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.[/quote]
.........
Hi Eduardo, your research from 2011 sounds super interesting. I am just wondering if you still have access to your code which allowed LabVIEW to control a blender object? I am currently doing a summer project where I'd like to use IMUs to control an on screen avatar and controlling a box would be a great start. If you have anything that could help I would be so grateful! Also do you have any video of your EMG project, I have done projects with EMG before and would love to see yours in action.
.........
Hi Eduardo, your research from 2011 sounds super interesting. I am just wondering if you still have access to your code which allowed LabVIEW to control a blender object? I am currently doing a summer project where I'd like to use IMUs to control an on screen avatar and controlling a box would be a great start. If you have anything that could help I would be so grateful! Also do you have any video of your EMG project, I have done projects with EMG before and would love to see yours in action.