fischertechnik TXT 4.0 version of ball on a plate with details about hardware design and programming details.
Camera from the top over the board gives x/y coordinates of the ball from -21 to 21 in each axis.
3 fischertechnik servos define the board hight and angle.
The board only tilts around a calculated zero hight of the center of the board, but it can also bump to make the ball bounce.
Besides the calculation of the servo positions, the algorithm uses only P and D of a simple PID algorithm.
The P calculates a predicted position to compensate for the time lag of a the camera. Px = px + dx
Px is the predicted as-is position of the ball which takes the last ball movement into account:
dx = Px - old_Px
old_Px is the Px of the previous thread execution.
To give the TXT4.0 connected camera enough time to provide the next picture in 30 fps mode, we pause 9ms between each positioning calculation.
Enjoy and try yourself!
9 сен 2024