mex RoboRealm.cpp RR_API.cpp RoboRealm('open', 'C:\Program Files\RoboRealm\RoboRealm.exe', 6060); RoboRealm('set_camera', 'Quickcam'); RoboRealm('load_program', 'C:\Program Files\RoboRealm\Examples\MotionOurs.robo'); roomList = [ 3068 3106];% 3196 3198 3234 3209 3209 3187]; on = 1; nulltest = []; roomNumber = 8; %make this the actual number of rooms rooms = zeros(1, roomNumber); roomCounter = 0; %comPortNum = 1; %set to value of comPort %serCommand = initializeComMod(comPortNum); pause(10); %wait for robot to begin moving before initializing motion-check condition while roomCounter<=roomNumber %run loop 8 times (there are 8 rooms on 3rd Chambers) %pause(5); update = RoboRealm('get_variable', 'MOVEMENT_PIXELS'); %this while-loop checks and updates the motion detections script update = str2num(update); while update > 15 %this is the threshold for moving pixels, under which the loop breaks update = RoboRealm('get_variable', 'MOVEMENT_PIXELS'); update = str2num(update); end tic RoboRealm('load_program', 'C:\Program Files\RoboRealm\Examples\NightFilterReflect2robo.robo'); %once the loop breaks, the scanning script is loaded roomCounter = roomCounter +1 ; %keeps track of which room its on check = 0; %resets check variable every loop %ping=1;%change for actual running %while ping==0 % ping = ReadCommand(serCommand); %test ping; put a serial port scanner here %end %disp('received a signal'); % pan left for i = 1:50 RoboRealm('set_variable', 'CAMERA_CONTROL', 4); %turn left pause(.1); if mod(i,25)==0 pause(2); check = RoboRealm('get_variable', 'COG_X'); %sets check to the cog value if isempty(check) ~= 1 %if a tape is detected rooms(roomCounter) = 1; %puts a one at the index of the room its in end end end pause(2); %pan right for j = 1:125 RoboRealm('set_variable', 'CAMERA_CONTROL', 8); %turn right pause(.1); if mod(j,25)==0 pause(2); check = RoboRealm('get_variable', 'COG_X'); %sets check to the cog value if isempty(check) ~= 1 %if a tape is detected rooms(roomCounter) = 1; %puts a one at the index of the room its in end end end pause(2); RoboRealm('set_variable', 'CAMERA_CONTROL', 16); %return home pause(2); RoboRealm('set_variable', 'CAMERA_CONTROL', 0); RoboRealm('load_program', 'C:\Program Files\RoboRealm\Examples\MotionOurs.robo'); %reload motion detection toc pause(10); %wait until starts moving again to loop through [this time needs to be coordinated with robot] end %send email with open windowed rooms message = 'The following rooms have open windows: '; for i=1:length(rooms) if(rooms(i)==1) message = strcat(message,num2str(roomList(i)),', '); end end setpref('Internet','SMTP_Server','smtp.gmail.com'); setpref('Internet','SMTP_Username','davidsonirobot'); setpref('Internet','SMTP_Password','teamCommando'); %setpref('Internet','E_mail','stmeador@davidson.edu'); props = java.lang.System.getProperties; props.setProperty('mail.smtp.auth','true'); props.setProperty('mail.smtp.socketFactory.class','javax.net.ssl.SSLSocketFactory'); props.setProperty('mail.smtp.socketFactory.port','465'); sendmail('laheyer@davidson.edu', 'Open Windows in Chambers', message);