UTK EF 230 MarsRoomba Project Fall 2018

Introduction: UTK EF 230 MarsRoomba Project Fall 2018

Currently, Mars rovers are used to collect data on the surface of Mars through various methods, to the ultimate end of learning more about the planet’s potential for microbial life. Rovers primarily use photography and soil analysis tools for data collection, but rovers also include navigation instruments, radiation detectors, atmospheric sensors, and a laser for rock sample vaporization. The planned 2020 rover mission’s goal is mostly the same, but with the special task to “collect samples of soil and rock and cache them on the surface for potential return to Earth by a future mission,” according to NASA.

However, under the premise that future rovers will be used for human assistance, our team considered what aspects of humans the rover could monitor. We came to the conclusion that should some emergency render an astronaut unconscious with failing life support and equipment, our rover could serve as a mobile mayday beacon by observing that the astronaut it followed is immobile and relaying a message of distress. To follow the human and determine immobility, the rover would take inputs such as the color of the human’s shoes and their motion. Another input to consider is that it would have to remember its path in order relay a distress signal in case of emergency. Our rover meets a need on Mars in that attempting such a costly mission on such foreign terrain necessitates multiple layers of fail-safes, and should an astronaut not be able to get their own help due to suit malfunction or unconsciousness, the rover can alert others.

This Instructable is designed to aid the reader in programming his or her Roomba to successfully follow an "astronaut" and to send a distress signal if applicable.

Step 1: Materials Needed

1) Internet accessible computer/laptop

2) MATLAB_R2018a

3) Roomba and Roomba Download

Step 2: Setup/Download

Run this script in MATLAB in order to download the software needed to access the Roomba (saved in its own file in the project folder).

Additional Help: https://ef.engr.utk.edu/ef230-2017-08/projects/ro...

% Installation program for EF 230 Roomba Project
% Last update: September 13, 2017 (Fixed security issues associated with https server and removed file delete warning if errors occured) function roombaInstall clc; % list of files to install files = {'roomba.m','roombaSim.m','roombaSimGUI.m','roombaSimGUI.fig'}; % location to install from options = weboptions('CertificateFilename',''); % tell it to ignore certificate requirements server = 'https://ef.engr.utk.edu/ef230/projects/roomba-f2016/install/'; dlgTitle = 'Roomba Install/Update'; % display purpose and get confirmation prompt = { 'This program will download these EF 230 Roomba files:' '' strjoin(files,' ') '' 'to this folder:' '' cd '' 'Do you want to continue? ' }; beep; yn = questdlg(prompt, ... dlgTitle, ... 'Yes','No','Yes');

if ~strcmp(yn,'Yes'), return; end

% get list of files that exist existing_files = files( cellfun(@exist,files) > 0 ); if ~isempty(existing_files) % make sure it is really ok to replace them prompt = {'You are replacing these file(s): ' '' strjoin(existing_files,' ') '' 'OK to replace?' }; beep; yn = questdlg(prompt, ... dlgTitle, ... 'Yes','No','Yes'); if ~strcmp(yn,'Yes'), return; end end

% download the files cnt = 0; for i=1:length(files) f=files{i}; disp(['Downloading ' f]); try url = [server f]; websave(f,url,options); % added options to avoid security errors cnt = cnt + 1; catch disp(['Error downloading ' f]); dummy = [f '.html']; if exist(dummy,'file')==2 delete(dummy) end end end

if cnt == length(files) msg = 'Installation Successful'; waitfor(msgbox(msg,dlgTitle)); else msg = 'Installation Error - see command window for details'; waitfor(errordlg(msg,dlgTitle)); end

end %roombaInstall

Step 3: Code Part 1: Tracking Function

This function takes the Roomba variable and the picture from the camera on the Roomba and finds the center xy coordinates of the tracked object.

Save this code in another file in the same folder.

