Abstract a Line Following Robot Is Designed and the Performance Is Evaluated When Using Three Types of Control Algorithms
Total Page:16
File Type:pdf, Size:1020Kb
LegoRacer project, Embedded Control Systems VT10 Jim Björk, Tomas Nilsson, Pontus Björk, Viktor Melker Author Affiliation(s): Uppsala Universitet E-mail: (Project Leader) [email protected] Abstract A line following robot is designed and the performance is evaluated when using three types of control algorithms. One can see that more time invested in design and control gives a better performance, but only to a limit. The PID controller outruns the simplest implementation however when implementing a more advanced LQG controller the performance actually deteriorates in our case. Conclusions and suggestions for future work is included in the last section with a concept for designing future versions of the line following robot. Index Abstract.................................................................................................................................................1 Project description................................................................................................................................3 LEGO® MINDSTORMS® NXT...............................................................................................3 Linesensor array..........................................................................................................................3 Development tools...........................................................................................................................3 RobotC........................................................................................................................................4 Lejos............................................................................................................................................4 Matlab.........................................................................................................................................4 Comparison between RobotC and Lejos/Java............................................................................4 Work procedure....................................................................................................................................4 Software development using the Agile Methodology......................................................................4 Experiments..........................................................................................................................................5 The chosen controllers.....................................................................................................................5 The simple (pseudo P) controller.........................................................................................................6 The PID controller................................................................................................................................7 The Model............................................................................................................................................8 Simulations...........................................................................................................................................9 LQG controller...................................................................................................................................10 Performance...................................................................................................................................12 Performance of the simple controller........................................................................................12 Performance of the PID controller............................................................................................12 Performance of the LQG controller..........................................................................................13 Dependence on sampling time..................................................................................................13 Optimization..............................................................................................................................13 Conclusions...............................................................................................................................14 Discussion...........................................................................................................................................14 (Unexpected) problems..................................................................................................................14 Suggestions for future work...........................................................................................................15 Project description The goal in the LegoRacer project is to construct a robot and three different kinds of controllers following a pre-defined path for benchmarking of path tracking algorithms. The goal is to make the robot to follow the path at highest possible speed. Once the controllers are designed their performance will be tested and compared to see what gains can be obtained using more advanced control algorithms. LEGO® MINDSTORMS® NXT The Lego Mindstorms NXT kit is a programmable robotics kit released by Lego in 2006. It is a replacement for the older Lego Mindstorms kit, called the Robotics Invention System. We were given an Education Base Set. This set comes with the NXT-G programming software but there exists a variety of other programming languages exist such as LeJOS NXJ, RobotC, NXC.1 In the kit there are: • 431 LEGO Technic parts including: • NXT Intelligent Brick • Rechargeable lithium battery • 3 servo motors • 1 ultrasonic distance and movement sensorvalue • 1 soundsensor • 1 lightsensor • 2 touch sensors • 3 converter cables(for using older parts) • 7 connector cables • 3 lamps Some other third party sensors are also availible e.g. A Gyroscopic sensor, Linesensor array, Accelerometers...2 Linesensor array The linesensor array1 is “an array of 8 sensors with a controlled light source, to detect a line “. Each of the eight lightsensors has a light source which illuminates the surface. Each sensor detects the reflected light from the surface and sets a value accordingly. The linesensor array also has a built in function, getAverage, to calculate where the line is. It works by calculating a weighted average3 and can obtain the most likely position of the line from this value. Development tools During the project a number of different development tools were used. 1 http://en.wikipedia.org/wiki/Lego_Mindstorms 2 http://www.mindsensors.com/ 3 http://www.mindsensors.com/index.php? module=documents&JAS_Document_op=downloadFile&JAS_File_id=743 RobotC “ROBOTC is a powerful C-based programming language with a Windows environment for writing and debugging programs, and the only programming language at this level that offers a comprehensive, real-time debugger. “4 RobotC was used since it offers a debugger and also because it is faster than a similar program in Java/Lejos. RobotC was used for the first 2 controllers in the project. After that it was decided to switch over to Java/Lejos since development was easier in the Java/Lejos environment and we progressed faster. We also realized that we didn't need the performance increase that RobotC could provide. leJOS “leJOS NXJ is a Java programming environment for the LEGO MINDSTORMS NXT ®. It allows you to program LEGO ® robots in Java”5. Lejos was used for development in the later parts of the project. The decision to switch to Java/Lejos was made because it has more built in support for various functions, proved to be easier to develop controllers with and had better documentations. The programming was done in the IDE Eclipse6. Matlab “MATLAB® is a high-level technical computing language and interactive environment for algorithm development, data visualization, data analysis, and numeric computation”7. Matlab contains different toolboxes that can be used for more specialized tasks. The control system toolbox contains many tools that are useful for designing controllers such as the ones in our project. Various analysis and simulations were done in matlab to ease the development process. Comparison between RobotC and Lejos/Java After switching over from RobotC to Lejos a performance test was conducted to find out their relative performances. The test was carried out by letting the PID controller run in both environments and measuring the time needed for each iteration of calculations. RobotC had an average processing time for each iteration of 6 ms while Lejos/Java had an average processing time of 10 ms. This is probably because Java is executed in a virtual machine on the NXT brick while RobotC is compiled into machine code and run directly on the NXT brick. Work procedure Agile system development is a name for a collection of different system development methods that can be used for software development, also called Agile methods. The methods themselves follow the same values, principles and approach. Compared to earlier waterfall models the agile methods represent more flexible ways to work. The philosophy behind agile is to make the customer/end user content with what is being developed by a close cooperation during the whole process with close and regular meetings between the 4 http://www.robotc.net/download/ 5 http://lejos.sourceforge.net/nxt/nxj/tutorial/Preliminaries/Intro.htm 6 http://www.eclipse.org/ 7 http://www.mathworks.com/products/matlab/description1.html developer and the customer/end user. The work itself is conducted incrementally and iterative which means that regular smaller deliveries