Raspberry Turk: The amazing chess-playing robot with a Raspberry Pi hidden inside

By Russell Barnes. Posted

Raspberry Turk is a mechanical turk robot that physically plays a game of chess

Joey Meyer’s Raspberry Turk is an ingenious chess-playing robot that was inspired by the eighteenth-century ‘Mechanical Turk’. While the latter machine had a human player concealed inside to determine its moves, the Raspberry Turk uses a Raspberry Pi 3 as its brain.

The chess player ponders the next move. Suddenly, a mechanical arm whirs into action, moves over the board, lowers an electromagnet, and picks up a piece… Checkmate!

Raspberry Turk: mechanical chess-playing robot

“My co-worker introduced me to the eighteenth-century Turk years ago and I was always fascinated by it,” Joey tells us. “A couple years ago I read The Turk: The Life and Times of the Famous Eighteenth-Century Chess-Playing Machine by Tom Standage, and loved it. After spending time learning computer vision and machine learning last year, I began looking for a project that would allow me to use what I had learnt. I made the connection and decided it would be a fun and challenging project.”


Joey says the hardware was the hardest part of the project. “I am a software engineer, and building hardware is a very different process.” One difficulty encountered was in interfacing Dynamixel servos with the Acrobotics components that make up the robot arm. “This gave me the opportunity to use 3D printing to build components to solve this problem.”

Precision robotics with a Raspberry Pi

Raspberry Turk Chess Playing Robot

Another challenge was making the arm movements precise. “In a perfect system, the movement of the arm could be modelled by a simple math equation, but due to inaccuracies in measurements, and unexpected real-world effects, this simple math equation model broke down. It did well, but not well enough to consistently grab the piece every time.” Joey solved the issue by collecting a dataset of arm movements to see where the model was having problems. “The results worked well and the arm can move very accurately now.”

Building a Mechanical Turk with a Raspberry Pi

Raspberry Turk Chess Playing Robot

  1. Make a table: The Turk is built into a small 3×3 ft (91×91 cm) table. A box on one side houses all the electronics, while the robotic arm is mounted on top.
  2. View the board: To evaluate the positions of the pieces, a top-mounted Pi Camera Module captures a view of the board which is then perspective-transformed using OpenCV.
  3. Move the arm: The arm’s motion is controlled by the rotation of two servos attached to gears at the base of each link. Another servo controls the gripper mechanism.

The Raspberry Turk took Joey around five months to build and the process has been fully documented on his site. “I knew I wanted to open-source the robot and describe the build process on a website from the beginning. I started this so I could use material I had learnt in a real project, but documenting the build process gave me the opportunity to help others learn, too.”

Asked how difficult would it be for other makers to replicate, Joey replies: “If you’re comfortable with some electronics, programming, math, and some simple handiwork, this project would be a big challenge, but is definitely doable. The code I wrote for mine is freely available. The website explains how everything works in detail and I am happy to answer questions for anyone who wants to take on the challenge. Several people have already reached out, telling me that they are working on building their own!”

While the Turk hasn’t been showcased in public yet, Joey says the response of those who have seen it has been interesting. “Reactions are usually positive, but then they quickly change to shock when they realise the robot isn’t just playing them, it’s beating them – badly!

From The MagPi store


Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.