Calculating time for Roomba to complete a circle

744 Views Asked by At

I am not very good at mathematics and as such I hope I've come to the right place to ask this question.

Currently, I am programming an iRobot Roomba to make a circle. All is well, except that I need it to stop after a complete circle. The Roomba itself cannot know this, so I am taking a time-based approach.

However, this approach is not working.

What I am doing at the moment is this: Let's say I am letting the Roomba make a circle with a radius of 100mm, and set its speed to 100mm/s. The radius is the distance from the centre of the circle to the centre of the Roomba; the Roomba follows the circumference of the circle.

I had calculated that the time for it to complete one circle was (2*pi*100mm) / 100mm/s, which equates to roughly 628/100 = ~6.3s. However, I find that it easily takes the Roomba 10 seconds to follow the circumference, so this current approach leads to the Roomba stopping before even making a full circle.

Have I made a very stupid mistake in assuming I could just divide the circumference with the speed? I have no clue where to look. I looked all over the internet for a day now, but I haven't been able to find a clue.

I thank you for your time and any pointers in the right direction.

Edit: Two things I should indeed point out. The speed given is defined as the average speed of the two wheels on the Roomba. The speed works out to be correct in straight lines. When I increase the radius, between r = 200mm and r = 300mm there comes a point to where the Roomba makes the circle faster than calculated.

EDIT 2: For those interested, I was able to get it to work thanks to JohnJPershing's hints and Ross Millikan's Mathematical aid. I calculated Vl and Vr with help of his explanation and put them in the Roomba using the Drive Direct (145) opcode. Then, the calculated time (6.3 seconds) came to be true!

3

There are 3 best solutions below

5
On BEST ANSWER

The reason why your calculations aren't working is that the speed of the Roomba lowers when it turns. Not sure how to math it, but when i did Roomba programming, i found a way to tell how much the wheels turn so i could measure how far each had gone, and whether it made a full circle. I know that this is not an answer, but its my experience with this.

0
On

When it makes a circle the outter wheel has to be faster than the inner one. But how fast? Depends of the distance between the wheels, which I will say that is 2x, hence, the distance from the center of the Roomba and a given wheel is x.

Now lets take as a reference the circumference discribed by the moviment of Roomba based on its center, with radius r. The circumference described by the inner wheel is inside the former one, has radius r-x and the length is (r-x)*2*pi, and the outter wheel draws the biggest circumference path with radius of r+x and length of (r+x)*2*pi.

Now I will assume (for security purposes) that 100mm/s is the fastest a wheel can go, therefore 100mm/s is the speed of the outter wheel, and the inner one has to go slower.

Looking at the equation of velocity:

distance = velocity times time

Substitute distance with (r+x)*2*pi, and velocity with 100mm/s, you have that:

Time to complete a circle = (r+x)*2*pi / 100 seconds

There is the answer to your question, which may not be totaly correct because my assumptions might be wrong (maybe the outter wheel won't go at 100mm/s, maybe is faster, I can't know).

If you can control the speed of the wheels separately, we may measure the speed of the inner wheel with the same formula:

distance((r-x)*2*pi)) = velocity (?) times times((r+x)*2*pi / 100mm/s)

velocity of the inner wheel = 100(r-x)/(x+r) mm/s

2
On

If the centerline radius is $r$ and the distance from the center of the Roomba to each wheel is $d$, one wheel will have a radius of $r+d$ and one will have a radius of $r-d$. They will have to travel $2\pi(r+d)$ and $2\pi(r-d)$ to do that. Let's say the left wheel is outside and travels at $v_l$, while the right one travels at $v_r$ If we make a good circle, the time is $\frac {2\pi(r+d)}{v_l}=\frac {2\pi(r-d)}{v_r}$, which shows $v_l=\frac {r+d}{r-d}v_r$. You can't average the speeds and get the speed over the centerline. If you want to compute $v$, the speed of the centerline, you have $v=\frac r{r-d}v_r=\frac r{r+d}v_l$