Read the next message comming from the server and outputs the data This function reads any message coming from the server, parses it, and returns a structure 'data' containing the data. The data are the same as in a urbiMessage, but in a different order to suit matlab conventions about missing output arguments timeStamp : the time stamp of the message tag : the tag of the message type : the type of the message: 'numeric', 'string', 'system', 'error', 'image', 'sound', or 'otherBIN') if type == numeric, then data is the numeric value of the message if type == string, then data is the string value of the message if type == system, then data is the string value of the system message if type == image, then data is the same as the result of urbiGetImage(con) (with the fields matrix, width, height, timeStamp) if type == sound, then data is the same as the result of urbiGetSound(con, length) (with the fields samples, Fs, nbits, length) if type == otherBIN then data is the vector of bytes of the BIN info
0001 function [data,timeStamp, tag, type] = urbiGet(con) 0002 % Read the next message comming from the server and outputs the data 0003 % This function reads any message coming from the server, parses it, and 0004 % returns a structure 'data' containing the data. The data are the same as 0005 % in a urbiMessage, but in a different order to suit matlab conventions 0006 % about missing output arguments 0007 % 0008 % timeStamp : the time stamp of the message 0009 % tag : the tag of the message 0010 % type : the type of the message: 'numeric', 'string', 0011 % 'system', 'error', 'image', 'sound', or 'otherBIN') 0012 % 0013 % if type == numeric, then data is the numeric value of the message 0014 % if type == string, then data is the string value of the message 0015 % if type == system, then data is the string value of the system message 0016 % if type == image, then data is the same as the result of urbiGetImage(con) 0017 % (with the fields matrix, width, height, timeStamp) 0018 % if type == sound, then data is the same as the result of urbiGetSound(con, length) 0019 % (with the fields samples, Fs, nbits, length) 0020 % if type == otherBIN then data is the vector of bytes of the BIN info 0021 0022 0023 0024 string = pnet(con, 'readline', 'view', 'noblock'); 0025 disp(string); 0026 0027 0028 data = []; 0029 type = 'nothing'; 0030 timeStamp = -1; 0031 tag = ''; 0032 0033 if (~isempty(string)) 0034 ans_string = strread(string, '%s'); 0035 [timeStamp, tag] = strread(ans_string{1}, '[%u:%s]', 'whitespace', ']'); 0036 %display(ans_string) ; 0037 0038 umessage = urbiFullParse(ans_string, timeStamp, con); 0039 0040 type = umessage.type; 0041 0042 if (strcmp(type,'numeric') || strcmp(type,'string') || strcmp(type,'system') || strcmp(type,'error')) 0043 data = umessage.value; 0044 elseif(strcmp(type,'image')) 0045 data = umessage.image; 0046 elseif(strcmp(type,'sound')) 0047 data = umessage.sound; 0048 elseif(strcmp(type,'otherBIN')) 0049 data = umessage.bin; 0050 end; 0051 0052 end ;