IRobot Create-Mars Expedition Rover Mark I

This instructable will teach you how to set up the iRobot Create by using MatLab coding. Your robot will have the ability to search for minerals by distinguishing shapes, maneuver rugged terrain through the use of cliff sensors, and has the ability to be manually controlled via a live feed.

Step 1: Supplies

For this project, you will need an the iRobot Create, which is a programmable version of the Roomba robot vacuum cleaner. The robot comes equipped with all of the sensors needed for this project, specifically bump sensors, cliff sensors and "Light Bump" sensors. You will also need a Raspberry Pi and video camera, used for wireless communication, live programming, and the live video feed. Lastly, you will need a 3D printed mount for the Raspberry Pi and camera.

Step 2: Develop Coding to Satisfy Desirable Outcome

Once you have connected your Roomba, you will need to create a Matlab code that will give you your desired outputs after your desired inputs.

The code can be seen here:

%Roomba Project
%Brenten Arnold (barnol15); Julianne Korn (qdp218); Mike Heal(mheal) %4/11/19 %Problem Description: Create a rover to assist humans during %exploration/habitation of mars. %Solution method: Search for organic(green) matter through use of %light bumpers, cliff sensors and camera to check for organic matter. Allow %the rover to navigate rough terrain through the use of bumpers, cliff %sensors, and wheel height sensors. Enable humans to control the rover from %a safe distance away and manually search for minerals. choices = {'LIFE','ROUGH TERRAIN','USER CONTROL'}; %Three options in dialog menu Setting = menu('',choices) if Setting>0 %If option chosen ask for user confirmation choices2 = {'Yes', 'No'} %Create a cell array for "yes" or "No" choice Confirm = menu(['You chose "' choices{Setting} '" mode.'], choices2) %Confirm user setting choice if Confirm==1 if Setting==1 %Check if "LIFE" setting was chosen i=0 while i==0 r.setLEDDigits(num2str('LIFE')) %Display 'LIFE' on LED for i=1:100 r.setDriveVelocity(0.05) %Move roomba forward at 0.05 m/s y = r.getCliffSensors %Retrieve and store cliff sensor values in cell structure "y" l = r.getLightBumpers %Retrieve and store light bump values in structure "f" if l.left>100 %Check if left light bumper is covered r.moveDistance(-0.05) %Move roomba backward 0.05 meters r.turnAngle(20) %Rotate roomba 20 degrees CCW img=r.getImage %Get image from rasberry pie camera on roomba rect = [100 0 150 150]; img = imcrop(img,rect) %crop image to focus on center red = mean(mean(img(:,:,1))) %average red intensity green = mean(mean(img(:,:,2))) %average green intensity blue = mean(mean(img(:,:,3))) %average blue intensity if green>red && green>blue %Check if plant is in the picture d=msgbox(['Life found!']); %Display a message box saying "Life found!" waitfor(d); end elseif l.leftFront>100 %Check is left/front light bumper is covered r.moveDistance(-0.05) %Move roomba backward 0.05 meters img=r.getImage %Get image from rasberry pie camera on roomba and store in variable 'img' rect = [100 0 150 150]; img = imcrop(img,rect) %crop image to focus on center red = mean(mean(img(:,:,1))) %average red intensity green = mean(mean(img(:,:,2))) %average green intensity blue = mean(mean(img(:,:,3))) %average blue intensity if green>red && green>blue %Check if plant is in the picture d=msgbox(['Life found!']); %Display a message box saying "Life found!" waitfor(d); end elseif l.leftCenter>100 %Check if left/center light bumper is covered r.moveDistance(-0.05) %Move roomba backward 0.05 meters img=r.getImage %Get image from rasberry pie camera on roomba and store in variable 'img' rect = [100 0 150 150]; img = imcrop(img,rect) %crop image to focus on center red = mean(mean(img(:,:,1))) %average red intensity green = mean(mean(img(:,:,2))) %average green intensity blue = mean(mean(img(:,:,3))) %average blue intensity if green>red && green>blue %Check if plant is in the picture d=msgbox(['Life found!']); %Display a message box saying "Life found!" waitfor(d); end elseif l.rightCenter>100 %Check if right/center light bumper is covered r.moveDistance(-0.05)%Move roomba backward 0.05 meters img=r.getImage %Get image from rasberry pie camera on roomba and store in variable 'img' rect = [100 0 150 150]; img = imcrop(img,rect) %crop image to focus on center red = mean(mean(img(:,:,1))) %average red intensity green = mean(mean(img(:,:,2))) %average green intensity blue = mean(mean(img(:,:,3))) %average blue intensity if green>red && green>blue %Check if plant is in the picture d=msgbox(['Life found!']); %Display a message box saying "Life found!" waitfor(d); end elseif l.rightFront>100 %Check if right/front light bumper is covered r.moveDistance(-0.05)%Move roomba backward 0.05 meters img=r.getImage %Get image from rasberry pie camera on roomba and store in variable 'img' rect = [100 0 150 150]; img = imcrop(img,rect) %crop image to focus on center red = mean(mean(img(:,:,1))) %average red intensity green = mean(mean(img(:,:,2))) %average green intensity blue = mean(mean(img(:,:,3))) %average blue intensity if green>red && green>blue %Check if plant is in the picture d=msgbox(['Life found!']); %Display a message box saying "Life found!" waitfor(d); end elseif l.right>100 %Check if right light bumper is covered r.moveDistance(-0.05)%Move roomba backward 0.05 meters r.turnAngle(-20)%Rotate roomba 20 degrees CW img=r.getImage %Get image from rasberry pie camera on roomba and store in variable 'img' rect = [100 0 150 150]; img = imcrop(img,rect) %crop image to focus on center red = mean(mean(img(:,:,1))) %average red intensity green = mean(mean(img(:,:,2))) %average green intensity blue = mean(mean(img(:,:,3))) %average blue intensity if green>red && green>blue %Check if plant is in the picture d=msgbox(['Life found!']); %Display a message box saying "Life found!" waitfor(d); end elseif y.leftFront<1500 %Check if left/front portion of roomba is off cliff r.moveDistance(-0.1,0.05) %Move roomba backward 0.1 meters at 0.05 m/s r.turnAngle(-5) %Rotate roomba 5 degrees CW elseif y.rightFront<1500 %Check if right/front portion of roomba is off cliff r.moveDistance(-0.1,0.05) %Move roomba backward 0.1 meters at 0.05 m/s r.turnAngle(5) %Rotate roomba 5 degrees CCW elseif y.left<1000 %Check if left side of roomba is off cliff r.moveDistance(-0.05,0.05) %Move roomba backward 0.05 meters at 0.05 m/s r.turnAngle(-10) %Rotate roomba 10 degrees CW elseif y.right<1000 %Check if right side of roomba is off cliff r.moveDistance(-0.05,0.05)%Move roomba backward 0.05 meters at 0.05 m/s r.turnAngle(10) %Rotate roomba 10 degrees CCW end end r.setDriveVelocity(0) %Stop roomba from moving choices4 = {'Yes', 'No'} %Create a cell array for "yes" or "No" choice Continue = menu('Continue "LIFE?" mode?', choices2) %Confirm user setting choice if Continue>0 %Run if button is pressed if Continue==1 i=0 %Continue searching for life else i=1 %End LIFE mode end end end elseif Setting==2 %Check if "ROUGH TERRAIN" setting was chosen i=0 while i==0 r.setLEDDigits(num2str('RGH')) %Display 'Rough' on LED Display for i=1:1000 r.setDriveVelocity(0.05) %Set roomba drive velocity to 0.05 m/s x = r.getBumpers %Retrieve and store bumper sensor values in structure "x" y = r.getCliffSensors %Retrieve and store cliff sensor values in structure "y" if x.right==1 %Check if right bumper is pressed r.turnAngle(10) %Rotate roomba 10 degrees CCW elseif x.left==1 %Check if left bumper is pressed r.turnAngle(-10) %Rotate roomba 10 degrees CW elseif x.front==1 %Check if front bumper is pressed r.turnAngle(20) %Rotate roomba 20 degrees CCW elseif x.rightWheelDrop==1 %Check if right wheel has dropped r.turnAngle(-20)%Rotate roomba 20 degrees CW elseif x.leftWheelDrop==1 %Check is left wheel has dropped r.turnAngle(20) %Rotate roomba 20 degrees CCW elseif y.leftFront<1500 %Check if front left portion of roomba is off cliff r.moveDistance(-0.05,0.05) %Move roomba backward 0.05 meters at 0.05 m/s r.turnAngle(-5)%Rotate roomba 5 degrees CW elseif y.rightFront<1500 %Check if right front portion of roomba is off cliff r.moveDistance(-0.05,0.05)%Move roomba backward 0.05 meters at 0.05 m/s r.turnAngle(5) %Rotate roomba 5 degrees CCW elseif y.left<1000 %Check if left portion of roomba is off cliff r.moveDistance(-0.05,0.05)%Move roomba backward 0.05 meters at 0.05 m/s r.turnAngle(-10)%Rotate roomba 10 degrees CW elseif y.right<1000 %Check if left portion of roomba is off cliff r.moveDistance(-0.05,0.05)%Move roomba backward 0.05 meters at 0.05 m/s r.turnAngle(10)%Rotate roomba 10 degrees CCW end end r.setDriveVelocity(0) %Stop roomba from moving choices3 = {'Yes', 'No'} %Create a cell array for "yes" or "No" choice Continue = menu('Continue "ROUGH TERRAIN"?', choices2) %Confirm user setting choice if Continue>0 if Continue==1 i=0 %Continue rough terrain else i=1 %End rough terrain end end end else %Manual Mode i=0 r.setLEDDigits(num2str('USER')) %Display 'USER' on LED Display d=msgbox(['Arrow Keys - Move; S - Stop Rover; ESC - End User Control; A - Locate Resource']); waitfor(d); while i==0 r.showCamera %Open rasberry pie camera live feed in separate window D=getkey(1) %Retrieve key pressed by user, store ASCII value as variable D if D==30 %Check if "up" arrow has been pressed r.setDriveVelocity(0.1) %Send roomba forward at 0.2 m/s elseif D==28 %Check if "left" arrow was pressed r.setDriveVelocity(0) %Stop roomba from moving forward or backward r.turnAngle(15,0.05)%Rotate roomba 45 degrees CCW at 0.05 m/s elseif D==31 %Check if "down" arrow was pressed r.setDriveVelocity(-0.1) %Move roomba backward at 0.2 m/s elseif D==29 %Check if "right" arrow is pressed r.setDriveVelocity(0) %Stop roomba from moving forward or backward r.turnAngle(-15,0.05) %Rotate roomba 45 degrees CW at 0.05 m/s elseif D==27 %Check if the "esc" (escape) key was pressed i=1 %Change value of variable "i" to exit loop d=msgbox('Exiting "User Control"') %Let user know that manual mode is being exited elseif D==115 %Check if the "s" key has been pressed r.setDriveVelocity(0) %Stop roomba from going forward or backward elseif D==97 %Check if "a" has been pressed image = r.getImage; imwrite(image,'image.png') W = Classify(image) K = mode(W) if K == 3 d=msgbox('Resource found') %Display if rectangular resource detected waitfor(d); %Wait for user to close message box "d" elseif K == 0 d=msgbox('Not Resource :(') %Display if rectangular resource not detected waitfor(d); %Wait for user to close message box "d" end else d=msgbox('Not a valid key input.') %Display if user closes "choose setting" menu waitfor(d); %Wait for user to close message box "d" end waitfor(d); %Wait for user to close message box "d" end end end else d=msgbox('Goodbye') %Says goodbye if options are closed end waitfor(d);

Step 3: Testing

Once your code has been written, you will need to test your Roomba. Although your code may seem correct, many of your values, especially for color or shape, will need to be changed in order to properly recognize the objects that you would like your Roomba to identify.

Step 4: Observe Visual Outputs

It will be very apparent whether or not you have successfully programmed your Roomba based on its visual outputs.

Outputs include:

  • Shape Detection: The Roomba's ability to properly distinguish shapes in order to find the correct minerals
  • Rough Terrain Maneuvers: Avoids cliffs or dark areas
  • Manual Mode: Live feed and the ability to control the Roomba
  • Pictures: Pictures of minerals
  • Life Found!: A MatLab text box signifying that your plant has identified organic life.

That's the end of our tutorial, enjoy your new Mars Expedition Rover!

Share

    Recommendations

    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Optics Contest

      Optics Contest
    • Plastics Contest

      Plastics Contest

    Discussions

    0
    None
    seamster

    7 months ago

    Nicely done. I love that roomba sells the base platforms for people to build on. Nice to see what you did with yours!