Simple robot to go through all the space available

Hi,

I built a robot with 2 motors on each side and a spinning wheel on the front, so it can go forward/backward and turn right/left easily. Then I attached a mop on the bottom of it so when it drives around, it drags the mop around and “cleans” the space. (photo attached).

I created one single mode: random (go ahead, if hit something, turn right a random amount and try to go ahead again…). It works fine and randomly cleans the floor. Given enough time, it will clean every single spot on my pretty small apartment.

Then I thought that maybe someone already created a “vaccum robot cleaning” algorithm to try to “map” a space and go through all the available space. Of course, using just a single switch in front of the robot, will not make it map the space, but if with that switch it could at least try to go at the most space available it would be awesome. I was thinking about using MPU6050 with PDI to make the robot goes straight and turn right/left in a precise amount, trying to drive at least in a “predictable” way, would be nice.

So after googling a lot, I didnt find anything closer to this simple task that I told you. So I ask you: does any of you know of any project like that so I can use the code?

Using random is/was the strategy in many commercial cleaners like that. Wheels slipping, losing some short distance at every impact... Forget mapping the surface. I think You have a realy good machine as it is!

@Railroader thanks! Indeed it looks to work, but it usually passes 3 or 4 times over the same places before reaching new places. Random looks good, but I was thinking that using MPU6050 I could prevent that wheel slip, cause I can track yaw rotation and that could help me make the robot always keep a straight line! Anyway, if you or anyone else knows a better way, I would love to hear!

The MPU-6050 can't measure yaw, because it has no North reference. MPU-6050 yaw values are always relative to the starting orientation and will drift, due to gyro drift.

A magnetometer (digital compass) works well, but must be calibrated on the robot.

@jremington Actually it does not need a reference at yaw, since I just want it to go a straight line from the orientation it starts OR from the last orientation that it hit something. For example: suppose the robot is going forward and then it hits something. With MPU6050 I can tell the motors to spin until the angle is the current + 20 degrees. After it stops spinning, then it goes in a straight line, keeping alway the same yaw angle, untill it hits something, then it spins another 20 degrees (or a random number) and keeps going straight. This way at least the robot can go straight.

The magnetometer surelly would be a better alternative, I didnt think about it. Unfortunatelly I dont have any here with me, so I will have to deal with the MPU6050.

Also, the drift that you said indeed would make the robot not go very straight, bug since it will change its orientation everytime it hits something, the drift will be too small while it's driving straight, dont you think?

The drift rate of the MPU-6050 gyros depends directly on how well you measure and subtract the zero offset. If you do a good job, yaw might drift by a degree per few seconds to a minute.

After calibration, the gyro drift rate will change with temperature and other factors, so some people implement a calibration update routine that runs in the background.

maybe someone already created a "vaccum robot cleaning" algorithm to try to "map" a space and go through all the available space.

The latest Roomba does that.

Discussion of various algorithms:

Thank you so much! Since you look a person that knows MPU6050, do you think that if I tilt the MPU6050 in 90 degree and use the ROLL/Y (instead of the YAW/Z), there will be no drift? Since I just need to measure one single angle, instead of using Z (yaw) I could use X or Y which has zero drift in the long run as they are measured in a filter that takes into consideration the gravity as a reference, right? The yaw does not use gravity, right?

Unfortunately the angle you want for steering is yaw, which is rotation about the vertical axis (regardless whether that axis is X, Y or Z or some combination). So gravity can't be used to define the yaw angle.

humm :frowning: Thank you for saying me that! I thought that maybe rotating the sensor and extracting other angle would help... so I will try to implement the code using just yaw at the weekend.

I don’t really see why a magnetometer would need to be calibrated.

Magnetometers usually don't work "out of the box" as a compass. The origin offsets cause the angle calculation to fail.

Explanation and calibration tutorial

jremington:
Magnetometers usually don’t work “out of the box” as a compass. The origin offsets cause the angle calculation to fail.

But are you really using it as a compass?
Knowing where North is doesn’t seem to me to be necessary in a simple floor cleaner.

Of course, some other horizontal reference could help steer a floor cleaner.

It could move parallel to walls or furniture, locate a charge station beacon, etc. North is convenient, easy and cheap.