Introduction: Roomba Explorer

By utilizing MATLAB and iRobot's Create2 Robot, this project will explore varying areas of an unknown location. We employed the sensors on the Robot to help maneuver a dangerous terrain. By getting photographs and video feed from a Raspberry Pi that is attached, we were able to determine the obstacles the Robot will face, and they will be classified.

Parts and Materials

For this project, you will need

-a computer

-newest version of MATLAB (MATLAB R2018b was used for this project)

- roombaInstall toolbox

-iRobot's Create2 Robot

-Raspberry Pi with Camera

Step 1: Initialization and Sensors

Before beginning any programming, we downloaded the roombaInstall toolbox, which allowed access to different components of the Robot.

Initially, we created a GUI to initialize any Robot. To do this, you need to type in the number of the Robot as an input. This will allow access to run our program to the Robot We worked on getting the Robot to maneuver through the many terrains it would encounter. We implemented the Cliff Sensors, Light Bump Sensors, and Physical Bump Sensors, by using their outputs to trip the Robot to change its speed and or direction. When any of the six Light Bump Sensors are detecting an object, the value they output will decrease, causing the speed of the Robot to decrease to avoid a full speed collision. When the Robot finally collides with an obstacle, the Physical Bump sensors will report a value greater than zero; because of this, the Robot will stop, so there will be no further collisions and more functions can be put into action. For the Cliff Sensors, they will read the brightness of the area around them. If the value is greater than 2800, we determined that the Robot would be on stable ground and safe. But, If the value is less than 800, the Cliff Sensors will be detecting a cliff, stopping immediately as not to fall off. Any value in between was determined to represent water and will cause the Robot to stop its action. By using the above sensors, the speed of the Robot is changed allowing us to better determine if there is any danger.

Below is the code (from MATLAB R2018b)

%% Initialization

dlgPrompts = {'Roomba Number'};

dlgTitle = 'Select Your Roomba';

dlgDefaults = {''};

opts.Resize = 'on';

dlgout = inputdlg(dlgPrompts,dlgTitle,1,dlgDefaults,opts) % Create window that prompts user to input their roomba number

n=str2double(dlgout{1});

r=roomba(n); % Initializes user specified Roomba %% Speed determination from Light Bump Sensors while true s=r.getLightBumpers; % get light bump sensors

lbumpout_1=extractfield(s,'left'); % takes the numerical values of the sensors and makes them more usable lbumpout_2=extractfield(s,'leftFront');

lbumpout_3=extractfield(s,'leftCenter');

lbumpout_4=extractfield(s,'rightCenter');

lbumpout_5=extractfield(s,'rightFront');

lbumpout_6=extractfield(s,'right');

lbout=[lbumpout_1, lbumpout_2, lbumpout_3, lbumpout_4, lbumpout_5, lbumpout_6] % converts values into matrix

sLbump=sort(lbout); %sorts matrix to lowest value can be extracted

lowLbump=sLbump(1); speed=.05+(lowLbump)*.005 %using lowest value, which represents close obstacles, to determine speed, higher speed when nothing detected

r.setDriveVelocity(speed,speed)

end

% Physical Bumpers

b=r.getBumpers; %Output true,false

bsen_1=extractfield(b,'left')

bsen_2=extractfield(b,'right')

bsen_3=extractfield(b,'front')

bsen_4=extractfield(b,'leftWheelDrop')

bsen_5=extractfield(b,'rightWheelDrop')

bumps=[bsen_1,bsen_2,bsen_3,bsen_4,bsen_5] tbump=sum(bums)

if tbump>0 r.setDriveVelocity(0,0)

end

% Cliff Sensors

c=r.getCliffSensors %% <800 is a cliff, >2800 safe, else water

csen_1=extractfield(c,'left')

csen_2=extractfield(c,'right')

csen_3=extractfield(c,'leftFront')

csen_4=extractfield(c,'rightFront')

cliffs=[csen_1,csen_2,csen_3,csen_4]

ordcliff=sort(cliffs)

if ordcliff(1) < 2750

r.setDriveVelocity(0,0)

if cliff<800

disp 'cliff'

else

disp 'water'

end

r.TurnAngle(45)

end

Step 2: Getting Data

After the Physical Bump Sensors are tripped, the Robot will implement its on board Raspberry Pi to take a photograph of the obstacle. After taking a photograph, using text recognition if there is text in the picture, the Robot will determine what the obstacle is and what the obstacle says.

img = r.getImage; imshow(img);

imwrite(img,'imgfromcamera.jpg')

photo = imread('imgfromcamera.jpg')

ocrResults = ocr(photo)

recognizedText = ocrResults.Text;

figure;

imshow(photo) text(220, 0, recognizedText, 'BackgroundColor', [1 1 1]);

Step 3: Finishing Mission

When the Robot determines that the obstacle is HOME, it will complete its mission and stay home. After completion of the mission, the Robot will send an e-mail alert that it has returned home, and it will send the images that it took along its trip.

% Sending E-mail

setpref('Internet','SMTP_Server','smtp.gmail.com');

setpref('Internet','E_mail','tylerreynoldsroomba@gmail.com'); % mail account to send from setpref('Internet','SMTP_Username','enter sender email'); % senders username setpref('Internet','SMTP_Password','enter sender password'); % 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('Enter receiving email','Roomba','Roomba has returned home!!','imgfromcamera.jpg') % mail account to send to

The Robot is then finished.

Step 4: Conclusion

The MATLAB program included is separated from the whole script that was utilized with the Robot. In the final draft, make sure to put all the code, except for the initialization step, into a while loop to make sure that the bumpers are constantly running. This program can be edited to suit the needs of the user. The configuration of our Robot is shown.

*Reminder: Do not forget that the roombaInstall toolbox is needed for MATLAB to interact with the Robot and the on board Raspberry Pi.