Roomba MATLAB Project

The current plan that NASA has for the Mars rover is for it to be a data collector and roam around Mars, collecting samples of the soil to bring back to Earth so that scientists can see if there were any previous life forms on the planet. Additionally, the rover sends back images to scientists, so that they can help navigate the rover and fix any problems it might have.

Our group's idea for our project is for the rover to do the same as the NASA rover that will be leaving earth in 2020, but for it also to map out the geography of the land. The roomba would be able to sense cliffs and stop itself before it falls off, and then back up, turn, and change its course so that it will not fall and be damaged. Our other idea integrated into our project is for the roomba to be able to plot out the landmarks it sees, and show a plot each time the loop is finished and its course has been run.

This instructable is for anyone else who would like to create the same type of code for their roomba.

Step 1: Step 1: Materials Needed

You will need:

  1. A roomba
  2. MATLAB
  3. This file to run the roomba
  4. A flat surface
  5. A table surface to act as a "cliff"

Step 2: Step 2: Setting Up/Getting Code for Roomba

Your screen will look like this once you input the files.

Step 3: Step 3: Setting Up Cliff Sensors/LED Lights

This code will tell your roomba exactly what angle to turn, check the battery info, tell your roomba how fast to go, and to check for a person through the roomba's camera. It will also beep if it identifies a person, and stop itself before going off a cliff.

% try
rob.setLEDDigits('') x=0; y=0; theta=0; obstacle = []; cycle = 1; AngCorr = @(x)x + 3.059.*x.^0.4205; %Function to correct turn angles while rob.getBatteryInfo.percent > 15 rob.setLEDDigits('') rob.setDriveVelocity(0.1) %Go %Check For Person if AA_checkperson(rob) rob.beep end %Check Cliff Sensor if AA_cliffcheck(rob) rob.stop rob.setLEDDigits('Cliff') pause(0.5) obstacle(cycle) = 2; AA_cliffbeep(rob) %Back Up And Turn rob.moveDistance(-.15) rob.turnAngle(30) end

Step 4: Step 4: Checking for Obstacles

This code will get the roomba for check for items around it, and will check the bump sensor to make sure it stops before it damages itself.

%Check Light Sensor
if AA_lightcheck(rob) rob.stop rob.setLEDDigits('Wall') pause(0.5) obstacle(cycle) = 1; %Wall AA_wallbeep(rob) %Back Up And Turn rob.moveDistance(-.15) rob.turnAngle(30) end %Check Bump Sensor if AA_bumpcheck(rob) rob.stop rob.setLEDDigits('Wall') pause(0.5) obstacle(cycle) = 1; %Wall AA_wallbeep(rob) %Back Up And Turn rob.moveDistance(-.15) rob.turnAngle(30) end %If none if isempty(obstacle) obstacle(cycle) = 0; elseif length(obstacle) < cycle obstacle(cycle) = 0; end

Step 5: Step 5: Plotting

This code will tell your roomba to plot out what it encounters on its journey. A plot like this one will appear after the roomba has stopped.

%Get Position
d = rob.getDistance; if cycle == 1 theta(cycle) = 0; x(cycle) = d.*cosd(theta(cycle)); % total dist traveled in x y(cycle) = d.*sind(theta(cycle)); % total dist traveled in y else theta(cycle) = theta(cycle-1) + rob.getAngle; x(cycle) = d.*cosd(theta(cycle)) + x(cycle-1); % total dist traveled in x y(cycle) = d.*sind(theta(cycle)).*d + y(cycle-1); % total dist traveled in y end %Break condition if rob.getButtons.clean break end %Increment cycle cycle = cycle + 1; end rob.stop for i = 1:cycle if obstacle(i) == 1 %Wall plot(x(i),y(i),'Marker','square','MarkerEdgeColor','r') elseif obstacle(i) == 2 %Cliff plot(x(i),y(i),'Marker','o','MarkerEdgeColor','k') end text(.9,0.9,sprintf('Square = Wall \nCircle = Cliff'),'Units','normalized') hold on end %Distress Signal while true rob.beep pause(3) if rob.getButtons.clean break end end % catch % rob.stop % end

Share

    Recommendations

    • Optics Contest

      Optics Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Plastics Contest

      Plastics Contest

    Discussions