|
|
|
|
|
by amatic
890 days ago
|
|
A tuned PID loop should follow a moving target with no issues and no advanced control theory. Here is a similar example from a Lego robot with a pixi camera [1]. The pixi camera recognizes the ball location in 2D, sends to arduino. There are two independent loops, one keeping the ball in the center of the horizontal visual field, by rotating the camera left-right, and the other is keeping the ball in the center vertically, by tilting the camera via two levers.
One thing you might notice is that the ball sometimes goes too fast for the robot to follow - this is due to the limitations of the power of the motors, and the rate of sampling in the loop. Games usually don't have the limitation of the power, but I suppose the rate of sampling and updating the loop could be limited by the game loop. In that case, it might be useful to update the PID multiple times per loop. Other than that, there are some tricks to make the loops more stable. Limiting the error can be useful. Limiting the action of the actuator. Smoothing the action of the actuator is very useful. I tend to think of PD loops as damped springs. The P term is like the spring constant, and the D term is like friction or viscosity. The first one determines the speed of reaching the goal, and the second one reduces the oscillations when reaching the goal. I rarely use the I term. [1]https://www.youtube.com/watch?v=7_IZb0RJN_U |
|