function [xm, ym] = trackingblue(r)
%Inputs: roomba variable %Outputs: x and y value of the center of the following object %Purpose: finds the center of a blue object given an image %Usage [x value, y value] = trackingblue(roomba variable) img=r.getImage; % reads the camera off of the robot subplot(1,2,2) subimage(img); %shows image in the same window as the path title('Tracking Image') red = img(:,:,1); green = img(:,:,2); blue = img(:,:,3); justBlue = blue - green/2 - red/2; bw = justBlue > 40; hold on subplot(1,2,2) subimage(bw); [x, y] = find(bw); if ~isempty(x) && ~isempty(y) xm = round(mean(x)); ym = round(mean(y)); xx = max(1, xm-5):min(xm+5, size(bw, 1)); yy = max(1, ym-5):min(ym+5, size(bw, 2)); bwbw = zeros(size(bw), 'uint8'); bwbw(xx, yy) = 255; hold on subplot(1,2,2) subimage(justBlue + bwbw); end

Step 4: Code Part 2: While Loop

This code drives the Roomba based on the x and y location of the object from the tracking function. This will make the Roomba watch out for walls and cliffs, while seeking out blue. This will also take the x and y coordinates of the Roomba path and create a corresponding plot with the tracking image. If the bump sensor is activated it will move on to the email section.

%Rover Project

%Jonah Zahn, Wade Price, Noah Sloan %jzahn2, wprice15, nsloan1 %Inputs: roomba value, camera data, bump, light and wall sensors %Purpose: Follows astronaut and avoids obstacles. If alerted, the roomba sends an email %detailing a map and where it is according to its start position. %Usage: just run the program with having declared a roomba variable, also %have a moving green object %Outputs: shows image tracking picture, emails map and text to user %% Following Section b=0; %Initializing variables c=0; x=0; y=0; theta=0; while c==0 %Loop to make it detect the blue object and obstacles t = r.timeGet; d = r.getDistance; [xval,yval] = trackingblue(r); cliff=getCliffSensors(r); %initializing the structures for sensor values light=getLightBumpers(r); bump= getBumpers(r); if light.leftCenter >= 10 || light.rightCenter >= 10 %Senses if there is a wall near r.stop r.setLEDDigits('help') c=1 % while b==0 % if bump.right == 1 || bump.left == 1 || bump.front == 1 %Senses if it has bumped something after it senses a wall % c=1 % b=1 % disp('bump') % end % end elseif bump.right == 1 || bump.left == 1 || bump.front == 1 %Senses if it has bumped something, if so, it will send an email r.stop c=1 b=1 elseif cliff.leftFront <= 100 || cliff.rightFront <= 100 || cliff.left <= 100 || cliff.right <= 100 %Senses if there is a cliff near r.stop c=1 r.setLEDDigits('help') else %Sets the drive velocities to follow the blue if yval <= 400 && yval >= 100 r.setDriveVelocity(0.1) elseif yval < 100 r.turnAngle(5) elseif yval > 400 r.turnAngle(-5) end end theta = theta + r.getAngle; x = d.*cosd(theta) + x; % x coordinate of the roomba y = d.*sind(theta).*d + y; % y coordinate of the roomba subplot(1,2,1) plot(x,y,'bd') % plots the path and adds a title title('Roomba Path') hold on; end

Step 5: Code Part 3: Email Section

This will take the plotted path and image and send it to a specified email address.

(Shown here with example email)

%% Email Section

if b==1 saveas(gcf,'rovermap.png') %saves the figure setpref('Internet','SMTP_Server','smtp.gmail.com'); setpref('Internet','E_mail','gssecomputercomputer@gmail.com'); % mail account to send from setpref('Internet','SMTP_Username','gssecomputercomputer@gmail.com'); % senders username setpref('Internet','SMTP_Password','gssegsse'); % Senders password 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('example email','RoverBeacon','The astronaut has stopped moving. For recovery, follow the directions in the attached file.','rovermap.png') disp('email sent') end

Be the First to Share


    • Puzzles Challenge

      Puzzles Challenge
    • Lamps Challenge

      Lamps Challenge
    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest



    4 years ago

    What a fun project! Thanks for sharing!