Application Programming for Embedded Systems in Education on Turtlebot3 Using Statecharts
Total Page:16
File Type:pdf, Size:1020Kb
Application Programming for Embedded Systems in Education on TurtleBot3 using Statecharts Mirka Schoute Layout: typeset by the author using LATEX. Cover illustration: Photo by Mirka Schoute Application Programming for Embedded Systems in Education on TurtleBot3 using Statecharts Mirka Schoute 11868643 Bachelor thesis Credits: 18 EC Bachelor Kunstmatige Intelligentie University of Amsterdam Faculty of Science Science Park 904 1098 XH Amsterdam Supervisors Prof. dr. K.B. Akesson and ing E.H. Steffens Informatics Institute Faculty of Science University of Amsterdam Science Park 904 1098 XH Amsterdam June 26th, 2020 ABSTRACT This thesis examines the possibility of using the TurtleBot3 Burger and YAKINDU Statechart tools to teach application programming for embedded systems. This is done by comparing these new tools to the Lego Mindstorm EV3 and Mathworks Stateflow, which were previously used to teach in this context. Development to test the new tools is described. In the development, a ROS 2 interface that can be connected to the inter- face of the generated code from YAKINDU is described. Over development the level of abstraction that is suitable for using the TurtleBot in education in this context is de- termined. This together will clarify the possibility of use of the Burger and YAKINDU Statechart tools for education in application programming for embedded systems. 1 Contents 1 Introduction 4 2 Background 6 2.1 The previous assignment: Traal-Rover . .6 2.2 The new tools . .8 2.3 Statecharts . 12 3 Prior Work 16 3.1 TurtleBot3 in research . 16 3.2 TurtleBot3 in education . 17 4 Method and Approach 18 5 Development 20 5.1 The new Traal-rover assignment . 20 5.2 The use of Gazebo during development . 22 5.3 The ROS 2 interface and connecting to SCT . 23 5.4 The statechart solution to the assignment . 24 6 Results 26 6.1 Capabilities of the new statechart tools . 26 6.2 The final performance . 29 7 Conclusion and Discussion 33 7.1 Q1..................................... 33 7.2 Q2..................................... 33 7.3 Q3..................................... 34 7.4 Additional Information . 34 7.5 The Main Question . 35 8 Future work 36 2 A Zoom in on the final Statecharts 39 Chapter 1 Introduction In recent years, robotics has gained considerable attention for numerous applications. As such, there is also an increased interest in education for robotics [7]. Currently, there are several robotic platforms that can be used in education. This research focuses on two of these robots, the Lego Mindstorm EV3 and mainly the TurtleBot3. The EV3 is a platform designed for hands on education1. It is a commercial robot and comes with visual programming software. Additionally, it can also be programmed with programming languages. A main feature of the robot is that it is modular. The EV3 can be edited to any configuration necessary for the type of education. The main target audience of the EV3 would be children in primary or secondary school. On the contrary, the TurtleBot32 is an open source robot that can be programmed using the Robot Operating System (ROS)[9]. It has a focus group of high-school and up. Lastly, the TurtleBot3 is also modular and can thus also be edeited to different configurations. [7] A course at the University of Amsterdam (UvA), Embedded software and systems3 (ESS), currently uses the Lego Mindstorm EV3 for one of the assignments in the course. However, students ran into inaccurate sensors on the EV3. Therefore, students needed to spend time refining parameters, which was not part of the intended learning outcomes of the course. The goal of the assignment was to work together in a team to develop soft- ware that satisfies its requirements on a given embedded platform. Thus, a replacement was necessary, such that the students could focus on the core contents of the course. TurtleBot3 may be the solution here. The development of this assignment was done using statecharts[3]. Statecharts are a visual formalism that can be used to represent how a complex system works. (In Chap- ter 2.3 the technical details will be explained.) In the case of the assignment in the ESS 1https://education.lego.com/en-us/products/lego-mindstorms-education-ev3-core-set/5003400 2http://www.robotis.us/turtlebot-3/ 3https://studiegids.uva.nl/xmlpages/page/2019-2020-en/search-course/course/73512 4 course, Mathworks Stateflow4 was used. However, ROS is not usually programmed using Matlab, the programming language Mathworks is based on. There is a package for Matlab that enables ROS support. But, students had some problems with the Math- works software. Thus, YAKINDU Statechart Tools (SCT)5 is used instead to enable the TurtleBot3 to be used as a replacement. SCT does not have ROS support in the base product. However contrary to Stateflow, there is a code generator for Python. This generated code can be used to interact with ROS. Additionally, SCT’s code generator can be customised or a new one can be developed by the user, if necessary. ROS does have a package called SMACH that can be used to develop hierarchical state machines. However, this does not support the statecharts formalism. The TurtleBot3 needs to be tested if it can be used for education in this manner. Therefore, the primary research question of this thesis will be : Can TurtleBot3 be used to teach application programming for embedded systems using Statecharts? To be able to answer this, three sub questions are used: Q1: Can the new tools, TurtleBot3 and SCT, serve the same educational purpose as the previous tools for the assignment in the ESS course? Q2: Can problems with the previous assignment be solved by using the new tools? Q3: What is a suitable level of abstraction for education using the TurtleBot3? The first sub question, Q1, is the baseline of what needs to be achieved for the Turtle- Bot3 to be used in this context. This will automatically fail if it turns out a statechart tool cannot be connected to the TurtleBot3. Ideally Q2 is also true as the TurtleBot3 is not just meant as a replacement, but also as an improvement. Q3 is catered towards the technical details. To teach application programming for embedded systems, a suitable level of abstraction needs to be used to enable students to focus on the materials of the course. Students should not have to spend much time with things that are not part of the course. This thesis starts with a background to the assignment in the ESS course and all the tools mentioned up until now. Then, in Chapter 2.3 there is a basic explanation of the formalism of statecharts. Next, the applications of the TurtleBot3 in research is discussed in Chapter 3 followed by the robot’s use in education. Afterwards, in Chapter 4, a method is proposed to give answer to all the questions previously stated. Then, the development of all necessary tools to prove the questions is discussed in Chapter 5. next, the results is discussed in Chapter 6, followed by the conclusion to the questions in Chapter 7. Lastly, in Chapter 8, some future work is proposed. 4https://nl.mathworks.com/products/stateflow.html 5https://www.itemis.com/en/yakindu/state-machine/ Chapter 2 Background In this chapter, the previous assignment is outlined as well as the tools used for it. Then, the new tools are established. Lastly, an introduction will be given to the formalism of statecharts. 2.1 The previous assignment: Traal-Rover As the previous assignment is used as the base criteria, it is important to know what tools were used and what the assignment consisted of. The tools for this assignment were the Lego EV3 Mindstorm and Mathworks Stateflow. Firstly, the configuration of the EV3, that can be seen in figure 2.1a, was as follows. in terms of sensors, it had 2 touch sensors facing up for manual control, a color sensor facing downwards, and an ultrasonic sensor facing forward. For movement, it had a motor for the left and the right wheel, and a motor to raise a flag. These motors also have sensors to measure their rotation. Secondly, Mathworks Stateflow was used as the visual interface to develop statecharts in. It would directly control the EV3 using Simulink. Further details of the tools will not be used for comparison and are thus not important. The previous assignment is used as a base for a new assignment that the TurtleBot3 is supposed to complete. The previous assignment was called Traal-Rover, in which students had to make an embedded application using statecharts for the EV3 to explore the planet Traal by following a path and logging what it encounters. Furthermore stu- dents had to work in groups, as the goal of the assignment was to work together in a team to develop software that satisfies its requirements on a given embedded platform. Additionally, it was used to teach statecharts and how to work with them in a practical manner. These were the main educational purposes and the TurtleBot3 burger should at least serve this purpose to be used in the course. 6 (a) The EV3 Configuration (b) The physical model Figure 2.1: Picture of the test setup for the Traal-Rover assignment for Embedded software and systems 2019/2020 academic year The Traal-Rover assignment consisted of 6 steps, which needed to be completed by five components. The course that needs to be completed can be seen in figure 2.1b. The first component is manual control. This component makes use of buttons and timing to control the robot’s movement. It is meant to complete Step 1, which is driving manually to an indicated area.