Full text
Final Master Thesis Master’s Degree in Automatic Control and Robotics Mobile manipulation with the TIAGo robot: perception and task manager Memory June 24, 2019 Author: Miller Stiven Espinosa Muñoz Advisor: Prof. Dr. Jan Rosell Gratacòs Date: 06/2019 Escola Tècnica Superior d’Enginyeria Industrial de Barcelona
Mobile manipulation with the TIAGo robot: perception and interaction page 1 Abstract This project aims to design and implement a solution for a complex mobile manipulation task using PAL Robotics’ robot TIAGo. The goal is to use the platform as an assistive robot, making it capable of picking a chosen object from a certain location and moving it to another. More precisely the task in which the project will focus will be to pick a certain soda can from a table with several of them on it and pour its contents into a glass placed on another table for the user to have his/her drink . For that, all the perception, interaction, planning and mobile capabilities of the robotic platform will be exploited in order to develop a suitable and complete solution. The generated solution is a modular method that can be launched as a whole process to complete the entire challenge, but this solution also gives the possibility of using each one of the modules independently. This way it is feasible to easily integrate them to other processes in order to complete other similar tasks, making the packages more versatile and adaptable. The entire project has been divided in two parts. One focused on developing the packages in charge of navigation and arm manipulation, carried out by Xavier Garcia Peroy. The other one, focused on developing perception and task management part, and described in this report. For the perception part, some computer vision capabilities have been implemented using TIAGo’s camera. These capabilities were added in order to get knowledge about the objects with which the robot needs to interact. In this case, these objects were cans of soda which the robot needed to detect and, using some image processing steps, determine their position in order to pick the can of soda chosen by the user. On the other hand, for task management part, a solution based on behavior trees was developed. This solution has been done in a modular way, removing a big part of the complexity of executing each necessary task to achieve the goal of this project, and also decreasing the necessity of going deep in programming in order to make changes and check partial functionalities. That has been achieved with the use of the BehaviorTree library and Groot, a visual tool that has allowed to create the task manager functionalities graphically. Both solutions have been checked to work properly in order to achieve the established goal. However, specially in perception part, some functionalities should still be improved in order to increase the robustness of the method and decrease some limitations. Future work is suggested in order to make these enhancements.
page 2 Report
Contents 1 Introduction 7 1.1 Motivation ....................................... 8 1.2 Objectives ........................................ 9 1.3 Scope of the project and methodology . . . . . . . . . . . . . . . . . . . . . . . . 10 1.4 State of the art .....................................11 1.4.1 Perception ...................................11 1.4.2 Task manager .................................12 1.5 TIAGo robot description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2 Perception 17 2.1 Introduction ......................................17 2.2 Image processing ...................................17 2.2.1 Image acquisition ...............................17 2.2.2 Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.2.3 Feature extraction ...............................21 2.2.4 Image processing results . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.2.5 Pseudocode ...................................24 2.3 Pose estimation .....................................24 2.3.1 Results and problems of pose estimation . . . . . . . . . . . . . . . . . . 26 2.3.2 Can position and orientation optimization . . . . . . . . . . . . . . . . . 26 2.4 Implementation inside the task manager . . . . . . . . . . . . . . . . . . . . . . 29 3 Task Manager 31 3.1 Introduction ......................................31 3.2 Behavior Tree Library Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.2.2 Type of nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3.2.3 Ports .......................................33 3.3 Behavior Tree inside ROS ...............................33 3.3.1 How it works inside ROS . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 3.3.2 How to implement behavior tree nodes . . . . . . . . . . . . . . . . . . . 34 3.3.3 How to build the logic process . . . . . . . . . . . . . . . . . . . . . . . . 36 3.4 Structure used in this project .............................38 3.4.1 General view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.4.2 System process explanation . . . . . . . . . . . . . . . . . . . . . . . . . 40 4 Experiments and Results 49 4.1 Perception experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 4.2 Task manager experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 4.3 General process experiments .............................59 5 User manual 61 5.1 Required actions before execution the entire system process . . . . . . . . . . 61 5.1.1 Environment setup ...............................61 5.1.2 Connection to TIAGo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 3
5.1.3 Map building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 5.2 How to reproduce the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 6 Costs 65 7 Environmental and social impact 67 7.1 Environmental impact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 7.2 Social impact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 8 Conclusions 69 8.1 Specific conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 8.1.1 Perception ...................................69 8.1.2 Task manager .................................70 8.2 General conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 9 Future work 73 9.1 Perception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 9.2 Task manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 9.3 General process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 10 Acknowledgements 75 References 76 A Code Repository 79 B XML file of the project 81 C Pose estimation algorithm 87 C.1 The feature vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 C.2 Analytic solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 D Optimization of pose estimation 93 D.1 Pose correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 D.2 Orientation correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 List of Figures 1 Image of the hackathon competition [1] at the IROS 2019.. . . . . . . . . . . . 8 2 Example of state diagram of a Finite State Machine (FSM). . . . . . . . . . . . 12 3TIAGo robot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4 Image processing steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 5 Original images. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6 Gray images. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 7 Binarized images. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 8 Can parts in image processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 9 Contours of the top of the can. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 10 Necessary points to perform pose estimation algorithm. . . . . . . . . . . . . . 22 11 Steps to obtain Sipoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4
12 Detection of each can and addition of their labels. . . . . . . . . . . . . . . . . . 25 13 Soda cans labeled with its number. This number is shown to the user to let him/her choose the drink. ...............................25 14 Taken capture. .....................................27 15 Visual result without applying any correction process. . . . . . . . . . . . . . . 28 16 Visual result without applying any correction process, from TIAGo’s view perspective. .........................................28 17 Result after applying position and orientation correction. . . . . . . . . . . . . 28 18 Result after applying position and orientation correction, from TIAGo’s view perspective. .......................................28 19 Result applying just orientation’s correction, from TIAGo’s view perspective. . 28 20 Result applying just orientation’s correction. . . . . . . . . . . . . . . . . . . . . 28 21 Result after applying both optimization processes. . . . . . . . . . . . . . . . . 29 22 Result after applying both optimization processes, from TIAGo’s view perspective. ...........................................29 23 Blank Groot interface. .................................37 24 Blank Groot interface. .................................38 25 System Behavior Tree created in Groot GUI. . . . . . . . . . . . . . . . . . . . . 39 26 Project’s behavior tree general view with sub-trees. . . . . . . . . . . . . . . . . 41 27 Open bar. ........................................44 28 Serving table user interaction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 29 Go to sensing table. ..................................45 30 Ask user to choose drink. ...............................45 31 Grasp can. .......................................46 32 Go to serving table. ..................................46 33 Serving drink. .....................................47 34 Experiment to check orientation with sample 1. A ROS topic was used to publish a message of type visualization_msgs/MarkerArray. . . . . . . . . . . . 50 35 Experiment to check orientation with sample 2. A ROS topic was used to publish a message of type visualization_msgs/MarkerArray. . . . . . . . . . . . 51 36 Experiment to check orientation with sample 1. A ROS topic was used to publish a message of type visualization_msgs/MarkerArray. . . . . . . . . . . . 52 37 Experiment to check orientation with sample 2. A ROS topic was used to publish a message of type visualization_msgs/MarkerArray. . . . . . . . . . . . 53 38 Experiment with sample 1. It shows if moving the grasping tool of TIAGo, it is possible to make the can fit between grasping fingers with the position of each can given by perception module. . . . . . . . . . . . . . . . . . . . . . . . . 55 39 Experiment with sample 2. It shows if moving the grasping tool of TIAGo, it is possible to make the can fit between grasping fingers with the position of each can given by perception module. . . . . . . . . . . . . . . . . . . . . . . . . 56 40 Output printed in terminal for each experiment. . . . . . . . . . . . . . . . . . . 57 41 Behavior tree used in goToSensingTable sub-tree modified in order to force a failure. ..........................................58 42 Observation of a point P.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 43 Problem setup. .....................................89 5
page 6 Report List of Tables 1 These errors are computed for sample 1. They are obtained by comparing the position of the soda cans obtained from perception module with the position obtained from aruco detector. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 2 These errors are computed for sample 2. They are obtained by comparing the position of the soda cans obtained from perception module with the position obtained from aruco detector. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3 Calculation of the final cost of the project. (Variable costs of TIAGo and lab computers have been computed dividing their fixed cost by their life expectancy in hours. Variable costs of electric consumption of each systems have been computed multiplying the power consumption of each machine by the average price of electricity described before). . . . . . . . . . . . . . . . . . 66
Mobile manipulation with the TIAGo robot: perception and interaction page 7 1 Introduction Robotics is one of the engineering areas that has been growing more and more in the past years. Everyday the news and social media have new articles presenting new amazing systems that can perform more complicated tasks. In the past, robots where almost only present in industry focusing in working on big repetitive manufacturing chains and in the military world. They where strictly separated from workers and doomed to do the same operations over and over. Lately, it has been more common to see robots away from industrial environments, like in hospitals, hotels, in the sky or even in our homes. For this reason Service Robotics is one of the fields in robot engineering that has been gaining a more important role last years. With the appearance of home robots that conquered successfully the market and became very well spread among society like Roomba, companies all over the glove have started to invest more money and efforts into generating new robotics products. In the last decade, the number of investigations around it and therefore the number of applications has increased year after year making it a main topic in laboratories and in the lead R&D research companies of the field. Service robots, as described by the International Organization for Standardization, are those robotic solutions “that perform useful tasks for humans or equipment excluding industrial automation applications” [2]. For that reason, this kind of robots must be capable of performing tasks based on the current state of its environment, being capable of sensing it and deciding autonomously. To achieve such an autonomous behaviour this kind of robots must combine theory and techniques coming from a wide range of different fields in order to perform a certain task which might be perceived as quite simple by a human being. Knowledge and techniques from fields like computer vision, machine learning, artificial intelligence, task planning and many others must be combined successfully to solve correctly the task. All of them must be studied and exploited in order to provide the robotic platform with all the tools necessary to complete its assignment. This project will focus on completing a service task, in particular its goal will be to use a mobile manipulator to serve a drink to a client. The robot selected is TIAGo, the collaborative mobile manipulator developed by the Barcelona company PAL Robotics. According to the description of the robot in the company’s web page the TIAGo robot “makes it immensely easy for developers to create their own applications and is open to customization and expansion. Fully ROS-enabled 1, it integrates manipulation, perception, navigation and HRI skills to suit multiple scenarios”[4]. Being a fully ROS enabled robot and all the different features that it integrates out of the box make this robot a very good option to try to complete a task of such characteristics Nowadays there are several examples of robots designed specifically to complete the task of serving food and drinks to customers in bars and restaurants. Videos [5] and [6] depict a couple of examples of these kind of robots. For now these robots do not have many cognitive capabilities as they are mainly “transporting” robots which carry the orders of 1ROS: Robotics Operating System.[3]
page 14 Report • The more complex the system becomes, the more probable is for FSM to create a spaghetti state machine, and this increases when tasks are divided in smaller ones. • If it is necessary, a BT can run two different nodes at once. In order to do this with FSM, it is necessary to create another different FSM, being less readable and understandable. • Finally, a good advantage of BT over FSM is the existence of visual editors that transform a graphical Behavior Tree into an XML description file, understandable by the BT library used to describe the BT structure. Finally, Behavior Tree was chosen as the best tool to implement the task manager of this project. In order to implement a behavior tree, an open-source library, called BehaviorTree.CPP [13]. On the other hand, for the behavior tree description a GUI editor, called Groot [14], was used. 1.5 TIAGo robot description A little description of the robot will be provided in order to have a better picture of the different characteristics and features of the robot. From the hardware point of view the robot incorporates several different elements of interest for this project. They are described next from top to bottom. The first element is a mobile head with a RGB-D camera inside it. The head can be moved using two motors on the its base to perform tilt and pan rotations. These movements can be used to focus the camera view range to different regions without moving the robot. This increases the visual range of the perception area of the camera. Just below the head, on the base of the neck, the robot incorporates as a stereo microphone for interaction and a speaker that can be used to reproduce different sounds. Going down to the torso of the robot, the most important element is the 7 degrees of freedom arm mounted on its chest. The first joint can be used to rotate the shoulder over the ground plane as an inverted 7DOF industrial arm. In particular, this robot has changed its mechanical limits to present a left-handed configuration instead of the standard righthanded one. The end-effector base incorporates a force/torque sensor to check the pay load on the end of the arm. The final tool mounted to the arm is a two claw gripper as the one in Figure [3]. Following from top to bottom, a prismatic joints is found on top of the mobile base. This link can be extended and retracted to change the height of the robot by lifting or lowering the torso. Finally, below this link, the mobile base is mounted. This is a differential drive mobile base that gathers all the necessary elements for navigation. It incorporates a belt of LEDs that can be managed to perform different lights and patterns, a laser range-finder sensor and two rear sonar sensors to successfully navigate the base.
Mobile manipulation with the TIAGo robot: perception and interaction page 15 Figure 3: TIAGo robot. From the software point of view, TIAGo uses as operating system the 64-bits version of Ubuntu,RT Preempt real-time framework. The robot uses ROS as a robotics middleware between the software layer and the Ubuntu OS. A robotics middleware is a communication layer between the software solutions developed by the user and the different drives of the OS used to control the robot. In particular ROS is an open source layer that provides standard operating system services such as hardware abstraction, low-level device control, implementation of commonly used functionality, message-passing between processes, and package management. Over this ROS layer, the robot includes a lot of different tools and features that are very useful to developers. There a lot of different packages already installed in the robot that can be helpful for so many different from controlling the base to recognizing human faces using the camera images. During the report the more relevant for this project will be described and mentioned.
Mobile manipulation with the TIAGo robot: perception and interaction page 17 2 Perception 2.1 Introduction The main objective of this module is to estimate the position of the cans of soda to be grasped. In order to do that, some image processing methods are applied to detect the cans and to obtain all the necessary information required for the pose estimation algorithm to obtain the position of each of the cans. Then, these positions are sent to task manager module, which call the arm’s module and gives to it the position of the object that must grasped. This module is implemented as a ROS node and called by the task manager module with the use of a ROS service. 2.2 Image processing In order to estimate the position of each of the targeted objects, it is necessary to apply some image processing steps to obtain some key points in the image plane, as a part of the input data of the algorithm in charge of estimating the position of the cans of soda. These image processing steps are summarized in Figure 4. 2.2.1 Image acquisition First of all, it is necessary to capture the image showing all the cans that can be selected by the user. ROS gives the possibility of subscribing/publishing information through topics, relevant to the robot and the devices being used. For instance, there are topics related to the information from the camera that TIAGo has. For instance, the topic /xtion/rgb/image_rect_color is the topic with the rectified color image. When the perception module is called, it is subscribed to this topic until it gets an image from the camera. This image is received in a message of type sensor_msgs/Image, that is later converted into a Mat variable in order to perform all the image processing steps. As an example, Figure 5shows two images taken by TIAGo’s camera and published at topic /xtion/rgb/image_rect_color. From now on, these images are going to be used in order to show each of the results obtained at each image processing step. Figure 4: Image processing steps
page 18 Report (a) (b) Figure 5: Original images. 2.2.2 Segmentation When the image is acquired, the segmentation process starts. This process executes the following steps. From color to gray The original image is an image with color. So, to execute the following segmentation process it is necessary to transform image from color to gray. The result of this transformation is shown in Figure 6. Binarization In order to isolate the cans from the rest of the scene, different alternative were attempted, being the binarization the best way to do it. Two results of a binarization are shown in Figure 7. The main reason why binarization works well is because the high gray intensity that the top of the cans has in relation to the rest of the objects scene. So, this way it is easier to isolate the cans from the scene. Nevertheless, this is not enough to detect if an object is a can or not. It is also necessary to extract other features of the can, as the location of the hole on its top (cans are assumed to be opened, ready to be served). It is possible to observe in Figure 7a that the binarization also isolates some bright regions from the scene, possibly detected as cans. For this reason, it is necessary to add an image processing procedure to have a better can isolation. Contours After binarization it is possible, with some of the Open CV functions, to fit an ellipse to the contours obtained.
Mobile manipulation with the TIAGo robot: perception and interaction page 19 (a) (b) Figure 6: Gray images. (a) (b) Figure 7: Binarized images.
page 20 Report Figure 8: Can parts in image processing. (a) (b) Figure 9: Contours of the top of the can.
Mobile manipulation with the TIAGo robot: perception and interaction page 21 2.2.3 Feature extraction As binarization it is not enough to isolate and detect cans, it is necessary to extract some features that cans have, like the existence of a hole at its top. Fig. 8shows the top contour and the hole of a coke can. Distinction between can’s top and hole Figures 9a and 9b show the contours detected for both can’s tops and holes (and some false detection too). In order to know if some detection is a can or not, it must have a hole inside its top, i.e. it should have a can’s hole contour inside a can’s top contour. So, first of all it is necessary to distinguish between a top and a hole. To do that, each contour will be compared with the rest of contours. If the contour that is being evaluated at the moment (e.g. contour A), is bigger, and the center of the other contour that is being evaluated (e.g. contour B) is in inside contour A, contour A will be assigned as the top of the can and contour B as the hole of that can. But if another possible hole is detected and it has more possibilities of being a hole, because it has higher black pixels rate than the previous assigned hole, it will substitute the previous hole. On the other hand, in order to improve the robustness of a can detection, a second round to detect holes inside contours was added, segmenting each top of can and looking for a black hole by searching clusters of black pixels. Feature vector points at image plane Now, there is information about the top and hole contours and their center. With that, it is possible to find the four coplanar points (S1to S4) required to estimate the position of each can. These points correspond to the intersection with the contour of the top of the can of the xand yaxis of a reference frame located on the plane of the top side and centered at its middle point (Fig. 10) Obtaining points S1and S3 To extract that points it is necessary to join the center of the top of the can Xwith the center of the can’s hole Hand create a line that intersects with the ellipse of the top of the can. This point is called S1, then S3is created by drawing a line in the opposite direction and intersecting with the ellipse of the top of the can again. It is possible to observe this behavior in the transition from figure 11a to figure 11b, and it is described in expression 1. (s1, s3) = intersection(line(X, H), ellipse)(1) Compute vectors viand u Now, in order to obtain the other two points S2and S4, it is necessary to perform some computations. First of all, it is necessary to compute local vectors viand u.
page 22 Report Figure 10: Necessary points to perform pose estimation algorithm. To obtain viand uit is required to take into account points P={P1, P2, P3, P4} and point X. These points come from the bounding box that delimits each of the can’s top: •Piare the bounding box vertices. •Xis the bounding box center. Then: •uis the vector created by joining Xand S1: u=S1−X(2) •viis the vector joining Xand Pi(Fig. 11c): vi=Pi−X(3) •W zi: are the Zivalues of the cross products between vand u: W zi= (vi×u)001T(4) The sign of W ziis used to determine if S1is in between Piand Pi+1 being i={1, 2, 3, 4}: When W zj>0and W zj+1 <0then S1is in between Piand Pi+1.
Mobile manipulation with the TIAGo robot: perception and interaction page 23 (a) Top’s center, hole center and bounding box points. (b) Line intersection between top’s center and hole’s center. S1and S3are created. (c) Local vectors vi. (d) Obtaining point Q1. (e) Obtaining point Q2.(f) Obtaining intersection of line formed by Xand Q2with top’s ellipse. Then S2and S4. Figure 11: Steps to obtain Sipoints.
Mobile manipulation with the TIAGo robot: perception and interaction page 31 3 Task Manager 3.1 Introduction The aim of this module is to manage all the tasks executed by the other modules as navigation, perception and arm’s interface. Moreover, it manages other tasks that are necessary to perform all the entire process. There are different ways to manage the different tasks of a system. The most direct way is to hard code it and manage all tasks by using loops and conditions. The problem with that comes when it is wanted to debug the code or add a new functionality. The bigger is the code, the more difficult it is to know what it is doing and to add new tasks. The most feasible way to create a task manager is to do it in a modular way. Isolating the code of each task from the rest of code, but being possible to communicate among all tasks. This way, it is not a problem to add new tasks and the debugging problem disappears, because when something is not working quite well, it is possible to debug just the task that is not working without affecting the rest of tasks. Another advantage of being modular, is that the system can be built in different order, just ordering in a different way these modules, like black boxes, without having big problems. 3.2 Behavior Tree Library Theory 3.2.1 Introduction The behavior tree library allows to create different tasks, called nodes, that can be communicated among them by using ports. These nodes are controlled using controller nodes of different types, depending of the task’s needs. In addition, there exist other type of control nodes, called decorator nodes, that allows to manipulate the flow of the behavior tree. Each type of node, except decorator nodes, have three different type of states: • RUNNING: still executing the node process. • SUCCESS: the node has finished successfully. • FAILURE: the node has finished without success. Then, once all the nodes have been implemented using the behavior tree library [13], it is necessary to describe the behavior tree (BT). This is done with an XML file or using a GUI editor. Groot is the GUI BT editor that has been chosen for the development of this project. Its own nomenclature will be used for the nodes explanation, i.e. the mentioned names of the type nodes come from the GUI editor Groot, despite behavior tree theory [17] uses different names in some cases.
page 32 Report 3.2.2 Type of nodes Control Nodes This kind of nodes is in charge of executing their child nodes. There are different type of control nodes that condition the execution behavior of the rest of nodes. The different type of control nodes are the following: •Sequence Nodes A sequence node follows the AND logic. All its child nodes must return SUCCESS in order to finish the process successfully. If some of the children returns FAILURE, the process is going to be aborted and returns FAILURE. In addition, sequence control node is composed of two different types: –Sequence –SequenceStar The difference between these two types lies in the response when a child node returns a FAILURE. While sequence control node restarts again the sequence of nodes execution, sequenceStar control node ticks again the last executed node (i.e. it invokes the callback function of the last executed node), the one that returned a FAILURE. •Fallback Nodes A fallback node follows the OR logic. At least its last child node must return SUCCESS in order to finish the process successfully. If the last child returns FAILURE, the process is also going to return a FAILURE. So, as it works as an OR logic, if one child returns a FAILURE it ticks the following child until all children have been ticked or a SUCCESS has been received from one child. There are two types of fallback control nodes: –Fallback –FallbackStar In this project only the standard fallback control node is used, because there are no tasks that requires to be interrupted in a asynchronous way as fallbackStar control node offers. Decorator Nodes Decorator nodes can only have one child and they are normally used for especial controls. There are different types of decorator nodes: • Inverter • ForceSuccess • ForceFailure
Mobile manipulation with the TIAGo robot: perception and interaction page 33 • Repeat • RetryUntilSucessful • Timeout Action Nodes Action nodes do not have any child node. It is necessary to be implemented in order to perform the necessary tasks. Condition Nodes Condition nodes are very similar to action nodes. They must be implemented, but they should not return a RUNNING nor change anything on the system. 3.2.3 Ports As behavior tree nodes have a very similar concept a normal functions, they also use input parameters and output information (that at the same time can be used as input parameters by other behavior tree nodes). The use of ports can be very useful when there are some parameters that are required to be changed because of debugging reasons or because they can vary according to the scene or because some behavior tree nodes need to share some variables. In this project, ports are not necessary because: • All the parameters that are required to be changed, are set in a launch file. • All the variables required to be shared among behavior tree nodes are shared with a class. So, an object from this class is passed to each behavior tree node when they are created. 3.3 Behavior Tree inside ROS 3.3.1 How it works inside ROS Using BehaviorTreeCPP all ROS functionalities continue working as normally, but now a new layer is added. So, instead of using different ROS nodes or functions for each step, an added layer managed by a behavior tree is used. It can be seen that each layer has its own file. These files are the following ones: •node.cpp: The called ROS node. It initializes the task manager. •behavior_tree_nodes.cpp: Behavior tree manager nodes. Each behavior tree node calls a function from Manager class. •manager.cpp: It contains a class, called Manager, with all the necessary functions to manage all the tasks that the robot should execute to perform all the process. All the robot functions that it uses comes from Robot class.
page 34 Report •robot.cpp: It contains a class, called Robot, with all the necessary functions to interact with the robot. 3.3.2 How to implement behavior tree nodes Create a node There are two ways to create a node: • Creating a class by inheritance from class SyncActionNode as shown in listing 2. Listing 2: BehaviorTree Node created by class inheritance. 1 2class GoToServingTable: public SyncActionNode 3 { 4 5public: 6 GoToServingTable(const std : : string& name) : 7 SyncActionNode(name, {}) 8 { 9 } 10 11 BT: : NodeStatus tick () override 12 { 13 std : : cout << "GoToServingTable: " << this−>name() << std : : endl ; 14 return BT: : NodeStatus : :SUCCESS; 15 } 16 }; • Creating a node using dependency injection with a function pointer, as shown in listing 3. Listing 3: BehaviorTree Node created by function pointer. 1 BT: : NodeStatus myFunction() As all the functions that manage the tasks are inside Manager class it is necessary to insert an object of Manager class as an attribute in node’s register. Different ways to use a Manager object have been attempted: •Sharing the Manager class object using behavior tree ports. The problem of this solution was the complexity of sharing each time the object and the low readability of this option. A new developer would not understand this data interchange.
Mobile manipulation with the TIAGo robot: perception and interaction page 35 •Sharing the same Manager class object by using a pointer. This was the chosen option. The object was shared defining an object pointer of class Manager in each inherited class, created to implement a behavior tree node. This way the same object was shared among all nodes in a more understood and readable way. Register a node Once the nodes functionality are implemented it is time to register them for their later execution. There are two main ways. •Using a function or class method. In order to register a node with a function pointer it is necessary to indicate if it is an action node or a condition node, and it is possible to register it by using a function pointer or a method of a class. It is possible to see below how to register a node with each one of these options. –Using a function pointer: Listing 4: BehaviorTree Node created using a function pointer. 1 factory . registerSimpleAction ( "GoToSensingPosition" , 2 std : : bind(GoToSensingPosition ) ) ; 3 factory .registerSimpleCondition("CheckSensingPosition" , 4 std : : bind(CheckSensingPosition ) ) ; –Using a class method: Listing 5: BehaviorTree Node created using a class method. 1 GripperInterface gripper ; 2 factory . registerSimpleAction ( "OpenGripper" , 3 std : : bind(&GripperInterface : : open, 4 &gripper ) ) ; 5 factory .registerSimpleCondition("CheckGripper" , 6 std : : bind(&GripperInterface : : check_gripper , 7 &gripper ) ) ; •Using a node created by class inheritance. This is the most recommended option since it is not necessary to indicate which is the type of the node. This was the chosen option but adding a parameter to the behavior tree node created by inheritance. This added parameter is an object pointer from class Manager used to execute all the necessary functions to perform all the tasks. Moreover, this object pointer shares with all behavior tree nodes a ROS node, being possible to execute different services and ROS functionalities without the need of creating each time a new node.
page 36 Report In order to have this object pointer inside the class, it is necessary to define the behavior tree class node as shown in listing 6and register the node by using the same coding shape as shown in listing 7. Listing 6: BehaviorTree Class Node with object pointer as parameter. 1class OpenBar: public SyncActionNode 2 { 3 4public: 5/ / additional arguments passed to the constructor 6 OpenBar( const std : : string& name, const NodeConfiguration& config , 7 Manager& manager) : 8 SyncActionNode(name, config){_manager = &manager;} 9 10 NodeStatus tick () override ; 11 static PortsList providedPorts () { return {}; } 12 13 private: 14 Manager *_manager; 15 }; Listing 7: BehaviorTree Node registration adding a object pointer as parameter. 1 NodeBuilder builderOpenBar = [&manager]( const std : : string& name, 2const NodeConfiguration& config ) 3 { 4return std : : unique_ptr<OpenBar>( new OpenBar(name, config , manager) ) ; 5 }; 6 TreeNodeManifest manifestOpenBar = 7 BehaviorTreeFactory : : buildManifest<OpenBar>("openBar" ) ; 8 factory . registerBuilder ( manifestOpenBar , builderOpenBar ) ; 3.3.3 How to build the logic process Once the nodes behavior have been implemented and registered, it is time to build the logic process that the entire system is going to follow to perform all the tasks. Below is described how to do it with an XML file and with Groot. XML file In BehaviorTree library documentation [18] the format that the XML file must follow is well explained. In appendix Bthe XML file of this project is shown. It was created using Groot.
Mobile manipulation with the TIAGo robot: perception and interaction page 37 Figure 23: Blank Groot interface. Groot Groot is a GUI that allows to build the XML that defines the logic process graphically. In figure 23 the Groot editor and its TreeNode Palette are shown, with the different default nodes that the Groot editor offers to build a behavior tree. They are the following: •Root –Root →It is a necessary node. Without this node at the beginning of the behavior tree, the XML file is not created. •Action All action nodes are registered here. The default action nodes are the following ones: –AlwaysFailure →Creates a node without any action that always returns a failure. Normally used for debugging reasons. –AlwaysSuccess →Creates a node without any action that always returns a success. Normally used for debugging reasons. –SetBlackBoard →Set a value for a port. Normally used for debugging purposes. •Control –Fallback →Implements fallback control node. –FallbackStar →Implements fallback star control node.
page 38 Report Figure 24: Blank Groot interface. –Sequence →Implements sequence control node. –SequenceStar →Implements sequence star control node. •Decorator Nodes with just one child, that apply special effects to its child nodes. –BB_Precondition →Node used as conditional, that returns a success when condition is fulfilled. –ForceFailure →Forces the failure of a node. Normally used when a failure is required for debugging reasons. –ForceSuccess →Forces the success of a node. Normally used when a success is required for debugging reasons. •SubTree In this section all sub-trees are listed. The sub-trees are groups of nodes with a bigger functionality. As an example, Figure 24 shows that to give the possibility to the user to choose a drink, a sequence of tasks must be executed. Therefore, the sequence of actions to allow user choose drink is grouped in a sub tree-called ASK USER TO CHOOSE DRINK. Figure 25 shows the same editor with the created action and condition nodes, in addition to created sub-trees. 3.4 Structure used in this project Taking into account previous sections about behavior tree, the project’s behavior tree will be explained and developed in this section.
Mobile manipulation with the TIAGo robot: perception and interaction page 39 (a) Graphical Behavior Tree. (b) Root and Action nodes. (c) Condition, Control and Decorator nodes and SubTree. Figure 25: System Behavior Tree created in Groot GUI.
page 46 Report Figure 31: Grasp can. Figure 32: Go to serving table.
Mobile manipulation with the TIAGo robot: perception and interaction page 47 Figure 33: Serving drink.
Mobile manipulation with the TIAGo robot: perception and interaction page 49 4 Experiments and Results In this section, the different experiments performed for the perception and task manager modules and the general process will be explained. The different results obtained from these experiments are used to analyze the behavior of the solutions. Some quantitative and qualitative data are analyzed for the perception part. On the other hand, for the task manager part, it is just necessary to perform some experiments to obtain qualitative data. A video was used to perform an experiment of the task manager. That is why it is important to remark that in the Appendix Athere is a link to a code repository page that, aside from all the code used in these tests, includes several videos of the different experiments mentioned in this section, both in this document and in that one from my partner with the parts of navigation and planning. 4.1 Perception experiments Perception was tested checking whether the position and orientation of the soda cans, computed by pose estimation algorithm, has a small enough error or not. In order to check that, three experiment were performed. •Check orientation With this experiment the orientation of the cans is evaluated. Three samples were used, consisting of nine soda cans each. In order to make it easy to check this orientation, Markers in rviz were used. This way it is possible to check it in a visually. Therefore, for performing this experiment, the perception module should be run. The perception module detects the soda cans and estimates their position, then publishes in a ROS topic the position and orientation using a MarkerArray message. Finally, it is possible to compare the orientation of each labeled can, shown in the capture done by perception module, with the orientation displayed with the rviz markers. For the purpose of comparing both orientations it is necessary to take into account the direction of each axis for each can: – X-axis it is shown in red in rviz markers, and must go from the center of the can towards the hole of the can. – Y-axis it is shown in green in rviz markers, and it is perpendicular to X axis in top of the can’s plane. – Z-axis it is shown in blue in rviz markers, and it is normal to the Xand Yaxis. As a result of this experiment, Figures 34,35 and 36 compare the result obtained with pose estimation algorithm with the real orientation. For each figure, left and right sub-figures have a similar perspective view, so it is easy to check that the orientation of the cans is correct for the first two samples.
page 50 Report (a) (b) Figure 34: Experiment to check orientation with sample 1. A ROS topic was used to publish a message of type visualization_msgs/MarkerArray. On the other hand, there is a mistake with can number 6, from last sample. Due to the position where it is, it is more probable to have some detection mistakes. In this case, the center of the hole was not found with accuracy and the angle formed by the center of the can and the hole creates a wrong S1point, and in consequence, a wrong x-axis direction and wrong orientation of the can. •Aruco markers comparison With this experiment we want to compare the positions given by the perception module with the positions given by a typical and very used pose estimation algorithm, as the Aruco markers detector. In order to execute this experiment, the following steps are performed: –9 cans of soda are placed on the sensing table. –These 9 cans are detected with the perception algorithm and their pose estimation is returned. –The returned pose estimation is published as a marker in order to see it on rviz and it is also possible to see the positions with the values returned by the service tiago_sensing/detectObjects. –It is placed an aruco at each can and their position is obtained from the pose topic published by aruco detector algorithm. It is also possible to see this pose in rviz and compare both positions graphically. –Finally, the values are compared and an error is obtained. For this experiment, two samples will be used, sample 1 (the same as the last one used in the previous experiment) and sample 2 shown in figure 37. In order to compare the positions obtained with perception module and the ones obtained with aruco detector it is better to use quantitative data instead of showing the results graphically.
Mobile manipulation with the TIAGo robot: perception and interaction page 51 (a) (b) Figure 35: Experiment to check orientation with sample 2. A ROS topic was used to publish a message of type visualization_msgs/MarkerArray. In tables 1and 2can be seen the results obtained from the position comparison between the position obtained using perception module and the one obtained applying aruco detector module for sample 1 and sample 2 respectively. In that table can be observed that the error is minimal, normally it is not higher than 2 cm both in X and Y axis. But this error is critical to grasp the user’s chosen can or not. It should be taken into account that it is possible to get some position error with aruco markers, because of a little bad detection or, because of human error when placing the aruco marker on the top of the can. The center of aruco may not be aligned with the center of the top of the can. •End effector position comparison On the other hand, the position of the cans of soda obtained from the perception algorithm, are compared with the position of the end effector. This way, it is possible to check if the real positions of the end effector and the cans correspond with the positions shown in rviz. This is useful to check if the path planner will be able to reach to can’s position before executing the movement, just moving by hand the end effector to the can’s position. It is necessary to follow steps below to perform this experiment: –Two cans of soda are placed on the sensing table. –These two cans are detected with the perception algorithm and their pose estimation is returned. –The returned pose estimation is published as a marker in order to see it on RVIZ and it is also possible to see the positions with the values returned by the service tiago_sensing/detectObjects.
page 52 Report (a) (b) Figure 36: Experiment to check orientation with sample 1. A ROS topic was used to publish a message of type visualization_msgs/MarkerArray. Can Module X Y X error Y error Perception 0,4436 0,2455 0Aruco 0,4370 0,2500 -0,0066 0,0045 Perception 0,4578 0,0658 1Aruco 0,4516 0,0711 -0,0062 0,0053 Perception 0,4671 -0,1056 2Aruco 0,4600 -0,1030 -0,0071 0,0026 Perception 0,5686 0,0712 3Aruco 0,5700 0,0800 0,0014 0,0088 Perception 0,5840 -0,1014 4Aruco 0,5901 -0,0986 0,0061 0,0028 Perception 0,6778 0,2576 5Aruco 0,6774 0,2722 -0,0004 0,0146 Perception 0,6736 0,0651 6Aruco 0,6860 0,0700 0,0124 0,0049 Perception 0,6827 -0,0913 7Aruco 0,7008 -0,0856 0,0181 0,0057 Perception 0,5512 0,2453 8Aruco 0,5686 0,2670 0,0174 0,0217 Table 1: These errors are computed for sample 1. They are obtained by comparing the position of the soda cans obtained from perception module with the position obtained from aruco detector.
Mobile manipulation with the TIAGo robot: perception and interaction page 53 (a) (b) Figure 37: Experiment to check orientation with sample 2. A ROS topic was used to publish a message of type visualization_msgs/MarkerArray. Can Module X Y X error Y error Perception 0,4601 0,0791 0Aruco 0,4550 0,0810 -0,0051 0,0019 Perception 0,4655 0,2351 1Aruco 0,4640 0,2461 -0,0015 0,0110 Perception 0,5092 -0,0894 2Aruco 0,5087 -0,0816 -0,0005 0,0078 Perception 0,5812 0,0451 3Aruco 0,5834 0,0469 0,0022 0,0018 Perception 0,5768 0,2056 4Aruco 0,5798 0,2180 0,0030 0,0124 Perception 0,6254 -0,1190 5Aruco 0,6346 -0,1285 0,0092 -0,0095 Perception 0,7198 -0,0388 6Aruco 0,7227 -0,0331 0,0029 0,0057 Perception 0,7238 0,0917 7Aruco 0,7276 0,1017 0,0038 0,0100 Perception 0,6860 0,2374 8Aruco 0,7045 0,2533 0,0185 0,0159 Table 2: These errors are computed for sample 2. They are obtained by comparing the position of the soda cans obtained from perception module with the position obtained from aruco detector.
page 54 Report –The gravity compensation feature of TIAGo robot is enabled and the end effector of the robot is moved by hand simulating the purpose of grasping a can. –For each can, the end effector is moved until the can is in between the tool fingers. –Finally, it is possible to see graphically if with the position obtained by the perception module, the robot would be able to grasp the can or not, applying correctly the planner to that position. As it can be observed in figures 38 and 39, when the movement of the grasping tool to the chosen cans is simulated and it is in the good position to grasp the can, it is seen that the can fits in between grasping tool fingers, so the real position coincides with the position seen in rviz. But there is a case, in figure 39d, where the can does not fit with the grasping tool due to a failure in pose estimation. 4.2 Task manager experiments •Behavior tree checked with terminal messages The first experiment that must be done in order to check if the behavior tree built with Groot works well or not, it is printing messages that indicate which behavior tree node is running at the moment. This way it is possible to see in which node it is the program at each moment and it is possible to change some return values in order to check if everything is working well or not. Two tests were performed for this experiment: –For the first test, all the executed nodes must return a SUCCESS, simulating that everything goes well. This behavior is shown in Figure 40a, where it can be observed which nodes have been executed printing their names. –For the last test, the navigation towards sensing table was forced to fail, that is why in Figure 40b can be observed that some messages are repeated. These messages show the FAILURE state received by isRobotLocalizedSensingTable at the bottom of the behavior tree (Figure 41). Moreover, two loop control nodes have been added. The first one, makes the fallback control node be repeated until success or two attempts, and the other one makes the sequence control node, that executes goToSensingTable and isRobotLocalizedSensingTable nodes, to be repeated until success or three attempts.
Mobile manipulation with the TIAGo robot: perception and interaction page 55 (a) (b) (c) (d) (e) (f) Figure 38: Experiment with sample 1. It shows if moving the grasping tool of TIAGo, it is possible to make the can fit between grasping fingers with the position of each can given by perception module.
page 62 Report Serving glass The serving glass should be wide enough, approximately 8cm of diameter in the tops side, in order to have more error margin to serve the drinks. The position of the glass is set in the transformation tree of the system. Recycle bin There is a recycle bin where TIAGo is going to throw the drink’s can. The position of the bin is determined by the tree of transformations. It can be modified by changing the parameters.launch file. 5.1.2 Connection to TIAGo In order to connect to TIAGo it is necessary to turn in on and execute the following commands at each terminal window: 1source / ros / path / setup . bash 2export ROS_MASTER_URI=http : / / tiagoioc:11311 3export ROS_IP= ip of computer used 4cd working_space 5source devel / setup . bash As an example, these are the commands that are needed to be executed in aquaris computer in IOC lab. 1source / srv / robotica / ros / install_isolated / setup .bash 2export ROS_MASTER_URI=http : / / tiagoioc:11311 3export ROS_IP=147.83.37.19 4cd catkin_ws 5source devel / setup . bash It is necessary to execute these commands to successfully connect the ROS master service running in the robot with the working environment on the computer. 5.1.3 Map building In addition, it is necessary to build the environment map where TIAGo is going to navigate. If this map is not built, it is not possible for TIAGo to know where is him. On the other hand, in order to have good transformations of the important points, and improve the TIAGo ’s location, it is important to have two ArUcos at each table to locate better where is the robot in reference to the tables. In order to build the map it is necessary to execute following steps: 1. Call Rviz and start mapping process executing the following commands: 1 roslaunch hackaton_nav rviz . launch 2 rosservice call / pal_navigation_sm "input : ’MAP’ "
Mobile manipulation with the TIAGo robot: perception and interaction page 63 2. Move the robot around till you like the map: 1 rosservice call / pal_navigation_sm "input : ’LOC’ " * If it doesn’t work probably is because the " and ’ have changed format in the terminal rewrite them. 3. Launch the following command: 1 roslaunch hackaton_nav hackaton_master . launch 4. Place the robot in a way that it detects both ArUco frames in sensing table and then run the command: 1 rosrun hackaton_nav connect_picking 5. Check in Rviz that the positions spawned around both tables are correct as described in the memory. 6. Place the robot in a way that it detects both ArUco frames in serving table and then run the command: 1 rosrun hackaton_nav connect_serving 7. Finally, save the aruco positions. This way it is possible to close and relaunch hackaton_master.launch without losing ArUco references. To do that it is necessary to run the following command: 1 roslaunch hackaton_nav save_aruco_points . launch 5.2 How to reproduce the project After setting up all the previous requirements, it will be possible to launch the entire system program. Launch program In order to launch the program it is necessary to execute the following commands in different windows. Remember to execute the commands shown in section 5.1.2 in order to connect to TIAGo. • roslaunch dmp dmp.launch • rosrun dmp_package dmp_service.py • roslaunch tiago_manager task_manager.launch • rqt_image_view for image interface
page 64 Report Program procedure The program is going to execute the following steps. The bold steps are the ones where the user must interact. 1. Ask user for a drink. (a) Image interface: at the beginning of the program a default image is shown in rqt_image_view window published in topic tiago_sensing/image. (b) TIAGo asks to the user if he/she wants a drink. (c) The user must say yes or no using the terminal where the tiago_manager task_manager.launch was launched. 2. TIAGo goes to sensing table. (a) A base movement is performed. (b) TIAGo is prepared to detect cans. 3. Can choice. (a) TIAGo detects drink cans. (b) Show the resulting image after applying an image processing. In this image all the cans are labeled with a number. (c) The user must select, using the terminal, the number that indicates the drink that he/she wants. 4. TIAGo goes to serving table. (a) TIAGo grasps the chosen drink. (b) TIAGo moves to the serving table. (c) TIAGo serves the drink in a glass in serving table. (d) Throws the can to a recycle bin next to the serving table. (e) User enjoys the drink.
Mobile manipulation with the TIAGo robot: perception and interaction page 65 6 Costs The economic cost of the project has been structured into three main parts. The first one is the depreciation related with the project of the robotics equipment and computers of the laboratory. The second one are the costs of the working hours of the students involved in the project as well as the supervisors that were consulted during its completion. Finally, an estimation of the electrical energy consumed during the tests and the development of the solution is also included. The robotics equipment used to develop the projects consist only of TIAGo as none other robots or extra sensors or equipment was necessary. A robot of this characteristics has usually an estimated useful life of 8years. Considering a use of TIAGo of 6hours a day, 5 days a week, 48 weeks a year, this generates a useful life of the robot of 11520 hours. The two computers of the lab used to develop the project have, on the other hand, an estimated useful life of 5years. This means that using them an average time of 10 hours a day gives an estimated useful life of 1200 hours. Depreciation can be then calculated from the total price of the robot and the computers, the knowledge of their useful life and the total time that they have been used. The project has been completed from February to June with and average of 4hours per day. This generates and approximate total time of 400 hours invested in development and testing. The two computers of the lab have been running constantly for almost all of these time so a percentage of 95% will be estimated for them, which means a total of 380 hours of use. TIAGo on the other hand has been working less and mainly in the final part of the project when the different tests have been performed, therefore a ratio of 60% will be considered for its working hours. This generates a total of 240 hours using the robot for this project. The working hours of both students can be estimated of 400 hours employed in the lab to complete project plus 20 hours more spent in writing this report and completing other documentation tasks. This is a total of 420 hours spent by each student. As ETSEIB recommends, the salary for the students will be considered of 8€/h. Supervision and meeting hours with the director of the project and other members of the staff of the laboratory will be considered of 50 hours in total with an average cost of 30 €/h. Finally, the electrical cost can be summarized by only considering the energy consumed by the computers and the robot during their working hours. The rest of electrical elements of the room are not considered as there is much more people working on the lab and light consumption would remain the same regardless of the project analyzed in this memory. With an average electrical cost in 2019 of 0.15 €/kWh, the consumption of both computers can be estimated to be of about 0.40 kWh. TIAGo, on the other hand, has an electrical consumption of 0.72 kWh. Next table presents all the costs described and analyzed. The total cost of the project finally is of 9964.75 €.
page 66 Report Cost factor Fixed cost [€] Life expectancy [h] Variable cost [€/h] Time referred to the project [h] Cost related to the project [€] TIAGo Depreciation 50000 11520 4.34 380 1649.31 Electric consumption - - 0,11 380 41.04 Lab Computers Depreciation 2000 12000 0.17 240 40 Electric consumption - - 0,06 240 14.4 Students - - 8 840 6720 Supervisors - - 30 50 1500 TOTAL COST 9964.75 Table 3: Calculation of the final cost of the project. (Variable costs of TIAGo and lab computers have been computed dividing their fixed cost by their life expectancy in hours. Variable costs of electric consumption of each systems have been computed multiplying the power consumption of each machine by the average price of electricity described before).
Mobile manipulation with the TIAGo robot: perception and interaction page 67 7 Environmental and social impact When developing new ideas and solutions in all the fields of engineering it is always very interesting to take some time and reflect on the impact of that idea in the environment and in society. In this chapter a small discussion around these topics will be conducted. 7.1 Environmental impact Robotics research can have a very deep impact in ecology and energy industries. In the particular field of this project, service robotics, the impact is much lower. In fact, using this kind of mobile manipulators in many different business could incur in an increment on energy consumption by this establishments. Of course this energy could be gathered using clean sources making the whole process clean and reducing the environmental impact of these solutions. But by just analyzing the project and the solutions that might come from it and be developed around it, it doesn’t seem very relevant to think that it might have any environmental impact. The relevance of this project from the environmental impact point of view is almost null. 7.2 Social impact On the other hand, this kind of service robots will have a very huge impact at a socioeconomic level. The perfecting of these machines and their implantation on the service sector will have a huge impact in the working market and society in general. This kind of robots will be working in professional area likes, medicine, professional cleaning, construction and many a others but they will also reach our homes with domestic uses like vacuum cleaning, entertaining, etc. For this reasons mobile manipulators like TIAGo will have a deep social impact in the short term future. First of all they will change our daily basis activities freeing up time and changing how we structure our daytime. If daily tasks like cleaning, preparing our food and other common activities are performed by robots instead of us, the impact in our way of life can be very deep. For this reason it will be important to change some cultural prejudgments to integrate robots in our home life in a comfortable way that does not derive into mental and social problems. On the other hand, the most important impact will occur in the job market. The massification of this kind of robots can be very dramatic if it is not performed in a controlled way. With robots completing tasks that are nowadays performed by humans, many jobs that are currently very common will disappear. In fact manual and service jobs that are associated with low preparation workers but also other important and very complex professions like surgeons, will change drastically and might become completely obsolete. On the other side, the appearance of all these new robots will create a new set of job position that will require different abilities and therefore education must change before the next generations are not prepared enough for the changes coming.
page 68 Report In summary, this project might be a very tiny step for the development of service robotics, and thus, it might contribute to all these change process making it an important thing to reflect about all these possible futures and which role must robotic engineers play in it.
Mobile manipulation with the TIAGo robot: perception and interaction page 69 8 Conclusions This section is about the reached conclusions from perception, task manager and the entire process. 8.1 Specific conclusions 8.1.1 Perception As the initial pose estimation algorithm did not work quite well the optimization processes shown in section 2.3.2 has been required. After applying these processes the pose estimation of each of the cans improved a lot, but depending of the situation the pose accuracy continued not being quite good. In order to accept the perception as good enough has to meet an important requirement: the maximum position error must be the slack between the two gripper fingers in order to make the can fit in between them and so grasp the can properly. Quantitatively, the maximum position error is ±0.75cm. This is computed taking into account the slack of gripper fingers and the size of the type of can used in this project. Therefore, depending of the circumstances the pose estimation is good enough. These circumstances depend of three main factors: •The inefficient detection of the top of the can ellipse: it would be necessary to improve the robustness of the algorithm to avoid problems with brightness. This problem is caused for the brightness environment and the characteristics of the cans, as their color. •The distance to the item: The higher is the distance to the can that is wanted to be detected, the higher are the possibilities of detecting an ellipse that does not fit quite well with the top of the can obtaining a wrong position, or the more likely is to find a bad location of the center of the top of the can and the center of the hole obtaining a wrong orientation of the can. •The quality of the camera: With a higher camera quality, the location accuracy in pixels would be higher and the distance would not affect too much to the position error. On the other hand, the accuracy compared with the arucos’s position accuracy is very similar depending of the situation. If the cans are in a good circumstance, according to the factors explained above (except the camera quality), their position is very similar from the one obtained detecting the aruco markers, sometimes even better. Otherwise, their position is worse than the given by the markers. In conclusion, in certain situations the perception module is good enough to achieve its goal, but its robustness should improve to give it more reliability in any environment and location. In addition, a good advantage is that it can be adjusted to detect other can sizes and it is very easy to use. It is only necessary call a service which returns the estimated position of the detected objects.
page 70 Report 8.1.2 Task manager As it has been seen in this project, task manager was built with a behavior tree model using a visual editor called Groot. The use of this tool made much easier the definition of the system procedure and its scalability. Unlike hard coding, the task manager procedure to add, delete or modify functionalities is very easy. Moreover, it allows to follow the steps of the system execution much easier. Concluding, it can be seen that using behavior trees is a good way to scale a program without going deep in programming, just creating nodes and building system execution strategy visually using Groot. In addition, it allows to separate each behavior tree node in order to have a better debugging process when needed, being possible to check each part of the process without many problems. 8.2 General conclusions Before starting to analyze the whole waiter process it would be interesting to mention that the robotic platform suffered an accident that kept it out of work for almost two weeks in the last month of the project. This was a very important complication as most of the experimental and testing tasks were planned to be performed on this last month. Due to this, the time for testing and experimenting was reduced by a half so some of the tests had to be canceled and others could not be performed as desired. This also generated that some solutions designed after performing some of the tests could not be retested again before finishing this memory. All the individual parts have been proven to work successfully and the task manager can correctly connect them in order to perform the whole waiter process. The solution developed can complete the entire serving process while sensing, picking and serving the cans as demanded by the users. The results obtained show that in simple scenarios, the method works correctly and allows the robot to be fully autonomous to serve drinks to the users. The task manager block, which gets its most importance in the final tests, has proven to correctly combine the different blocks and generate a sequence of actions to complete the task. The objective of completing the hackathon challenge by integrating the solutions completed for it and developing new ones has been achieved. The solution has been structured in different packages that can be launched and tested separately, presenting independent tools to solve each one of the tasks included in each block. Aside from this, the implementation in a behavioural tree has provided a modular structure to modify the process easily using a graphical GUI. For all these reasons it can be affirmed that the objective of generating a modular solution that can be afterwards reused for other projects has been achieved too. Despite these positive achievements, the method is not as robust as expected and still presents some critical flaws. The system is very sensitive to errors in perception and navigation that make the picking and serving trajectory generation algorithms fail in finding suitable plans to perform the movements. These errors get magnified when the inverse kinematics computation functions use this erroneous positions to compute the final configurations for grasping and serving. The arm manipulation package is the more sensitive to
Mobile manipulation with the TIAGo robot: perception and interaction page 71 these errors and also the most critical to assure a correct completion of the waiter process. On the other hand, the computation of the inverse kinematics itself is also a problem as seen in the conclusions for arm manipulations. As the number of solutions provided by the library is limited and depends on the value of the redundant joints the configurations obtained to grasp a can might be very far away from the one obtained to serve it afterwards generating a lot of problems in the trajectories that lead to an execution failure. This mismatch between picking and serving configurations also diminish the robustness of the method as they reduce the number of scenarios in which these problems will not appear. The complexity of the scene presented to the robot is still too relevant to assure a successful completion of the process. Although the sensing capabilities are ready to perceive picking tables very crowded with cans, the path planning capabilities are very limited and the cans placed in very complicated regions as well as the presence of to many cans can lead to the impossibility of finding a path to pick the desired can which leads to failing in completing the process. Summing up, the whole methods has been proven to be suitable to perform the waiter task assigned and all the blocks and methods generated have been integrated and combined successfully to generate a proper solution. The problem is the robustness of the methods as all the errors previously detailed can make the whole process fail. The next step should be to enhance the solution in order to make it more robust against all these errors and uncertainties but the base method generated is proven to be a good foundation to keep on developing the solution.
page 78 Report [16] S. G. Johnson, “NLopt git repository,” Last access: 09/06/2019. [Online]. Available: https://github.com/stevengj/nlopt [17] M. Colledanchise, “BehaviorTree basics,” Last access: 23/05/2019. [Online]. Available: https://www.behaviortree.dev/bt_basics/ [18] ——, “BehaviorTree XML format,” Last access: 16/06/2019. [Online]. Available: https://www.behaviortree.dev/xml_format/
Mobile manipulation with the TIAGo robot: perception and interaction page 79 A Code Repository All the software packages developed have been uploaded into the IOC robotics lab repository. The link is presented next. https://gitioc.upc.edu/xavier.garcia/TIAGO_waiter The repository includes a README file explaining the structure of all the packages and a summary of the user guide in order to run the methods developed. A link to a Wiki page with all the videos of the experiments is included next as mentioned in the section 4. https://gitioc.upc.edu/xavier.garcia/TIAGO_waiter/wikis/home
Mobile manipulation with the TIAGo robot: perception and interaction page 81 B XML file of the project Listing 8: XML file that describes the behavior of the Behavior Tree nodes that defines the operation of this project. 1<root main_tree_to_execute="BehaviorTree"> 2<!---------------------------------------> 3<BehaviorTree ID="ASK USER TO CHOOSE DRINK"> 4 5<Sequence> 6<RetryUntilSuccesful num_attempts="1"> 7<Sequence> 8<Action ID="detectCans"/> 9<Condition ID="isThereSomeCan"/> 10 </Sequence> 11 </RetryUntilSuccesful> 12 <Action ID="askUserForCanChoice"/> 13 <Action ID="confirmCanSelected"/> 14 </Sequence> 15 16 </BehaviorTree> 17 <!---------------------------------------> 18 <BehaviorTree ID="BehaviorTree"> 19 20 <RetryUntilSuccesful num_attempts="1"> 21 <Inverter> 22 <Sequence> 23 <SubTree ID="OPEN BAR"/> 24 <SubTree ID="SERVING TABLE USER INTERACTION"/> 25 <SubTree ID="GO TO SENSING TABLE"/> 26 <SubTree ID="ASK USER TO CHOOSE DRINK"/> 27 <SubTree ID="GRASP CAN"/> 28 <SubTree ID="GO TO SERVING TABLE"/> 29 <SubTree ID="SERVE DRINK"/> 30 </Sequence> 31 </Inverter> 32 </RetryUntilSuccesful> 33 34 </BehaviorTree> 35 <!---------------------------------------> 36 <BehaviorTree ID="GO TO SENSING TABLE"> 37 38 <Sequence> 39 <RetryUntilSuccesful num_attempts="1"> 40 <Fallback> 41 <Sequence> 42 <Action ID="prepareToGoToSensingTable"/>
page 82 Report 43 <RetryUntilSuccesful num_attempts="1"> 44 <Sequence> 45 <Action ID="goToSensingTable"/> 46 <Condition ID=" isRobotLocalizedSensingTable"/> 47 </Sequence> 48 </RetryUntilSuccesful> 49 </Sequence> 50 <Inverter> 51 <Condition ID="isGoToSensingTableSolved"/> 52 </Inverter> 53 </Fallback> 54 </RetryUntilSuccesful> 55 <Condition ID="isRobotLocalizedSensingTable"/> 56 </Sequence> 57 58 </BehaviorTree> 59 <!---------------------------------------> 60 <BehaviorTree ID="GO TO SERVING TABLE"> 61 62 <Sequence> 63 <RetryUntilSuccesful num_attempts="5"> 64 <Fallback> 65 <Sequence> 66 <Action ID="prepareToGoToServingTable"/> 67 <RetryUntilSuccesful num_attempts="1"> 68 <Sequence> 69 <Action ID="goToServingTableEnd"/> 70 <Condition ID=" isRobotLocalizedServingTable"/> 71 </Sequence> 72 </RetryUntilSuccesful> 73 </Sequence> 74 <Inverter> 75 <Condition ID="isGoToServingTableSolved"/> 76 </Inverter> 77 </Fallback> 78 </RetryUntilSuccesful> 79 <Condition ID="isRobotLocalizedServingTable"/> 80 </Sequence> 81 82 </BehaviorTree> 83 <!---------------------------------------> 84 <BehaviorTree ID="GRASP CAN"> 85 86 <RetryUntilSuccesful num_attempts="1">
Mobile manipulation with the TIAGo robot: perception and interaction page 83 87 <Sequence> 88 <Action ID="prepareToGraspCan"/> 89 <RetryUntilSuccesful num_attempts="1"> 90 <Fallback> 91 <Action ID="computeInverseKinematics"/> 92 <Inverter> 93 <Action ID="correctPositionIK"/> 94 </Inverter> 95 </Fallback> 96 </RetryUntilSuccesful> 97 <Action ID="prepareToComputePath"/> 98 <RetryUntilSuccesful num_attempts="1"> 99 <Fallback> 100 <Action ID="computePath"/> 101 <Inverter> 102 <Action ID="correctPositionPath"/> 103 </Inverter> 104 </Fallback> 105 </RetryUntilSuccesful> 106 <Action ID="tryToGraspCan"/> 107 </Sequence> 108 </RetryUntilSuccesful> 109 110 </BehaviorTree> 111 <!---------------------------------------> 112 <BehaviorTree ID="OPEN BAR"> 113 114 <Sequence> 115 <Action ID="openBar"/> 116 </Sequence> 117 118 </BehaviorTree> 119 <!---------------------------------------> 120 <BehaviorTree ID="SERVE DRINK"> 121 122 <Sequence> 123 <Action ID="serveDrink"/> 124 <Action ID="closeBar"/> 125 </Sequence> 126 127 </BehaviorTree> 128 <!---------------------------------------> 129 <BehaviorTree ID="SERVING TABLE USER INTERACTION"> 130 131 <Sequence> 132 <Action ID="goToServingTable"/>
page 84 Report 133 <Action ID="askForDrinks"/> 134 </Sequence> 135 136 </BehaviorTree> 137 <!---------------------------------------> 138 <BehaviorTree ID="SETUP"> 139 140 <Sequence> 141 <Action ID="initNodes"/> 142 <Action ID="readParameters"/> 143 <Action ID="transformStamped"/> 144 <Action ID="headTowardUser"/> 145 </Sequence> 146 147 </BehaviorTree> 148 <!---------------------------------------> 149 <TreeNodesModel> 150 <SubTree ID="ASK USER TO CHOOSE DRINK"/> 151 <SubTree ID="GO TO SENSING TABLE"/> 152 <SubTree ID="GO TO SERVING TABLE"/> 153 <SubTree ID="GRASP CAN"/> 154 <SubTree ID="OPEN BAR"/> 155 <SubTree ID="SERVE DRINK"/> 156 <SubTree ID="SERVING TABLE USER INTERACTION"/> 157 <SubTree ID="SETUP"/> 158 <Action ID="askForDrinks"/> 159 <Action ID="askUserForCanChoice"/> 160 <Action ID="askUserToSolveProblem"/> 161 <Action ID="closeBar"/> 162 <Action ID="computeInverseKinematics"/> 163 <Action ID="computePath"/> 164 <Action ID="confirmCanSelected"/> 165 <Action ID="correctPositionIK"/> 166 <Action ID="correctPositionPath"/> 167 <Action ID="detectCans"/> 168 <Action ID="goToSensingTable"/> 169 <Action ID="goToSensingTableFailure"/> 170 <Action ID="goToServingTable"/> 171 <Action ID="goToServingTableEnd"/> 172 <Action ID="headTowardUser"/> 173 <Action ID="initNodes"/> 174 <Action ID="initializeVariables"/> 175 <Condition ID="isCanGrasped"/> 176 <Condition ID="isGoToSensingTableSolved"/> 177 <Condition ID="isGoToServingTableSolved"/> 178 <Condition ID="isPreviousDrinkServedCorrecly"/>
Mobile manipulation with the TIAGo robot: perception and interaction page 85 179 <Condition ID="isRobotLocalizedSensingTable"/> 180 <Condition ID="isRobotLocalizedServingTable"/> 181 <Condition ID="isThereSomeCan"/> 182 <Condition ID="isValidPath"/> 183 <Action ID="openBar"/> 184 <Action ID="prepareToComputePath"/> 185 <Action ID="prepareToGoToSensingTable"/> 186 <Action ID="prepareToGoToServingTable"/> 187 <Action ID="prepareToGraspCan"/> 188 <Action ID="readParameters"/> 189 <Action ID="serveDrink"/> 190 <Action ID="transformStamped"/> 191 <Action ID="tryToGraspCan"/> 192 </TreeNodesModel> 193 <!---------------------------------------> 194 </root>
Mobile manipulation with the TIAGo robot: perception and interaction page 87 C Pose estimation algorithm In this appendix section it will be explained the steps to follow in order to get the position of the detected objects with the use of the perception module. All the calculus below has been extracted from Modelling, Planning and Control book [10] and are implemented inside perception module in pose_estimation.cpp file in a function called CanDetector::poseEstimation. C.1 The feature vector Let {B}be the world reference frame and Tb cbe the transformation that defines the reference frame of a camera w.r.t. {B}. If P= [px, py, pz]Tis a point and ˜ p= [pT,1]Tits generalized representation, then the coordinates from the reference frame of the camera are: ˜ pc= [pc x, pc y, pc z,1]T=Tb c˜ p(9) The perspective transformation of a camera with distance focus fleads to the following values (Fig. 42): Xf=−fpc x pc z Yf=−fpc y pc z ,(10) And considering a “virtual" image plane located at zc=fand defining X=pc x pc z and Y=pc y pc z , the expressions in Eq. (10) become: Xf=fX Yf=fY(11) The representation in the virtual image plane of point [Xf,Yf]depends on the spatial sampling (the spatial sampling units are the pixels). Pixel coordinates are obtained through a scaling process: XI=fαxX+X0 YI=fαyY+Y0,(12) with X0,and Y0,being the offsets of the origin in the pixel coordinate system. This can be expressed in matrix form as: XI YI 1 = fαx0X0 0fαyY0 0 0 1 X Y 1 = Ω X Y 1 (13)
page 94 Report D.2 Orientation correction This optimization process is in charge of correcting just the orientation of the cans, unlike the previous correction this is focused just in the orientation of the can. In order to do it, a series of steps are applied inside a function called angle_correction inside file pose_estimation.cpp in perception module. This function receives the following parameters as input: •Tr c:xtion_rgb_optical_frame w.r.t base_footprint frame • real center: center of the can computed by the pose estimation algorithm. • pixelated center: position of the center of the can in image coordinates (pixels). •s1: point s1in image coordinates (pixels) • cam: intrinsic camera parameters • alpha (α): angle formed by s1and s3points taking into account the correction computed in pose correction. Now, the function follows the steps listed below to apply angle correction: • A lower and an upper bounds are defined for yaw orientation. • Necessary data to use the objective function is defined as ObjectiveFunctionDataCorrection data. –data.cam = cam [intrinsic camera parameters] –data.T_camera_world = T_world_camera.inverse() –data.s1 = s1 [s1 point in image coordinates] –data.s_center = s_center [center of the can in image coordinates] –data.canCenter = centerCan [real position of the center of the can computed by the pose estimation algorithm] • Apply objective function: –Compute the center of the can in camera coordinates Pc cc =Tc w∗Pw cc –Compute S1point in the camera coordinates. yaw =α[this is the value to optimize]
Mobile manipulation with the TIAGo robot: perception and interaction page 95 Sw 1= Pw cc.x +r∗cos(yaw) Pw cc.y +r∗sin(yaw) Pw cc.z 1 Sc 1=Tc w∗Sw 1 where r= 0.026 [m]. This is the distance in meters from the center of the can to the coplanar points. In this case is a circular object, so the distance from the center to these points is the radius, 0.026 [m] for a standard soda can. –Compute projection of center of the can and S1point in image plane, being s1in image coordinates. In order to compute this projection it is necessary to apply the equations (9), (10), (11), (12) and (13) from appendix C –Correct s1according to the difference between the center of the can compute in image coordinates computed by the image processing algorithm (cip) and the center of the can that comes from the projection in image plane of the position estimated (cps). s1c=s1+ (cip −cps) –Compute vswith the vector from center (cip) to s1. vs=s1−cip –Compute vpwith the vector from s1cto center (cip) vp=s1c−cip –Compute angle between vectors. This angle should be minimized. α=acos < vs, vp> kvsk vp !