esdalmaijer / PyGaze

an open-source, cross-platform toolbox for minimal-effort programming of eye tracking experiments
www.pygaze.org
GNU General Public License v3.0
671 stars 211 forks source link

OpenSesame plugin crashes after calibration with EyeTribe #22

Closed dschreij closed 9 years ago

dschreij commented 9 years ago

The calibration of the EyeTribe tracker finishes without a problem, but after completion the experiment is aborted with the following error message

exception message: request
exception type: KeyError

Traceback (also in debug window):
  File "C:\Users\Daniel\Documents\GitHub\OpenSesame\libqtopensesame\misc\process.py", line 139, in run
    exp.run()
  File "C:\Users\Daniel\Documents\GitHub\OpenSesame\libopensesame\experiment.py", line 333, in run
    self.items[self.start].run()
  File "C:\Users\Daniel\Documents\GitHub\OpenSesame\libopensesame\sequence.py", line 47, in     run
    self.experiment.items[item].run()
  File "C:\Users\Daniel\AppData\Roaming\.opensesame\plugins\pygaze_init\pygaze_init.py", line 180, in run
    self.experiment.pygaze_eyetracker.calibrate()
  File "C:\Python27\lib\site-packages\pygaze\_eyetracker\libeyetribe.py", line 189, in calibrate
    self.eyetribe.calibration.start(pointcount=len(calibpoints))
  File "C:\Python27\lib\site-packages\pygaze\_eyetracker\pytribe.py", line 1113, in start
response = self.connection.request('calibration', 'start', {'pointcount':pointcount})
  File "C:\Python27\lib\site-packages\pygaze\_eyetracker\pytribe.py", line 394, in request
    elif self.resplist[i]['request'] == request:
KeyError: 'request'
esdalmaijer commented 9 years ago

Hi Daniel,

I've tried to replicate the problem (Windows 7, using OpenSesame Portable 2.8.3 and the latest version of PyGaze and the PyGaze plug-ins for OpenSesame), but couldn't. What system are you testing on, are you using the latest version of PyGaze, and when did the crash occur? Was it simply after calibration, or after retrying?

Also, does this occur every time you try to calibrate? The error traceback seems to indicate that the wrong JSON message from the tracker was picked up by. Could you maybe try to debug by printing the self.resplist in line 391 of pytribe.py?

Thanks for the bug report!

dschreij commented 9 years ago

Hi Edwin,

Thanks for your response. I ran it on a prerelease of OpenSesame 2.9.0 first, but when trying it with 2.8.3 again, I get the same result. A printout of self.resplist looks as follows:

 [{u'category': u'calibration',
   u'statuscode': 800,
   u'values': {u'statusmessage': u'Tracker has been calibrated'}},
  {u'category': u'calibration', u'request': u'start', u'statuscode': 200},
  {u'category': u'tracker',
   u'request': u'get',
   u'statuscode': 200,
   u'values': {u'frame': {u'avg': {u'x': 176.7112, u'y': 917.6643},
     u'fix': False,
     u'lefteye': {u'avg': {u'x': 155.593, u'y': 901.6043},
      u'pcenter': {u'x': 0.3409, u'y': 0.4114},
      u'psize': 20.8036,
      u'raw': {u'x': 155.593, u'y': 901.6043}},
     u'raw': {u'x': 176.7112, u'y': 917.6643},
     u'righteye': {u'avg': {u'x': 197.8293, u'y': 933.7243},
      u'pcenter': {u'x': 0.5093, u'y': 0.4069},
      u'psize': 23.3589,
      u'raw': {u'x': 197.8293, u'y': 933.7243}},
     u'state': 7,
     u'time': 346506113,
     u'timestamp': u'2014-09-08 11:45:21.025'}}}]

I am running the EyeTribe SDK server version 0.9.41-x86 This is the last value at least that is printed before it crashes. A printout of my modules() is as follows:

OpenSesame 2.8.3
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
OpenCV is available (version is unknown)
OpenCV2 2.4.8
QProgedit 1.3.4
Expyriment 0.7.0 (Revision 7a6b73d; Python 2.7.6)
NumPy 1.8.1
PIL is available (version is unknown)
PsychoPy 1.80.06
PyAudio 0.2.7
PyGame 1.9.2pre
Pyglet 1.1.4
PyOpenGL 3.0.2
PyQt 4.9.6
PySerial 2.7
python-bidi 0.3.4
python-markdown 2.3.1
SciPy 0.14.0

Don't know if it is of any use to you, but just for the sake of completeness ;)

esdalmaijer commented 9 years ago

Thanks, that helps immensely! What is happening, is that the EyeTribe sends back the following message after being calibrated:

{u'category': u'calibration',
   u'statuscode': 800,
   u'values': {u'statusmessage': u'Tracker has been calibrated'}}

However, the connection's request method is expecting messages that contain a 'request' key, which the unprovoked messages form the tracker apparently do not have. Hence the KeyError when the "Tracker has been calibrated" message is parsed in line 392 of pytribe.py. I'll fix and commit shortly.

Thanks for debugging!

esdalmaijer commented 9 years ago

Fixed with the latest commit. Could you check if it works now?

dschreij commented 9 years ago

It works now!

esdalmaijer commented 9 years ago

Awesome, thanks for checking!