You, probably, saw a set of the projects based on Arduino which were controlled via any smartphone. Such projects were, as a rule, just such a picture: a machine with a Bluetooth module inserted into it, to which commands (or something like that) are sent from the joystick emulator on the phone. There were a lot of such gizmos, and such an idea came to my mind. But what if Arduino helps you to part with your smartphone for a while, but at the same time continue to play it? This is how the project of a chess robot was born, the “brains” and “eyes” of which are concentrated in the Android-smartphone. Read more - under the cut.
The whole composition is a wooden box on which a chessboard, a manipulator and an illuminated bracket, on which the telephone rests, are located. After the game, all the above listed is removed in this very box and can easily be transported anywhere, for example, in a backpack. ')
The principle of operation is as follows. Above the board, a phone with a special application is installed on a special bracket, which, using a computer vision system, records the current position of the pieces on the board. Based on the fact that the system keeps track of all the moves, there is no need to visually determine what kind of figure is in the cage, it is enough to know the fact of its presence and color. After a move made by a man is fixed, this information is transmitted to the chess engine , which decides which way to answer. Next, the calculation of the angles for the positions that the robot has to take to make a move. After that, this information is sent via Bluetooth to the paddle. The manipulator can only accept this information and make a move.
I hope that the reader of this article will find here something interesting for yourself. Perhaps someone will want to repeat this project, or do something similar. I want to say right away that there will not be a tutorial, because copying this work simply according to the instructions will not work step by step, since there are many subtleties that can be understood only when trying to implement. If you want to look at the drawings of the manipulator, or you have any other questions, write in a personal on GT or VK , I will answer for free and upon request.
Software part
All this composition is controlled by one small Android application. He has many tasks: Determining pieces on the board, calculating angles for a manipulator, working with a chess engine, also implemented a couple of voice messages of the robot like “I put you a check!” And “Thank you for the game!”. But with all this, the application interface fits into one screen.
The vision system is fairly simple. From the perspective of the phone there is no particular difference between, say, the king and the horse - visually both of these figures will look like black and white circles. Therefore, the system does not get acquainted with the position it has seen every time anew, but remembers the sequence of all the moves made. And it is very simple to determine the move made: if at some point in time the program sees that the figure has disappeared in one cell and appeared in another cell, then this will be considered a move. This is how it works. This kind of vision is implemented exclusively through the Android API, without using OpenCV or something similar. It’s not quite right, the reason here is a personal interest to realize everything from scratch.
Manipulator
It took a lot of creative searches to come up with such a construction of a manipulator that can adequately perform its work with a lot of cheap Chinese TowerPro sg-90 servo drives that I do not have high quality work. Therefore, both arms of the manipulator are made in the form of parallelograms, this allows the system of capturing figures to always remain in a vertical position. This, in turn, makes it unnecessary to add another servo drive, therefore, there will be less errors in the system, allowing it to be easy and more or less reliable. Since the gears are also made of wood, it is difficult to achieve the highest quality of their work, therefore, to compensate for backlash, the manipulator makes a movement in sideways before each move in order to approach each point from one side.
As for power, his robot gets it from two boards from the usual charge for the phone, which are safely located in the case. One charge feeds the controller itself along with the Bluetooth module, the other directly to the mechanics. In order to make the lighting, the LED light was disassembled. As it turned out, there are two boards inside it: the LEDs are on one, the power converter is on the other. One is mounted on the bracket, the other is placed in the body of the box. All the power is displayed on a small socket on the side of the box body:
Another picture, which shows the working area of ​​the manipulator for the red dot marked on it. For the zero axis, the angle range is 180 °.
I didn't manage to make such a robot right away, some prototypes worked very poorly, and some were suitable for another job. For example, a robot in a video below puts sugar in a mug and stir the seagull.
System of capturing figures
Special attention, in my opinion, deserves the design of the system of capture figures. The most obvious decision here was to make two cheeks moving towards you under servo control. Something like that:
As can be understood from the figure, for a set of not at all large figures with a base diameter of 18 mm, the cage of a chessboard is almost twice as large, and the size of the board is also unreasonably huge. After a few unsuccessful implementations of this option, I came across such an unusual thing, which is called “flexible collet grip”), and it looks like this:
That is, it is a flexible hollow rod with a small metal spring-loaded claw at the end, which closes if it is squeezed on the sides. And in the absence of pressure, the claw opens instantly. Having broken such a grip, on its basis I made my own system of gripping figures. The metal claw squeezes the ring, which is attached to the toothed rack, driven by a servo drive.
results
Work on the project continues, and the results are also gradually improving. At the moment, the robot can play a game that is not limited by the number of moves, both for black and for white. In this case, there will be no errors in the operation of the mechanics or the program part of the system. He plays, by the way, not very strongly, to the level of the third rank, it is easily recovered by replacing the chess engine. I demonstrated this robot at the Archimedes-2016 exhibition, where he played with different people practically without stopping for 6 hours in a row and withstood the test drive with dignity.
That's all, I hope you were interested in this project. Of course, it has its drawbacks, especially implementation, so there is still much to strive for, what to improve and what to develop. I will be glad to any advice, questions and suggestions in the comments.