scieee AI-readable full text Open interactive document viewer

Implementation of a control system for morobot and its application in playing tic-tac-toe

Martínez Cueto, Óscar

Abstract

Departamento de Ingeniería de Sistemas y Automática

Full text

UNIVERSIDAD DE VALLADOLID ESCUELA DE INGENIERIAS INDUSTRIALES Grado en Ingeniería en Electrónica Industrial y Automática IMPLEMENTATION OF A CONTROL SYSTEM FOR MOROBOT AND ITS APPLICATION IN PLAYING TIC-TAC-TOE Autor: Martínez Cueto, Óscar Responsable de Intercambio en la Uva: Fernando Martínez Rodrigo Universidad de destino: University of Applied Sciences Technikum Wien Valladolid, septiembre 2021. TFG REALIZADO EN PROGRAMA DE INTERCAMBIO TÍTULO: Implementation of a control system for morobot and its application in playing tic‐tac‐toe ALUMNO: Óscar Martínez Cueto FECHA: 25 de junio de 2021 CENTRO: Main Campus at Höchstädtplatz UNIVERSIDAD: University of Applied Sciences Technikum Wien TUTOR: Johannes Rauer Resumen Aprender a través del juego es muy beneficioso para un grato aprendizaje y una mayor motivación del estudiante. Si además se realiza empleando la robótica en el juego, se consigue introducir a una temprana edad el pensamiento de programación de una manera creativa y atractiva para el alumno. Por ello en este trabajo se emplea un miniaturizado, e impreso en 3D, robot industrial (morobot) para el cual se programa y se construye un entorno de forma que se pueda jugar al 3 en raya con él. De esta forma finalmente se consigue un sistema barato y fácilmente reproducible para poder enseñar programación o diseño 3D de forma amena. Puede ser utilizado por los estudiantes para desarrollar ciertas partes propias para el sistema y hacerle modificaciones de forma creative Palabras clave: Robots, aprendizaje mediante juego, Morobot, Arduino, 3 en raya. Abstract Learning through play is very beneficial for enjoyable learning and increased student motivation. If it is also done by using robotics in the game, it is possible to introduce programming thinking at an early age in a creative and attractive way for the student. For this reason, this work uses a miniaturised, 3D printed, industrial robot (morobot) for which an environment is programmed and built in such a way that it can be used to play tic-tac- toe. In this way, an inexpensive and easily reproducible system for teaching programming or 3D design in an entertaining way is finally achieved. It can be used by students to develop certain parts for the system of their own and make modifications creatively. Keywords: Robots, learning through play, Morobot, Arduino, Tic-tac-toe. BACHELOR PAPER Term paper submitted in partial fulfillment of the requirements for the degree of Bachelor of Science in Engineering at the University of Applied Sciences Technikum Wien - Degree Program Mechatronik/Robotik Implementation of a control system for morobot and its application in playing tic-tac- toe By: Óscar Martínez Cueto Student Number: 2000330002 Supervisor 1: Johannes Rauer Vienna, 25.06.2021 Declaration of Authenticity “As author and creator of this work to hand, I confirm with my signature knowledge of the relevant copyright regulations governed by higher education acts (see Urheberrechtsgesetz/ Austrian copyright law as amended as well as the Statute on Studies Act Provisions / Examination Regulations of the UAS Technikum Wien as amended). I hereby declare that I completed the present work independently and that any ideas, whether written by others or by myself, have been fully sourced and referenced. I am aware of any consequences I may face on the part of the degree program director if there should be evidence of missing autonomy and independence or evidence of any intent to fraudulently achieve a pass mark for this work (see Statute on Studies Act Provisions / Examination Regulations of the UAS Technikum Wien as amended). I further declare that up to this date I have not published the work to hand nor have I presented it to another examination board in the same or similar form. I affirm that the version submitted matches the version in the upload tool.” Vienna, 25.06.2021 Place, Date Signature Abstract Learning through play is very beneficial for enjoyable learning and increased student motivation. If it is also done by using robotics in the game, it is possible to introduce programming thinking at an early age in a creative and attractive way for the student. For this reason, this work uses a miniaturised, 3D printed, industrial robot (morobot) for which an environment is programmed and built in such a way that it can be used to play tic-tac-toe. In this way, an inexpensive and easily reproducible system for teaching programming or 3D design in an entertaining way is finally achieved. It can be used by students to develop certain parts for the system of their own and make modifications creatively. Keywords: Robots, learning through play, Morobot, Arduino, Tic-tac-toe. Resumen Aprender a través del juego es muy beneficioso para un grato aprendizaje y una mayor motivación del estudiante. Si además se realiza empleando la robótica en el juego, se consigue introducir a una temprana edad el pensamiento de programación de una manera creativa y atractiva para el alumno. Por ello en este trabajo se emplea un miniaturizado, e impreso en 3D, robot industrial (morobot) para el cual se programa y se construye un entorno de forma que se pueda jugar al 3 en raya con él. De esta forma finalmente se cosnigue un sistema barato y fácilmente reproducible para poder enseñar programación o diseño 3D de forma amena. Puede ser utilizado por los estudiantes para desarrollar ciertas partes propias para el sistema y hacerle modificaciones de forma creativa Palabras clave: Robots, aprendizaje mediante juego, Morobot, Arduino, 3 en raya. Acknowledgements I would like to kindly thank my supervisor Johannes Rauer for guiding me through the work jams and resolving certain doubts. Radu Curcean for his help as lab manager. And my family and my Erasmus friends for their support and encouragement along the process. Table of Contents 1 Introduction ........................................................................................................ 1 1.1 Goals of this work ............................................................................................... 1 1.2 State of the art.................................................................................................... 2 2 Development of the system ................................................................................ 4 2.1 Mechanical part .................................................................................................. 5 2.2 Electrical part ..................................................................................................... 8 2.3 Programming part .............................................................................................. 9 2.3.1 Pick up pieces ............................................................................................. 11 2.3.2 Leave pieces ............................................................................................... 12 3 Results and Discussion .................................................................................... 14 3.1 Physical assembly ............................................................................................ 14 3.2 System in action ............................................................................................... 15 3.3 Discussion ........................................................................................................ 18 4 Conclusions and future lines ............................................................................ 18 5 Bibliography ..................................................................................................... 19 6 List of figures .................................................................................................... 21 7 List of Tables .................................................................................................... 21 Appendix ..................................................................................................................... 22 7 To play tic-tac-toe some designs in CAD are made to laser cut them in 4mm methacrylate sheets and then assemble them: - A grid to play and its walls and floor for a more robust design (Fig. 5). - Other grids where the pieces are stored and their corresponding walls and floor (Fig. 6). - The pieces to play with, which will be cubes with X or O (Fig. 7). - A base for the morobot to stand on (Fig. 8). - And a large board on which to place all the elements. Figure 6. Parts for the tic-tac-toe grid. Figure 7. Parts for the grid to store pieces. Figure 8. Parts for the X and O pieces. Figure 9. Base for the morobot. 8 All these parts have been conveniently glued together in order to get the robot's workspace suitable for working and playing tic-tac-toe (see results in section 3). 2.2 Electrical part The connection of the morobot motors as mentioned above is as follows (see Fig. 10): motor one connects its inputs to 12v (red wire), to GND (black wire), to pins D18 and D19 of the Arduino Mega board (yellow and white wires, respectively). And its four outputs are connected to the corresponding inputs on the second engine. In the same way the outputs of the second motor are connected to the inputs of the third motor and the outputs of the third motor to the inputs of the fourth motor (gripper). The Arduino Mega board is also conected to ground (GND pin) and 12 volts (Vin pin) to have a proper power supply. Figure 10. Electrical circuit A. Moreover, it is also conected to the button array 4x4 as follows (see Fig. 11): pin O4 of the button array to pin D10 of Arduino mega board, pin O3 to pin D11, pin O2 to pin D12, pin O1 to pin D13, pin R1 to pin D6, pin R2 to pin D7, pin R3 to pin D8 and pin R4 to pin D9. 9 With these connections the Arduino board is now able to detect all the button presses and use them in the program properly. Figure 11. Electrical circuit B. For the complete electrical circuit see appendix. 2.3 Programming part To control the system, a program has been created in Arduino language (resembling C++). But it is presented in the form of flowcharts so that it can be exportable to other programming languages. First, the general functioning of the program is (see Fig. 12) starting in a menu, depending on which button is pressed, one of the following options is carried out: S1 to play a new game, S2 to see the rules and an explanation of how the game works on the screen (and then go back to the menu) and S3 to exit the program. 10 When the game starts (button S1 pressed) the morobot moves to pick up O pieces (each time one) and returns to the starting position where it waits for a button to be pressed depending on where the player chooses to place their piece. Figure 12. General flowchart. 11 Once the player presses the button the morobot moves to this position to release the piece, it checks if the player has won the game or if the game is a draw and if it is neither, moves directly to take an X piece (each time a different one). And in the same way as before, the morobot stays in the initial position waiting for the player to press the corresponding button for the position where they want to leave their piece. Now, it checks if the second player has won or there is a draw and if it is neither, return to the O pieces and stays in this loop until someone wins or there is a draw and when the game is over, it congratulates the winner on the screen, put the pieces back in place and it returns to the start menu. 2.3.1 Pick up pieces More specifically what the program does in "pick up O pieces" is (see Fig. 13): is to move from the home position (with the end effector forward where the tic-tac-toe board is located and at a comfortable height) to its right side where the O pieces are located and depending on which turn number it is, it is directed towards one piece or the other. Then the morobot closes the gripper and moves upwards and back to its home position. Figure 13. "Pick up O pieces" flowchart. 12 To take the X pieces, the procedure is similar except that you will only take 4 pieces because as the second player, you never get to use 5 pieces. And that morobot will turn to its left side instead of its right, where the X pieces are located. To do all these movements I use functions from the morobot.h library that has been developed. This allows you to easily perform movements with the different motors and obtain a desired position. To make possible these movements. to reach the piece in question and carefully remove it from its box, a series of small movements of each motor are made until the right position is reached. 2.3.2 Leave pieces Another function to be explained in more detail: leave pieces in the chosen place (Fig. 14). Figure 14. "Leave pieces" flowchart. 13 In the home position the morobot remains waiting for the player in question to press the appropriate button depending on where they want to place their piece. The position corresponding to each button can be seen graphically in Fig.15. The system remembers which places are already occupied and If the button pressed is one that corresponds to a place that is already occupied, it sends a warning message to the user to press another button because that position is occupied. The morobot carefully positions the end effector in the chosen position using the button, opens the gripper a little so that the piece falls down but without hitting other possible pieces on the sides and slowly returns to the home position. The procedure for programming the movements is the same as for picking up the pieces. It involves making a series of small movements with the different motors until it reaches the right position so that it reaches its position without colliding with other pieces and improving the precision of the final position. Figure 15. Positions on the board for each button. Finally, to return the pieces to their places, the procedure is very similar to putting the parts down and picking them up from their original place, but in reverse. Saving in different variables the positions that have been occupied in order to be able to return the pieces correctly. Careful movements to pick up the pieces from the board and lift them, then it moves to the home position and carry them to its right position and carefully put them back in place. 14 3 Results and Discussion This chapter deals with all the results obtained throughout the work and some discussion of them. 3.1 Physical assembly The parts in figures 3 and 4 were printed and assembled with the motor included, resulting in the shape shown in Fig. 16. The end gripper meets expectations and is the right size and shape to pick up the game pieces. Figure 16. Gripper mounted. Figure 17. Workspace placed. 15 Fig. 17 shows both the gripper assembled to the morobot and the complete system already in place. The pieces of Fig. 5-9 already glued and placed in their places. And the Arduino board, the button array and all its electrical circuit can also be seen already in place. The system is properly positioned so that the system runs smoothly, and the morobot-p can pick up the pieces and move them without bumping into each other. 3.2 System in action With the whole system set up and the program developed, we proceed to test and observe the results obtained. Figure 18. System in action. 16 It can be seen in Figure 18 the morobot playing in various positions and the pieces being moved in different games. As it can be seen the system is working correctly and can continue to pick up and drop off pieces. In the meantime, players are shown on the screen the action to be taken so that the game can be played properly. In the following images we can see different situations that occur in the games and how they are displayed on the screen. For example, Fig. 19 shows how when a position already occupied is selected, a warning message is displayed on the screen. Figure 19. Screenshot of position occupied. And then it would be asked again to choose where it wants to place the piece. Figure 20. Player 1 winning. Another case is shown in Fig. 20, player 1 doing 3-in-a-row. On the left you can see how the board looks and the robot starting to move to pick up the pieces again. On the 23