Introduction: Mars Reconnaissance Robot

This Instructable is a step-by-step guide to program and command the Mars Reconnaissance Robot.

To start, one must obtain the list of the following materials: A charged iRobot create customized by the Tickle College of Eningeering Univerisity of Tennessee, A wireless network which is connected to the Raspberry Pi in the iRobot, UTK iRobot create charger, Wifi-capable computer with access to MATLAB and the internet.

Step 1: Roomba Toolbox

Open MATLAB and create a new folder for the code files to be stored from your project. In MATLAB, open a new script and run the code below. Once the script is ran, add the new folder to the directory where MATLAB looks for files.

Code:

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 2: Preparing to Connect

Connect the micro-USB protruding from the robot to the bottom port of the Raspberry Pi. Then on the top of the Roomba, simultaneously press and hold the dock and spot buttons until the light on the Roomba dims. You should hear a electronic scale from the Roomba once you release.

Step 3: Connecting to the Robot

Open the available networks on your computer and select the existing network between the computer and Raspberry Pi. In MATLAB's current folder, right click on your current project folder and select the roomba toolbox downloaded in step 1 and add to the path. In a network which is designed for multiple Pi connections, specify your robot by creating an object of class Roomba. See example below

If you have a Roomba assigned to the number 7, enter the following:

r=roomba(7)

%Remember that this variable is now assigned to the roomba, any command given to the robot must be lead by the assigned variable.

Step 4: Code

https://drive.google.com/drive/folders/1OVR5oTHUsn...

Using the link above, save all the .m files, to the given folder where the main program will be run. The link should be open to all who have the link. Open a new script in the current folder and run mycontrolprogram.m as seen below:

function mycontrolprogram(r)
global m m = mobiledev; emailInit(); running = 1; global f global count count = 0; f = r; global direc direc = 0; r.getAngle; r.getDistance; global curLoc curLoc = [0,0]; global pts pts = zeros(1,2,2); manual = true; graphObs(1); v = 0.15; while count < 50 if(manual == false) obsDetect(r,v,pts); direc = direc + r.getAngle; r.setLEDDigits(num2str(count)); else direc = direc + r.getAngle; manualDrive(); end end figSend(); end

The Robot should now perform its designed job.