This is a read-only mirror of pymolwiki.org
Difference between revisions of "RUCAP UM-5"
(21 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
RUCAP UM-5 tracker is a wireless joystick for view control in PyMol. | RUCAP UM-5 tracker is a wireless joystick for view control in PyMol. | ||
The code based on project [[ImmersiveViz]].<br><br> | The code based on project [[ImmersiveViz]].<br><br> | ||
+ | |||
+ | The script, which is reproduced below, transmits data to [[ImmersiveViz]]. [[ImmersiveViz]] runs on top of PyMol and adjusts the PyMol screen view in accordance with the position of your eyes in the space in front of the monitor.<br><br> | ||
Our system contains a head tracking thread which communicates the users position to a PyMol script via a socket. The PyMol script unpacks the message and updates the world respectively. All rotation is done around the virtual origin in PyMol and zoom is also considered.<br><br> | Our system contains a head tracking thread which communicates the users position to a PyMol script via a socket. The PyMol script unpacks the message and updates the world respectively. All rotation is done around the virtual origin in PyMol and zoom is also considered.<br><br> | ||
+ | |||
+ | ==Operating principle== | ||
+ | |||
+ | Tracker RUCAP UM-5 in real time detects the absolute position and orientation of Your head relative to computer monitor. Antenna RU constantly traces the position of emitter CAP and transmits the data to RUCAP UM-5 Service program rucap.dll for further processing. Information from ultrasonic sensors is processed into concrete commands for the PyMol or computer program which runs RUCAP UM-5 profile at the moment.<br><br> | ||
+ | |||
+ | ==5 degrees of freedom== | ||
+ | |||
+ | There are 6 types of movement in three-dimensional space: linear move along X, Y, Z axes and also rotations of head around each of the axes. | ||
+ | RUCAP UM-5 supports 5 degrees of freedom: all types of movement and head rotations left-right (yaw) and up-down (pitch). These are all types of view control that are used in computer games that's why RUCAP UM-5 tracker gives You complete view control in PyMol. | ||
== Getting UM-5 data of the users position into socket by your script rucap.py == | == Getting UM-5 data of the users position into socket by your script rucap.py == | ||
+ | |||
+ | This device has got only OS Windows support on current time. | ||
+ | |||
+ | First, you need runing PyMol with [https://code.google.com/p/immersive-viz/source/browse/trunk/MolViz.py MolViz.py]. And optional with [https://code.google.com/p/immersive-viz/source/browse/trunk/MolVizGeneratedGui.py MolVizGui.py] (That is [https://code.google.com/p/immersive-viz/wiki/UserManual UserManual] for GUI), that make fine settings of interface RUCAP. | ||
+ | |||
+ | ./pymol -l MolViz.py 1jnx.pdb | python MolVizGui.py | ||
+ | |||
+ | MolViz.py runing the [https://code.google.com/p/immersive-viz/source/browse/trunk/SocketServer.py SocketServer.py]. | ||
+ | |||
+ | For convert data to MolViz format you need run next socket script client '''rucap.py''': | ||
+ | |||
<source lang="python"> | <source lang="python"> | ||
# -*- coding: cp1251 | # -*- coding: cp1251 | ||
+ | # rucup.py - wraper for RUCAP driver (rucap.dll - http://rucap.ru/um5/support#sdk) | ||
+ | # need code from https://code.google.com/p/immersive-viz/source/browse/trunk/ | ||
# Take data from UM-5 and put to the socket on port 4440. | # Take data from UM-5 and put to the socket on port 4440. | ||
#----- The server used to listen for head tracking | #----- The server used to listen for head tracking | ||
Line 14: | Line 38: | ||
#----- The server used to listen for the GUI to update the values / display info | #----- The server used to listen for the GUI to update the values / display info | ||
# self.gui = Server(self, 4441) | # self.gui = Server(self, 4441) | ||
+ | # | ||
from ctypes import * | from ctypes import * | ||
+ | import socket | ||
+ | HOST = "localhost" # remote host-computer (localhost) | ||
+ | PORT = 4440 # port on remote host | ||
RUCAP_VERSION = 3 | RUCAP_VERSION = 3 | ||
Line 40: | Line 68: | ||
y = c_float(0.0) | y = c_float(0.0) | ||
z = c_float(0.0) | z = c_float(0.0) | ||
+ | |||
+ | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
+ | sock.connect((HOST, PORT)) | ||
# main loop | # main loop | ||
Line 48: | Line 79: | ||
#print '%f %f %f\n' % ( x.value, y.value, z.value) | #print '%f %f %f\n' % ( x.value, y.value, z.value) | ||
print x.value, y.value, z.value | print x.value, y.value, z.value | ||
+ | sock.send('X%.15f;Y%.15f;Z%.15f;\n' % ( x.value, y.value, z.value)) | ||
+ | #result = sock.recv(1024) | ||
+ | #print "Recive:", result | ||
+ | |||
+ | sock.close() | ||
</source> | </source> | ||
Line 63: | Line 99: | ||
[[Category:Script_Library|RUCAP UM-5]] | [[Category:Script_Library|RUCAP UM-5]] | ||
[[Category:UI_Scripts|RUCAP UM-5]] | [[Category:UI_Scripts|RUCAP UM-5]] | ||
+ | [[Category:ThirdParty Scripts|RUCAP UM-5]] |
Latest revision as of 10:22, 19 May 2013
RUCAP UM-5 tracker
RUCAP UM-5 tracker is a wireless joystick for view control in PyMol.
The code based on project ImmersiveViz.
The script, which is reproduced below, transmits data to ImmersiveViz. ImmersiveViz runs on top of PyMol and adjusts the PyMol screen view in accordance with the position of your eyes in the space in front of the monitor.
Our system contains a head tracking thread which communicates the users position to a PyMol script via a socket. The PyMol script unpacks the message and updates the world respectively. All rotation is done around the virtual origin in PyMol and zoom is also considered.
Operating principle
Tracker RUCAP UM-5 in real time detects the absolute position and orientation of Your head relative to computer monitor. Antenna RU constantly traces the position of emitter CAP and transmits the data to RUCAP UM-5 Service program rucap.dll for further processing. Information from ultrasonic sensors is processed into concrete commands for the PyMol or computer program which runs RUCAP UM-5 profile at the moment.
5 degrees of freedom
There are 6 types of movement in three-dimensional space: linear move along X, Y, Z axes and also rotations of head around each of the axes. RUCAP UM-5 supports 5 degrees of freedom: all types of movement and head rotations left-right (yaw) and up-down (pitch). These are all types of view control that are used in computer games that's why RUCAP UM-5 tracker gives You complete view control in PyMol.
Getting UM-5 data of the users position into socket by your script rucap.py
This device has got only OS Windows support on current time.
First, you need runing PyMol with MolViz.py. And optional with MolVizGui.py (That is UserManual for GUI), that make fine settings of interface RUCAP.
./pymol -l MolViz.py 1jnx.pdb | python MolVizGui.py
MolViz.py runing the SocketServer.py.
For convert data to MolViz format you need run next socket script client rucap.py:
# -*- coding: cp1251
# rucup.py - wraper for RUCAP driver (rucap.dll - http://rucap.ru/um5/support#sdk)
# need code from https://code.google.com/p/immersive-viz/source/browse/trunk/
# Take data from UM-5 and put to the socket on port 4440.
#----- The server used to listen for head tracking
# self.server = Server(self, 4440)
#----- The server used to listen for the GUI to update the values / display info
# self.gui = Server(self, 4441)
#
from ctypes import *
import socket
HOST = "localhost" # remote host-computer (localhost)
PORT = 4440 # port on remote host
RUCAP_VERSION = 3
RUCAP_RESULT_OK = 0;
RUCAP_RESULT_FAIL = 1;
RUCAP_RESULT_TRACKERAPP_OFF = 2;
RUCAP_RESULT_UNPLUGGED = 3;
RUCAP_RESULT_DEVICE_NOT_CREATED = 4;
RUCAP_RESULT_BAD_VERSION = 5;
# load dll
a = CDLL("rucap.dll")
# call function, that returned int
a.RucapCreateDevice.restype = c_int
print "RucapCreateDevice:"
print a.RucapCreateDevice(c_int(RUCAP_VERSION))
# initialisation of device
if (a.RucapCreateDevice(c_int(RUCAP_VERSION)) == RUCAP_RESULT_OK): print "Can`t create ruCap device\n"
a.RucapGetHeadPos.restype = c_int
x = c_float(0.0)
y = c_float(0.0)
z = c_float(0.0)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
# main loop
while (1) :
if a.RucapGetHeadPos(byref(x),byref(y),byref(z)):
print "No Position!"
else :
#print '%f %f %f\n' % ( x.value, y.value, z.value)
print x.value, y.value, z.value
sock.send('X%.15f;Y%.15f;Z%.15f;\n' % ( x.value, y.value, z.value))
#result = sock.recv(1024)
#print "Recive:", result
sock.close()
Availability
Additional Information
- RUCAP UM-5 tracker: http://rucap.ru/en/um5/about
PyMol Script of ImmersiveViz
- Project Page: http://code.google.com/p/immersive-viz/
- Source: here and here
- Instructions: here and here