Commit d55381d2 authored by Jesse Heckman's avatar Jesse Heckman
Browse files

updated server functionality + light simulator

parent c5ed4e51
function rpl = pb_pl2rpl(pl,ot,gaze_prim,ot_rigid)
% PB_PL2RPL()
%
% PB_PL2RPL() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
rpl = [];
Pup = pl;
Opt = ot;
gaze_prim.Data=[];
gaze_prim.Data(1,:)=Pup.timestamp;
gaze_prim.Data(2,:)=Pup.confidence;
gaze_prim.Data(3,:)=Pup.timestamp;
gaze_prim.Data(4,:)=Pup.norm_pos(:,1);
gaze_prim.Data(5,:)=Pup.norm_pos(:,2);
lsl_tsPup = lsl_correct_pupil_timestamps(gaze_prim);
lsl_tsOpt = lsl_correct_lsl_timestamps(ot_rigid);
q = quaternion(Opt.qx,Opt.qy,Opt.qz,Opt.qw);
q1= quaternion(Opt.qx(1),Opt.qy(1),Opt.qz(1),Opt.qw(1));
qRot=q*inverse(q1);
qRotDouble=double(qRot);
[az el rot] = quaternion2azel(Opt.qx,Opt.qy,Opt.qz,Opt.qw);
[azRot elRot rotRot] = quaternion2azel(qRotDouble(1,:,:),qRotDouble(2,:,:),qRotDouble(3,:,:),qRotDouble(4,:,:));
normv = Pup.gaze_normal_3d(1:10,:);
normv=median(normv);
% Estimate rotation matrix
GG = @(A,B) [ dot(A,B) -norm(cross(A,B)) 0;
norm(cross(A,B)) dot(A,B) 0;
0 0 1];
FFi = @(A,B) [ A (B-dot(A,B)*A)/norm(B-dot(A,B)*A) cross(B,A) ];
UU = @(Fi,G) Fi*G*inv(Fi);
b=normv'; a=[0 0 1]';
Rot = UU(FFi(a,b), GG(a,b));
% Rotate
gaze_normalsrot=Pup.gaze_normal_3d*Rot;
% gaze_normalsrot(Pup.confidence<0.6,:)=NaN;
% Convert to angles
ax2=real(asind(gaze_normalsrot(:,2)));
ax1=real(asind(gaze_normalsrot(:,1)./cosd(ax2)));
% Interpolate in order to create gaze
azinterp=interp1(lsl_tsOpt,azRot,lsl_tsPup,'spline');
elinterp=interp1(lsl_tsOpt,elRot,lsl_tsPup,'spline');
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......@@ -30,10 +30,10 @@ function pb_lightviewer(varargin)
end
run_show(h,ls,leds,freq);
run_show(ls,leds,freq);
end
function run_show(h,ls,leds,freq)
function run_show(ls,leds,freq)
n = 8;
for idx = 1:n
if mod(idx,length(ls)) == 0
......
......@@ -10,6 +10,8 @@ function [sn] = pb_mountserver(varargin)
srv = pb_keyval('server',varargin,'mbaudit5');
force = pb_keyval('force',varargin,false);
flag = pb_keyval('flag',varargin,true);
prfx = '';
cin = ['mount -t smbfs //' getcredentials(srv) '@' srv '-srv.science.ru.nl/' srv '/ ~/sharename/'];
......@@ -17,7 +19,8 @@ function [sn] = pb_mountserver(varargin)
if s > 0 && s ~= 64; disp(cout); end
if s == 64 && ~force; system('umount ~/sharename/'); prfx = 'un'; end
disp([srv ' is ' prfx 'mounted.' newline])
if s == 0 && flag; pb_open; end
disp([srv ' is ' prfx 'mounted.' newline]);
end
function auth = getcredentials(srv)
......
function cout = pb_open(folder, varargin)
% PB_OPEN()
%
% PB_OPEN() ...
% PB_OPEN() opens directory.
%
% See also ...
% See also PB_MOUNTSERVER
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
......@@ -12,7 +12,8 @@ function cout = pb_open(folder, varargin)
end
if exist(folder,'dir')
system(['open ' folder])
cin = ['open ' folder];
cout = system(cin);
end
end
......
......@@ -9,9 +9,9 @@ function [fname, path] = pb_getfile(varargin)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
cdir = pb_keyval('dir',varargin,userpath);
ext = pb_keyval('ext',varargin,'*.*');
title = pb_keyval('title',varargin,'Open file...'); % titles have been removed from matlab ui's in OS X - El capitain
cdir = pb_keyval('dir',varargin,cd);
ext = pb_keyval('ext',varargin,'*.*');
title = pb_keyval('title',varargin,'Open file...'); % titles have been removed from matlab ui's in OS X - El capitain
cd(cdir);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment