Lego Chess Robot
Total Page:16
File Type:pdf, Size:1020Kb
Department of Computing Science and Department of Electronic and Electrical Engineering University of Glasgow Team E Project Report Level 3, 2004/2005 Lego Chess Robot by Stewart Gracie, Jonathan Matthey, David Rankin, Konstantinos Topoglidis We hereby give our permission for this project to be shown to other University of Glasgow students and to be freely distributed in an electronic format. Please note that you are under no obligation to sign this declaration, but do- ing so would help future students. Stewart Gracie Jonathan Matthey David Rankin Konstantinos Topoglidis i Abstract As Team E, we aim to build a fully interactive robot that will play chess on a physical board against a human player. This robot's movements will be dictated by a chess engine written in C running under a Windows environment on a desktop computer. The computer and robot will interact via infra red transmissions. The human's moves are detected by a specially built chess board that is connected to the PC via USB using Phidgets technology. The Robot's movement is controlled by motors and sensors which are operated through RCXs which are programmed in NQC. The setup o®ers a strong game supporting all legal chess moves such as castling, en passant and promoting pieces. Once complete a human player is able to play against a computer chess program without the distractions of the computer. The game is played on an actual chess board and, after setup, the computer can be ignored altogether. An LCD display, LED lights and sound e®ects keep the user continually informed. The system will allow individuals to test their chess abilities on a real board without having to move for the computer. ii Contents 1 Introduction 1 1.1 Motivations . 1 1.2 Background . 1 1.3 Preliminaries . 1 1.4 Aims . 2 1.5 Module Description . 2 1.5.1 Lego Robot Design . 2 1.5.2 Board Design and Construction . 3 1.5.3 Board Software . 3 1.5.4 Chess Engine Interface Development . 3 1.5.5 RCX Movement Programming . 3 1.6 Document Outline . 4 2 Project Speci¯cation 5 2.1 Team E - Requirements Speci¯cation . 5 2.2 Essential Goals . 5 2.3 Quanti¯able Factors . 6 2.4 Additional Goals . 6 2.5 Risk Factors . 7 2.6 Timeline . 7 3 Lego Robot Design 8 3.1 Design Rationale . 8 3.2 Design Options . 8 3.2.1 Magnetic Robot . 8 3.2.2 Robotic Arm . 8 3.2.3 Girder Robot . 9 3.2.4 Comparison Criteria . 10 3.2.5 Final Decision . 11 3.3 Design Considerations . 11 3.4 Grabber Prototypes . 12 3.4.1 Tripod Grabber Model . 12 iii 3.4.2 Final Grabber Model . 13 3.4.3 Lifting Mechanisms for Grabber . 14 3.4.3.1 Two Track Model . 15 3.4.3.2 Final Lifting Model . 15 3.4.4 Motor Matching . 17 3.4.5 Platform for Grabber . 18 3.4.6 Movement of Grabber . 18 3.4.6.1 Horizontal Movement . 18 3.4.7 Structure . 19 3.4.7.1 Stationary Model . 19 3.4.7.2 Vertical Movement with Tracks . 20 3.5 Stopping the Structure . 21 3.6 Final Design . 21 3.7 Future Improvements . 22 4 Board Design and Construction 23 4.1 Introduction . 23 4.2 Board Requirements . 23 4.3 Lego Vs Phidgets . 23 4.4 Detection Methods . 24 4.4.1 Visual Detection . 24 4.4.2 Light Sensors . 24 4.4.3 Magnets . 25 4.4.4 Switches . 25 4.5 Analogue Vs Digital . 26 4.5.1 Digital . 26 4.5.2 Analogue . 26 4.6 Investigating the Phidgets Analogue Inputs . 27 4.7 Switch \Sensor" Prototyping . 28 4.8 Bouncing . 28 4.9 3x3 Prototype . 28 4.10 Interference . 29 4.10.1 The Cause . 30 4.10.2 The Solution . 30 4.10.3 Problems in the Future . 31 4.11 LEDs . 31 4.11.1 Row and Column LEDs . 32 4.11.2 The Decoder . 32 4.11.3 Prototype Circuit . 33 4.11.4 Power Supply Changes . 33 4.12 Circuit Layout and Construction . 34 4.13 Board Construction . 34 iv 4.14 Testing Outcomes . 36 5 The Board's Software 37 5.1 Introduction . 37 5.2 Requirements . 37 5.3 The Phidgets Software Components . 37 5.3.1 The PhidgetInterfaceKit class . 38 5.3.2 The IphidgetInterfaceKitEventsAdapter class . 38 5.4 Early Programs . 38 5.5 Simple GUI . 39 5.6 LED Control . 39 5.6.1 LedOutput2 . 40 5.6.2 LedOutput3 . 40 5.7 Software Debouncing . 40 5.8 GuardedLCD . 41 5.9 MoveGen . 41 5.9.1 Normal Moves . 41 5.9.2 Special Moves . 42 5.9.3 Cancel . 42 5.10 Extra Output from MoveGen . 42 5.10.1 ThinkingOutput . 42 5.10.2 LEDhighlightMove . 43 5.11 User Buttons . 43 5.11.1 The Yes/Begin Button . 44 5.11.2 The No/Cancel Button . 44 5.12 RobotMove . 45 5.13 Extras . ..