Any way to predict when to stop a moving ball in order to get it to x?

  • Thread starter crewxp
  • Start date
  • Tags
    Ball
In summary, In order to have the Sphero stop at a specific location, you need to know velocity, acceleration, and x position. If velocity drops too fast, the Sphero will undershoot the target. To reduce the amount of error the Sphero makes, you can add a small threshold for position.
  • #1
crewxp
2
0
I am working on a project for my kid. I have a question.

Question: Is there a way to predict when to stop a moving ball in order for it to finally stop rolling at a specific position?

Data: I know the balls x and y position, and the velocityX and velocityY float values. I think it has an accelerometer as well, but I haven't experimented with it. It has a x,y, and z value.

Situation: I am programming a Sphero (wireless moving ball), and I know my starting location (0,0), and ending location eg:(0,300cm). Once it stops at the ending location, it needs to travel back to 150cm, (the middle between the two locations). But every time I find out the position is 150cm and send stop, it rolls past where I want it to go while its stopping. (Stopping Distance)

I can't hard program it to stop a random SET distance (through trial and error) before the middle because its velocity won't always be the same. Sometimes it rolls on rough carpets and sometimes on smooth tile floors.
 
Last edited:
Physics news on Phys.org
  • #2
Sure. First, you can ignore the fact that it's rolling. Rolling inertia will just work as if the ball has extra mass. So you have a known x, y, Vx, and Vy, and you are trying to get the ball to come to a stop at specific position, but you don't know exactly what the acceleration is going to be. Let's talk just about x for the moment, because it's easy to generalize, and I'll just assume you want it to stop at x = 0. Naturally, you can shift the position to wherever.

The simplest way to do this is to make an assumption about worst case acceleration. This is gives you the longest distance it's going to stop on the surface. Let's say you found (or even just guessed) the acceleration to be a. Guessing a value too high can result in errors, so start low and see if you can increase it later.

Now you have the ball approaching zero from some distance x at velocity v. If you were to start stopping at acceleration a, you can stop in distance v²/(2a). So that's going to be your test. If x < v²/(2a), you should be trying to stop. But you keep making this test. If velocity drops too fast, and new x > v²/(2a), keep the ball rolling towards the target position.

Even if all you can do is alternate between "stopped" and "maximum speed", because the ball has inertia, you will get smooth movement with the ball decelerating at the set rate a before reaching the target. The fact that the ball can decelerate at the rate of at least a on any surface means you won't have problems with the ball rolling past the target, and because you alternate between moving and stopped modes, the net acceleration will not exceed a even on surfaces where the ball can stop faster.

There are a number of ways to go fancier, but I'm guessing you are looking for something pretty basic.
 
  • #3
thanks a lot for this! Still confused lol. I thought I would have to somehow use the sphero's internal location to learn when to stop. But you said I don't need this? Only the velocity, acceleration, and x position to stop at?

I sent you a pm! (Confused!)

Here is what I was thinking:
if ((player2positioninY/2)<velocity^2/2a)
{
send stop to sphero
}

But I'm confused on the part where you say if velocity drops too fast.

On my sphero, I can get: VelocityX, VelocityY, PositionX, PositionY, Accel XYZ, Gyro XYZ)
 
  • #4
The problem is that a is just an estimate. If actual acceleration is going to be greater than a, stopping the servo too early will result in the Sphero undershooting the target.

Ok, so let's say we have TargetY being location where we want to stop. In that case, you want to have two independent checks.

if(|TargetY - PositionY| < VelocityY^2 / (2*a))
{
send "servo-off"
}
if(|TargetY-PositionY| > VelocityY^2 / (2*a))
{
send "servo-on"
}

Here, I'm assuming that "servo-on" will have the Sphero rolling towards TargetY. I'm sure you can figure that bit out and generalize this whole thing to movement in 2D.

One more note, the above code will be switching servo on and off rather rapidly as it approaches target. If this causes any trouble, you can add a small threshold. Like, replace second if() with if(|TargetY-PositionY|-err > VelocityY^2 / (2*a)). Here, err is a small error you allow in the position. This will allow for a bit longer times between servo switching on and off. In ideal world this would reduce precision, but in real world a small allowance for error might actually improve it.
 
  • #5


I understand your frustration and desire to find a way to accurately predict when to stop a moving ball in order to get it to a specific position. While there is no one definitive answer to this question, there are a few factors that may help you in your project.

Firstly, it is important to understand that predicting the exact stopping point of a moving ball is not an exact science. There are many variables that can affect the ball's movement, such as friction, surface type, and air resistance. These variables can make it difficult to accurately predict when the ball will come to a stop.

That being said, there are a few techniques you can try to improve your predictions. One approach could be to use a mathematical model, such as Newton's laws of motion, to calculate the trajectory and velocity of the ball. This can help you estimate the stopping point based on the initial position and velocity of the ball, as well as the forces acting upon it.

Another approach could be to use sensors, such as the accelerometer mentioned in your question, to track the ball's movement in real-time. By analyzing the data from these sensors, you may be able to make adjustments to the ball's velocity and direction in order to more accurately reach your desired stopping point.

It is also important to consider the limitations of your equipment and the environment in which you are working. For example, the accuracy of your sensors and the smoothness of the surface can greatly impact your results. It may be helpful to conduct experiments in different conditions to gather more data and refine your predictions.

In conclusion, while there is no guaranteed way to predict the exact stopping point of a moving ball, there are techniques and tools that can help improve your accuracy. By combining mathematical models, sensor data, and experimentation, you may be able to achieve a more precise stopping point for your Sphero. Good luck with your project!
 

FAQ: Any way to predict when to stop a moving ball in order to get it to x?

Can we accurately predict when a moving ball will reach a certain point?

Yes, it is possible to predict when a moving ball will reach a certain point by using mathematical equations and principles such as Newton's laws of motion.

What factors affect the prediction of when to stop a moving ball?

The factors that affect the prediction of when to stop a moving ball include the initial velocity of the ball, the angle at which it is thrown, the force of gravity, air resistance, and the surface the ball is moving on.

Is it possible to predict when to stop a moving ball without knowing all the initial conditions?

No, it is not possible to accurately predict when to stop a moving ball without knowing all the initial conditions. Any small changes in the initial conditions can greatly affect the outcome of the prediction.

Can we predict the exact point where a moving ball will stop?

It is very difficult to predict the exact point where a moving ball will stop due to factors such as external forces and the unpredictable nature of the ball's bounce. However, we can make a close approximation using mathematical models.

How can we improve the accuracy of predicting when to stop a moving ball?

The accuracy of predicting when to stop a moving ball can be improved by using more precise measurements, reducing external factors such as air resistance, and using advanced mathematical models and algorithms to account for all the variables involved.

Back
Top