scieee AI-readable full text Open interactive document viewer

High level programmable and flexible industrial robotized cells

Marcos André Magalhães Ferreira

Full text

High Level Programmable and Flexible Industrial Robotized Cells Marcos Ferreira Doctoral Program in Electrical and Computer Engineering Supervisor: Ant´onio Paulo Gomes Mendes Moreira Co-Supervisor: Joaquim Norberto Cardoso Pires da Silva A thesis submitted for the degree of Doctor of Philosophy (PhD) January 2014 Abstract Industrial manipulators play a key role on major production lines. They are one of the most powerful automation solutions for flexible mass production, delivering efficiency and quality at reduced prices. In an entirely different scene, there are the small and medium enterprises (SMEs), which mostly rely on high skilled labour, delivering less quantity but increased customization. In the face of modernization, and to sustain global competitiveness, SMEs are increasingly adopting robotized solutions. Yet, despite of the numerous researches and contributions to improve human-robot interface, programming an industrial robot is still a very technical and time-consuming challenge. On this scenario, this thesis sets focus on developing new means of intuitive and high level robot programming. Specifically, a new method for robot programming by demonstration is proposed: the factory operator demonstrates a given task, and the robot is automatically programmed to mimic the human operation. This is a framework for human-robot skill transfer, since the know-how of the operator is translated into robot language. Additionally, the final solution is designed and optimized for maximum industrial applicability: use of low-cost hardware, low impact on the industrial process, high success rate and accuracy, fast (real-time) output. The proposed framework puts together a stereoscopic vision module and a luminous marker. Unlike equivalent motion tracking solutions available, this one uses visible markers. Using a synchronization technique known as the sincrovision, cameras and markers and simultaneously triggered. This results in very accurate and robust measures, even under harsh industrial environment conditions. A collection of algorithms, that take advantage of the marker shape and the colour of the markers, is able to reconstruct the path in six degrees of freedom (6 DoF) — position and orientation. 3D B- Splines and quaternion splines are used to smooth the tracked path before generating the robot program. A prototype of the system was implemented at an industrial demonstrator, for a spray painting application. The operator was able to demonstrate several painting trajectories using a minimal software interface to start and stop the procedure. Immediately after demonstration (negligible post-processing time), the robot successfully imitated the human moves, and the results were validated by the painters. The company, Flupol, can now instantaneously transfer to the robot the 25 years experience of the oldest painter. Resumo Os manipuladores industriais tˆem um papel preponderante nas grandes linhas de produ¸c˜ao. S˜ao uma das solu¸c˜oes mais avan¸cadas tendo em vista o conceito de produ¸c˜ao em massa flex´ıvel, produzindo com eficiˆencia e qualidade a um custo reduzido. Num outro cen´ario completamente diferente encontram-se as pequenas e m´edias empresas, PMEs, que dependem fundamentalmente da m˜ao de obra qualificada dos seus trabalhadores, produzem em menor quantidade mas com maior grau de customiza¸c˜ao. Na perspectiva de se modernizarem, e de forma a manterem a competitividade no mercado global, as PMEs tˆem vindo cada vez mais a apostar na robotiza¸c˜ao dos seus processos. Contudo, apesar de toda a investiga¸c˜ao em torno da cria¸c˜ao de novos m´etodos para melhorar o interface homem-robˆo, a programa¸c˜ao de um manipulador industrial ainda requer um elevado n´ıvel de conhecimento t´ecnico para al´em de ser uma tarefa morosa. ´ E neste cen´ario que esta tese pretende contribuir, desenvolvendo m´etodos intuitivos para a programa¸c˜ao de robˆos industriais. Mais especificamente, ´e proposto um novo m´etodo para programa¸c˜ao por demonstra¸c˜ao: o operador humano demonstra uma determinada tarefa e o robˆo ´e automaticamente programado de modo a que consiga imitar o movimento humano. No seu todo, esta solu¸c˜ao consiste numa framework para transferˆencia de know-how do operador humano para o robˆo. Mais ainda, a solu¸c˜ao final ´e projetada e otimizada do ponto de vista da aplicabilidade industrial: ´e usado equipamento de baixo custo, o impacto no processo ´e m´ınimo, apresenta elevada exatid˜ao e taxa de sucesso, o resultado ´e obtido em tempo real. Aframework proposta nesta disserta¸c˜ao engloba um sistema de vis˜ao estereosc´opica e um marcador luminoso. Ao contr´ario de algumas solu¸c˜oes dispon´ıveis para seguimento de movimento, esta ´e baseada em marcadores na gama do vis´ıvel. Usando uma t´ecnica de sincroniza¸c˜ao denominada por sincrovision, as cˆamaras e o marcador s˜ao acionados simultaneamente, permitindo assim uma leitura precisa e robusta do marcador, mesmo em condi¸c˜oes adversas t´ıpicas de um ambiente industrial. Um conjunto de algoritmos otimizados para a forma e cor dos marcadores permite fazer uma reconstru¸c˜ao da trajet´oria com seis graus de liberdade (6 DoF) — posi¸c˜ao e orienta¸c˜ao. Antes da gera¸c˜ao do c´odigo para o manipulador industrial, a trajet´oria ´e ainda suavizada usando B-Splines em 3D e splines no espa¸co dos quaterni˜oes. Um prot´otipo do sistema desenvolvido foi implementado num demonstrador industrial, numa aplica¸c˜ao de pintura por pulveriza¸c˜ao. O operador foi capaz de demonstrar v´arias trajet´orias de pintura usando, para tal, uma interface de software onde tem de indicar apenas o in´ıcio e fim do processo de demonstra¸c˜ao. Imediatamente ap´os a demonstra¸c˜ao (o tempo de p´os-processamento ´e praticamente nulo), o robˆo imitou com sucesso o movimento humano, tendo os pr´oprios pintores validado a qualidade da execu¸c˜ao. A empresa onde se realizaram os ensaios, Flupol, tem agora a possibilidade de transferir os 25 anos de experiˆencia do seu mais antigo pintor para um manipulador industrial, conseguindo-o fazer de forma praticamente instantˆanea. When you make the finding yourself - even if you’re the last person on Earth to see the light - you’ll never forget it. Carl Sagan To my parents... viii Acknowledgements First and foremost I must thank my supervisors, Professor A. Paulo Moreira and Professor Norberto Pires, for their guidance. To Professor Norberto, whose extensive and remarkable work on the field of robotics served as an inspiration for my research. To Professor A. Paulo, to whom I owe a great debt of gratitude for all this years of advice, support and friendship. His enthusiasm for research, his liveliness and his faithfulness in my work were a major motivation for me. I would like to thank everyone in the Robotics and Intelligent Systems Unit (Robis) of INESC-TEC. They are the most amazing colleagues and they make of Robis laboratory the most interesting place to work at. A special word of gratitude for my labmates Heber Sobreira, Miguel Pinto, Filipe Santos, Andr´e Figueiredo, Lu´ıs Rocha and Germano Veiga for sharing their knowledge and friendship over these past years. My sincere thanks to Lu´ıs Rocha for all the help, the availability, and for enduring many hours of frustration setting up the industrial solution. Furthermore, I’m also grateful to Germano Veiga for all the insightful discussions, for sharing his experience, and for taking time to examine my work and questioning it. I would also like to give my sincerest thanks to my friends Paulo Malheiros and Professor Paulo Costa. To Paulo Malheiros, I thank him for all his support and for being the most helpful labmate. And also, because I was able to develop my research upon the basis of his work. To Professor Paulo Costa, I thank him for all the guidance, the most useful suggestions and ideas, and for all those late night discussions which proved to be utterly valuable. My sincere appreciation and gratitude to Jos´e Bandeira, Pedro Bandeira and Flupol. They believed and invested in my research since the very CONTENTS xvi List of Figures 1.1 Industries purchasing robots . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 IndustrialRobots............................... 3 2.1 TeachPendants................................ 15 2.2 Glove ..................................... 21 2.3 Inputdevices ................................. 23 3.1 Frames..................................... 27 3.2 Frames translation and rotation . . . . . . . . . . . . . . . . . . . . . . . 28 3.3 Homogeneous Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.4 ImageNotation................................ 34 3.5 Camera Pinhole Model............................ 35 3.6 Stereoscopy .................................. 37 3.7 CalibrationPattern.............................. 40 3.8 Sincrovision Timings............................. 41 3.9 Sincrovisioneffect .............................. 42 4.1 Camera and Stereo Calibration Using the Industrial Robot . . . . . . . 49 4.2 Precision/Repeatability vs Accuracy . . . . . . . . . . . . . . . . . . . . 51 4.3 Icosahedron: 3D shape, CAD model and real marker . . . . . . . . . . . 53 4.4 Icosahedron/Dodecahedron properties . . . . . . . . . . . . . . . . . . . 55 4.5 Markerapplications ............................. 56 4.6 MarkerElectronics.............................. 58 4.7 Stereo Capture and Normal Photo . . . . . . . . . . . . . . . . . . . . . 59 4.8 HSVcolormodel............................... 60 4.9 Colour classification based on HSV . . . . . . . . . . . . . . . . . . . . . 62 xvii LIST OF FIGURES 4.10 HSV Calibration Example and Detection . . . . . . . . . . . . . . . . . . 63 4.11 Pixel/Cluster Correspondence By Colour And Epipolar Line Constraint 65 4.12Multiplematches............................... 66 4.13 3D Scene with LEDs and a Sphere . . . . . . . . . . . . . . . . . . . . . 67 4.14 Sphere Fitting — 3D representation . . . . . . . . . . . . . . . . . . . . 71 4.15 The Dodecahedron Coloured Graph . . . . . . . . . . . . . . . . . . . . 74 4.16 Synchronization across images and devices . . . . . . . . . . . . . . . . . 79 4.17 Piecewise Linear Approximation of Noisy Path . . . . . . . . . . . . . . 80 4.18 B-Spline Cubic Basis Function . . . . . . . . . . . . . . . . . . . . . . . 82 4.19 B-Spline smoothing and a real path in a spray painting application . . . 86 4.20 lerp and Slerp interpolation ......................... 88 4.21 Slerp and Squad interpolation for a path of rotations . . . . . . . . . . . 90 4.22 Trajectory Segmentation Based on I/O Changes . . . . . . . . . . . . . 91 4.23 Moving linearly to each point . . . . . . . . . . . . . . . . . . . . . . . . 92 4.24 Segmentation of backtracks using 4D line fitting . . . . . . . . . . . . . 95 4.25 Trajectory Segmentation in Linear Movements . . . . . . . . . . . . . . 96 4.26 Tweaking the Robot Trajectory Controller Tolerance . . . . . . . . . . . 98 4.27 Automatic Robot Program Generation . . . . . . . . . . . . . . . . . . . 99 5.1 Human Painter in Flupol Coating Cell . . . . . . . . . . . . . . . . . . . 102 5.2 Robot in Flupol Coating Cell . . . . . . . . . . . . . . . . . . . . . . . . 103 5.3 Marker Attached to the Industrial Spray Painting Gun . . . . . . . . . . 103 5.4 Two Camera Arrangement for Stereoscopy . . . . . . . . . . . . . . . . . 104 5.5 CAD Model of the Calibration Tool . . . . . . . . . . . . . . . . . . . . 106 5.6 Error variation in the Xaxis ........................ 109 5.7 Error variation in the Yaxis ........................ 109 5.8 Error variation in the Zaxis ........................110 5.9 HSV Colour Classes Calibration . . . . . . . . . . . . . . . . . . . . . . . 111 5.10ABakingTray ................................ 116 5.11 B-Spline Smoothing of a Baking Tray Painting Path . . . . . . . . . . . 117 5.12 B-Spline vs Piecewise Linear Side View . . . . . . . . . . . . . . . . . . 118 5.13 B-Spline vs Piecewise Linear Opposite View . . . . . . . . . . . . . . . . 118 5.14 B-Spline vs Piecewise Linear X-Y view . . . . . . . . . . . . . . . . . . . 119 xviii LIST OF FIGURES 5.15 B-Spline Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 5.16 Sampling of the B-Spline at the Same Frequency of the Tracking . . . . 121 5.17 Sampling of the B-Spline at 2 times the Tracking Frequency . . . . . . . 122 5.18 Sampling of the B-Spline at 4 times the Tracking Frequency . . . . . . . 123 5.19 Sampling of the B-Spline at 8 times the Tracking Frequency . . . . . . . 124 5.20 Path decomposed into X(t),Y(t) and Z(t) ................ 125 5.21 B-Spline smoothing of X(t),Y(t) and Z(t) ................ 126 5.22 Zoom on B-Spline Smoothing of X(t),Y(t) and Z(t)........... 127 xix LIST OF FIGURES xx List of Tables 4.1 Cluster data after processing images from both cameras . . . . . . . . . 64 4.2 Marker Position Estimation . . . . . . . . . . . . . . . . . . . . . . . . . 69 4.3 Dodecahedron Vertices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 5.1 Calibration error on x,yand zaxis .................... 107 5.2 Calibrationerror ............................... 107 5.3 Number of misclassification of image clusters sorted by colour . . . . . . 112 5.4 Evaluation of the position and orientation estimation . . . . . . . . . . . 113 5.5 Marker position error on x,yand zaxis.................. 114 5.6 Markerposeerror............................... 115 5.7 Sampling of the B-Spline Curve . . . . . . . . . . . . . . . . . . . . . . . 122 5.8 Processing times for every stage of the motion demonstration . . . . . . 129 xxi LIST OF TABLES xxii Chapter 1 Introduction 1.1 On the use of industrial robotic manipulators Industrial robotic manipulators are, as of today, a fully grown commercial off-the-shelf product that integrate the largest and most complex manufacturing facilities worldwide. These machines are taken as the ultimate automation tool: A powerful and robust mechanical solution, fit to most demanding operations — heavyweight cargo lifting and handling, ability to sustain hazardous environments, full 24h work-shift. Top grade electronics using state of the art sensors and motion controllers — high precision, high production quality and speed; integration with the most recent vision, laser and force sensing technologies to satisfy the most heterogeneous systems. Dedicated software and user interfaces — the manipulators can be reprogrammed on-site, adapted to different work objects, configured with different grippers and tools; in short, they can be recycled on and on through a number of distinct applications. To these advantages must also be added the cost. As the price varies with the target application and robot payload, the robotic market offers solutions for welding (arc and spot), painting, handling, assembly, palletizing, packing, etc, with payloads ranging from a few Kg to more than a ton. Choosing the right robot for a given application, and for the right price is simple while avoiding expensive “home-made” or overrated machines. 1 1. INTRODUCTION Robots are the way to go in an ever increasing competitive market. But is it always so? Precision, quality and robustness all come with the pack, i.e they are bought with the industrial machine. Flexibility, however, it is an entirely different matter that may cost huge extras. In fact, that stands true on one face of today’s industry: the large scale production, the large companies, the major markets. As depicted in Fig. 1.1, the electrical/electronics (PCs, TVs, cellphones) industry, rubber/plastic, metal/machinery and particularly the automotive industries are the most relevant purchasers of industrial robots. Figure 1.1: Industries purchasing robots - Estimated wordwide annual supply (taken from [1]) Manipulators fit perfectly to these environments: production resumes for months, sometimes even years — in the mean time, no reprogramming is needed, only casual maintenance; large factories are build from scratch, supported by fine design (with virtual models), with each step of the production stage carefully studied and identified — it is known a priori how many robots, which task they are appointed to, the workspace and its layout; there are experienced programmers that can develop machine code and there are expensive simulation software products to aid them. The bet on robots is 2 1.1 On the use of industrial robotic manipulators certain and undisputed. Flexibility, in this scenario, means that robots can do the tedious and repetitive tasks humans would have to do otherwise; means calling in the programmer, weeks apart, to debug and correct the manipulation procedure or even change it completely to something else, instead of having to hire and teach an human operator for days. The 2012 annual report [1] from the International Federation of Robotics (IFR) shows the increasing use of industrial robots (Fig. 1.2, since the 2009 crisis and up until 2015(predicted)). Apart from the automotive industry, which has always been the major growth stimulator on process robotization, all other sectors are creating conditions to apply manipulators to their processes as they are seen as the prime tool for modernization, competitiveness and improvement of quality of work for human operators. Figure 1.2: Industrial Robots - annual supply (taken from [1]) What’s then on the other face? The small batch production, the most limited resources, companies with just a few tens of employees, the small and medium enterprises (SMEs). Are robots of as much importance as on large companies? Do they bring the same benefits? It is believed that SMEs are the economy driving force [2]; it is particularly true on rather small countries like Portugal. For years, SMEs relied on skilled labour and scarcely automated processes, but the market has changed; technol- 3 1. INTRODUCTION parts travel on a conveyor and are scanned by the laser; then, a machine learning algorithm identifies the part and uploads the correct painting program into the robot controller. With this system it was expected that both the program generation and the reconfiguration for different pieces would occur in a simplified manner without using the robot teach pendant. Nonetheless, it was concluded that the generation of accurate painting programs for complex shapes using CAD would be too difficult. So, the pursuit for means of collecting the know-how of the painter begun, and with that a simpler way to generate robot programs for any shape. 1.4 Thesis Outline •Chapter 1 serves as the introductory chapter. It presents the panorama of using robotic manipulators at the industry level, particularly on SMEs. Discussion follows with the challenges of interfacing these machines and to allow factory operators easy interaction with them. The problem addressed by this thesis is exposed together with the proposed solution and major goals. The industrial demonstrator is described and framed with the research aims. •Chapter 2 presents a review on the state of the art on programming by demonstration, human motion capture and intuitive human-robot interfaces. A relevant set of contributions has been selected to provide insight on current research work along this stream. In addiction, they are also meant to support and justify the line of research of this thesis. •Chapter 3 provides the most basic tools for the understanding of the remaining of the document. It defines the notation used in equations and schemes, and presents some fundamental notions on cameras, stereoscopy, orientation of rigid bodies, etc. Also, some trivial algebraic relations are defined so that they can be skipped later and make the development sections more readable. •Chapter 4 is the grand development chapter. It presents the design, implementation and methodology that make up the proposed solution to a novel human robot skill transfer framework. The chapter itself follows the structure of the motion imitation framework: starts with the sensing component, the module that deals 10 1.4 Thesis Outline with capturing human moves, down to replaying those exact movements with an industrial robot. •Chapter 5 describes the implementation of the proposed solution in the industrial demonstrator. It comprises the installation and test routines that validate the developed framework. System precision is accessed and discussed. •Chapter 6 provides the conclusions taken from this research work: a final word on the achievements, the novelty of the system and where it excels. Also, some lines of thought are addressed to future research work: how the framework can be improved, adapted or used for other ends. 11 1. INTRODUCTION 12 Chapter 2 Related Work This chapter presents the state of the art methods and achievements on robot programmingby-demonstration. The universe of human-robot interaction is vast and it is hard to cover all the current streams of research in the area. Brenna Argall et al. [5] and Geoffrey Biggs et al.[6] offer a survey on robotics learning/programming from demonstration. According to the author of [5], the work on this thesis is best categorized as an imitation learning process. On this line, this literature review sets focus primarily on motion and tasks demonstration, which provide the necessary data for a robotic imitation. Also, the main goal is to achieve a system that allows transferring skill from a factory operator over to an industrial manipulator and, for that reason, this review is restricted to the interface with industrial robots. Within this shorter scope, the reader starts by finding references on the actual methods for robot programming, mainly commercial-off-the-shelf products as simulation software and the teach pendant (which is the default programming tool provided by robot manufacturers). From here, discussion follows through contributions found on programming by motion demonstration. In-between, a review on CAD based programming takes place since this is a major stream of research on the field of intuitive robot interfaces. On programming by demonstration there are also different approaches: gesture recognition, lead through programming and actual motion capture for robot playback. Each of those is discussed and, for the sake of completeness, a few contributions on humanoid/mobile robot interfaces are also analysed. Although these are not the type of platforms that 13 2. RELATED WORK this research aims to interface, some knowledge can be retrieved on limited sections of such contributions: methods and technologies for motion capture (which are commonly used in humanoid research and to build virtual reality models of humans), and methods for robot path planning, trajectory smoothing and collision avoidance (which are also used in mobile robotics). 2.1 Programming Industrial Robots: the Teach Pendant and Simulators Industrial manipulators have their vary own programming language. Unfortunately, each brand has developed their specific version making it hard to develop an universal method or tool to program these machines. Another drawback of this scenario stands on the costumer side, who is forced to stick to the same manufacturer in order to prevent their operators to have to learn how to work with/program different machines. The first and most used method to teach industrial robots are the teach pendants — Fig. 2.1. The reasons are obvious: it is the default tool shipped with every robot, it comes with no extra costs, manufacturers support is guaranteed, it is well established as it has been around since the first manipulators. Furthermore, these tools have access to all the robot functionalities, are designed to endure industrial environment and provide an easy-to-learn interface for the final user. Ease of learn, however, does not translate into ease of use or, more importantly, into efficiency. The method of programming through the teach pendant is tedious, time consuming and far from intuitive, mostly to the expected end user: an inexperienced factory operator. Through the pendant, the user moves the robot to the desired position, records the point, defines the type of movement, velocity and several other parameters; all those steps for a single point, repeated to every point that makes the desired path. In the end, the resulting program can hardly be used for anything else other than the task it was first meant to; adaptation or upgrades cost as much as redoing from scratch. In the SME scenario, specially with small series production, this is not a practicable solution. Therefore, the first approach on improving human-robot interaction has been on the enhancement of these existing interfaces. At the teach pendant level, KUKA has integrated a 6-D mouse, developed by the German Aerospace Center for space robotics projects [7]. Renzo Calcagno et al. [8] present a wireless 14 2.1 Programming Industrial Robots: the Teach Pendant and Simulators Figure 2.1: Teach Pendants - Each manufacturer has its own layout for the teach pendant 15 2. RELATED WORK pendant aiming to improve flexibility and usefulness in tight shop floors but also to provide means for distributed supervision and multi-unit control. Even though these steps enrich indeed user interface, the programming method is still the same as are the proprietary programming languages. In a fairly recent study, as of 2011 (Lei Wang et al. [9]), it is obvious that the research community still seeks to overcome the limitations of such reality; in this case, the authors use case-based-reasoning to segment parts of the machine code in order to reuse them in similar applications avoiding to rewrite the code or to build a full point-by-point path all over again. Similar approaches dated old can also be found: replacing the code editor and interface by an icon-based flowchart [10] and the development a set of modular robot programs that adapt to different shapes provided the user is able to extract geometric data of the work-pieces [11] — then, a program variant is automatically created. All of these concepts cannot relinquish a skilled programmer with experience in robot specific language nor provide a way for a common factory operator to intuitively interact with the manipulator. Another common reality of robot programming nowadays are the simulators. Some major dealers of industrial manipulators have their own simulation software, such is the case of RoboSim from Motoman and RobotStudio from ABB. Simulators provide the ability to test machine programs offline, saving testing time along with other key advantages: visual feedback, improved control over robot motion, security analysis, collision avoidance, tool/robot dimensioning, cell layout definition, etc. To cite a few, there are some projects that take full advantage of these virtual reality tools and try to further improve their usefulness and flexibility as reported by Xiongzi Li et al. [12] (the authors import CAD models of the pieces to generate and validate a painting path) and by Liwei Qi et al. [13](the paper analyses the reasons why robot simulations and offline programming are far from intuitive). One of the greatest drawbacks in simulations is the need of an accurate representation of the real world scene: representing the robot, the workspace, the work-pieces and every layout details with low precision grounds the effectiveness and interest of offline simulation. Also, the volumetric inaccuracy of the robot may compromise the virtual→real transformation: even if the virtual environment has accurate models, the robot may fail to respect the coordinates and still fail to deliver. Xiongzi Li et al. [14] present a solution for calibration between virtual and real scene increasing the rate of success when mapping simulated programs into the physical robot — [12],[13] and [14] all use ABB’s RobotStudio. The work of 16 2.2 Taking advantage of CAD Haixiang Yu et al. [15] is conducted over Motoman’s MotoSim, and advocates the use of simulation based programming in a palletizing application for a safe and efficient output. Each and every of the discussed researches assume the default tools for robot programming and try to build more productive and/or intuitive layers on top of it though they do not close the gap between man and machine. Before us remains the scenario where the highly skilled (and expensive) programmer has to code for manipulators. Although the teach pendant and the simulators are indeed the de facto standard of industrial robot programming, while the former is not easy to use nor time efficient, the latter are dizzyingly expensive. Again, for SMEs, that is not an affordable solution. Besides, there’s still no away to take the operator expertise and send it to a robot. 2.2 Taking advantage of CAD On a similar line to simulation and modelling tools comes the offline programming using CAD. This stream alone has received notorious attention by researchers and can be considered one of the major fields of human-robot interaction. Since companies are increasingly resorting to CAD software to design their products, this is an existing valuable asset that was waiting to be explored. Through the 3D data on CAD files it is possible to generate robot programs that can uniformly cover the object surface (useful for painting/coating applications), move along the contour (grinding and polishing tasks) or to plan ahead complex trajectories for collision free operations. Contributions to this area of expertise started long ago; Grier Lin et al., back in 1995, have demonstrated the capabilities of CAD for object recognition and adaptive pick up applications with manipulators [16]: the authors used cameras to capture images from the workbench which where compared to CAD drawings for proper identification; robot programs where then generated to grab the objects in the messy workbench. On an extension of that application, the same authors used the CAD data, neural networks and torque sensors to further improve the grasping capabilities of the robot and the compensate position uncertainty [17]. In the fields of industrial painting and coating, CAD has also served numerous researches; Chen Heping is an author who provided a considerable amount of contributions in this area: [18] and [19] are examples where the author seeks methods for 17 2. RELATED WORK automatic robot path generation in order to evenly paint a work object based on its CAD drawings. The later contribution shows the application of the developed algorithms in an actual industrial situation of automotive painting. The same authors try to expand the knowledge of this CAD based painting to applications that require any kind of surface manufacturing. Although the basis are the same, the scope is widened [20] and a CAD based path planning framework is proposed. Years later, as of 2008, still the same authors release novel research on CAD based coating of composite materials [21], together with a review of industrial robot path planning in spray painting applications, [22]. This shows the usefulness of automatic path planning through CAD but also indicates that a generic approach is hard to accomplish. Furthermore it can be seen that industrial painting applications are still requiring major research work; the variability of shapes, applicable products and painting techniques make it harder to develop a single framework. The industrial demonstrator for testing and validation of the research work presented on this thesis is itself a case of industrial spray painting. It is believed that the true know how lies on painters, experts with years of contact with the application; the CAD solutions do not take advantage of that expertise nor allow operators to transfer their skill to the robot. The CAD employment obviously do not limit to painting application. To make reference to a few more applications, T. Pulkkinen et al. [23] use 2D CAD to automatically process metal profiles. M. Soron et al. [24] report on the field of welding — again, CAD models are used to generate continuous tool paths. Norberto Pires et al. [25] suggest an interface for easy mapping from the CAD to the robot program, also directed over welding processes. Another different application, polishing, comes from Fusaomi Nagata et al. [26] — other than for path generation alone, the CAD model is used to integrate data from the force sensor, and feed it to a force controller to prevent an over/under abrasive operation. Since CAD data may not be as much accurate as needed for a given task, or the robot may not have the required accuracy, researches are conducted ahead of the simple path planning: P. Neto et al., [27] and [28], seek to compensate for poorly calibrated scenarios or for inaccurate/uncertain CAD models. 18 2.3 Programming by motion demonstration As mentioned before, CAD based robot programming have been seeing quite a respectful amount of research and the number of contributions is vast. As such, it is worthy of a mention in this state of the art overview. Nevertheless, this method of programming is more of a sophisticated interface than a true demonstration method. The user do not teach nor is able to pass on its expertise, he rather points out positions to where the robot should move. It is indeed an improvement over the standard robot programming interfaces but still lacks the ability of bringing together the robot and the actual factory operator who usually executes the tasks. The following section provides an insight on current and previous projects that show how operator-robot interaction can or may evolve in the years to come. From the vast set of contributions on the PbD (Programming by Demonstration) field it is from programming by motion demonstration that most profit is taken from this state of the art analysis. As commented before in the introductory chapter, this thesis searches for a novel way to learn (even if only by imitation) from the human expertise in industrial processes: to find a way to capture know-how while operators do their tasks, instead of forcing them to learn how to use either software or hardware. 2.3 Programming by motion demonstration The interaction with robots using the hand motion or gestures is arguably the most explored. Gestures and movements come as the most natural means for humans to express themselves. The programming by gesture recognition is, however, a mean of intuitive interaction rather than motion demonstration; for the sake of completeness of this review, some of the work on motion recognition is discussed: Stefan Waldherr et al. [29] present a framework based on video tracking that allows a mobile robot to follow an human; the same video data is used with neural networks and a template matching algorithm so that, if a given predefined gesture is captured, the manipulator on top of the mobile base executes pre-programmed tasks. The same approach is used by Matthias Strobel et al. [30], this time with hidden markov models and integrating context knowledge to better understand human intentions. Instead of a pure video inspection of human moves, Piyush Kumar et al. [31] developed a glove which allows a more precise tracking and identification of gestures. 19 3. BACKGROUND AND NOTATION 3.2 Coordinate Systems, frames and transformations In the remainder of this document, wherever is made reference to coordinate systems, without further specification, cartesian coordinate system is meant. Camera models and calibration, along with stereoscopic principles, make use of homogeneous coordinates (more on it ahead); this fact is highlighted in such cases. Throughout the proposed motion imitation framework there are numerous frames (distinct cartesian coordinate systems) to be considered: the robot base frame, the robot’s tip frame, the marker frame, the cameras frames, etc. When a point in 3-D space is projected into a 2D image pixel, or when a point in robot base coordinates is mapped to the end-effector frame, a transformation of frames occur. In Fig. 3.1, two frames are shown. The same point Pis represented in both frames. Concerning notation: 1. a frame is denoted by upper-case script capitals, e.g, Aand B; 2. a point is denoted by italic upper-case letters. E.g, P; 3. point Pon frame Ais represented by AP; 4. when a set of points is considered, the subscripted index in Pirefers to point i; 5. APihas coordinates APi=A(xi, yi, zi); 6. alternatively, Pcan be converted to matrix notation thus using the vector convention mentioned above: P→−−→ OP →p, where Ois the frame origin; The transformation of frame Ainto Bhappens in two moments: a rotation BRA and a translation BTA. Rotations are represented by square matrices which rotate points about the origin of the coordinate system by a certain amount (an angle) — in Fig.3.2 (a-left), a rotation of φdegrees around the zaxis is applied, followed by a rotation of θaround the new y0axis. More details on rotations matrices are given further ahead, in the angles and orientation section. Translations in RNare N×1 matrices and represent the offset between the two frames origins, AOAand AOB— Fig. 3.2 (b-right). 26 3.2 Coordinate Systems, frames and transformations x y z A AP OA x0 y0z0 OB B BP Figure 3.1: Frames - Notation for frames and points. Two frames are shown: Aand B. The later is obtained from Aafter a translation and a rotation 3.2.1 Homogeneous Coordinate System At this point, homogeneous coordinates are introduced for two main reasons: first they simplify the algebra of frame transformation by allowing a more compact and computationally efficient representation of the pair rotation+translation and by making composition of successive transformations easier; secondly, homogeneous coordinates are also used to represent projective transformations which is the base for (3D) computer vision; as such, these notions will be used on the camera related subsystems. Concerning frame transformations (rotation plus translation), the homogeneous coordinates can be seen as an extra dimension, with value equal to 1. Simply put, a point in 3D space with coordinates P= (x, y, z) has homogeneous coordinates P= (x, y, z, 1). What are the implications? In the example of Fig. 3.2, if APis represented in homogeneous coordinates, AP= (x, y, z, 1), then the whole transformation is written in a more compact manner: B     x y z 1      ="BRABTA 031# | {z } AHB A     x y z 1      ,where 03= [0,0,0] (3.2) The homogeneous 4×4 transformation matrix Hgroups rotation and translation in 27 3. BACKGROUND AND NOTATION x y z φ φ θ x0 y0z0 φ θ (a) x y z A OA x0 y0z0 OBB t= =AOB−AOA (b) Figure 3.2: (a) Frame Rotation: The second frame (Oxyx)0is obtained from the original by a rotation in the z-axis followed by another around y0. (b) Frame Translation: Vector trepresents the offset from the two origins. Translation succeeds rotation. If translation comes first, then the rotation must be around the translated BO. 28 3.2 Coordinate Systems, frames and transformations a single form which is a more computationally efficient and clean representation. The composition of consecutive frame transformations is also made easier: it is a succession of multiplications by each Hmatrix — DHA=DHCCHBBHA. The use of homogeneous coordinates in artificial vision problems is more than an added 1-value coordinate. In fact, homogeneous coordinates are useful to describe projective transformations and to have a non-singular definition of infinity. A point in 2D space still needs three coordinates: P= (x, y)→Ph= (x0, y0, w) where x=x0/w. From here it is easy to see that the mapping of cartesian coordinates to homogeneous ones is not unique: any value of wcan be set; the inverse mapping, on the other hand, is unique. When wis zero the point is at infinity so homogeneous coordinates can in fact represent the infinity in the form of coordinates (x, y, 0) instead of having to compute a zero division. In addiction, this added coordinate shows how it is impossible to go from a 2D frame into 3D, for instance, from an image frame into the world, without a complementary restriction — there are infinite possibilities (set wany value); for the reverse transformation, a projection, it shows how there are many 3D points (along a line) that project into the same 2D point (whichever the value of w,xand yare the same when the normalization w= 1 occurs). Fig. 3.3 holds a geometric interpretation for the added dimension w. 3.2.2 Orientation of a Rigid Body: representations There are several ways to represent the orientation (also called attitude) of a rigid body: rotation matrix (many times referred to as direct cosine matrix), euler angles, direction cosines, vector-angle representation and quaternions. There are advantages in using some representations over the others. Rotation matrices are larger in size (9 elements) but their algebra is efficient and easier; nonetheless, interpolating between orientations is not possible. Euler angles are just 3 values but have discontinuities and the representation of a given attitude is not unique. Quaternion algebra is less common and more complicated but they offer means for interpolation that no other representation does. The notation and some properties: 29 3. BACKGROUND AND NOTATION x0 y0 w Pxy P xy w= 1 infinity P=xp, yp, w Pxy =xp w,yp w,1 w= 0 → ∞ w= 1 : the usual cartesian frame, the XY-plane Figure 3.3: Homogeneous Coordinates - a geometric interpretation. A point Pxy in cartesian R2space (w= 1) can have infinite representations in homogeneous coordinates — all points along the line Pxy–P. The plane w= 0 represents infinity. 1. Rotation matrices use the standard matrix notation, upper-case bold letters, e.g, R. 2. The rotation around an axis uby an angle θis denoted Ru,θ. 3. If BRArotates frame Ato B, then the inverse rotation ARBis defined by ARB=BRA−1(also,R−1=RT) (3.3) 4. Consecutive rotations (about the current axis) are obtained by pre-multiplication of the respective matrices: DRA=DRCCRBBRA(3.4) 5. There are many conventions for use of the euler angles. In this thesis, euler angles were required to interface with a MOTOMAN manipulator and, as such, the convention followed is the one that best adapts to the robot programming. The euler angles define an orientation by the composition of three simple rotations, around the coordinate system axis. Assuming intrinsic rotations, i.e, 30 3.2 Coordinate Systems, frames and transformations around the moving axis, first there is a rotation around Z-axis by an amount φ; then a rotation around the new Y-axis by θ; finally, there is a rotation around the final X-axis by ψ. If fixed axis are considered (extrinsic rotations), then the order of axis rotation is reversed. MOTOMAN uses angles (Rz, Ry, Rx) but this notation is easily confused with the matrices. Hence the adopted notation hereafter will be (φ, θ, ψ); if a rotation matrix is associated with these angles and axis, then an orientation is described by R=Rz,φRy,θRx,ψ (3.5) 6. Lastly, there are quaternions. These are one of the most used tools to deal with orientations specially in the computer graphics field. Quaternions are an extension of complex numbers in 4D space: q= [qr, qi, qj, qk]T. 7. Unit quaternions represent orientation in 3D space; qand −qrepresent the same orientation while q∗, the conjugate, represent the inverse rotation; 8. unit quaternions live on the unit sphere of R4; interpolation between two orientations, which is not possible using rotation matrices, is simple in quaternion space — a ”linear” interpolation on the sphere surface (called Slerp, spherical linear interpolation). The algorithms used in this thesis are mainly based on rotation matrices and quaternions. However, the interface with industrial manipulators is usually done using euler angles or quaternions. For this reason, and to simplify the presentation of the algorithms throughout the thesis, the methods for converting between each representation are here described. Later, the representations shall be used interchangeably without caring to present again the same basic calculations. 31 3. BACKGROUND AND NOTATION 1. From euler angles to rotation matrix: RZ,φ =   cos φ−sin φ0 sin φcos φ0 0 0 1    RY,θ =   cos θ0 sin θ 0 1 0 −sin θ0 cos θ   RX,ψ =   1 0 0 0 cos ψ−sin ψ 0 sin ψcos ψ   R=Rz,φRy,θRx,ψ (3.6) 2. From axis-angle to rotation matrix — considering a rotation of θdegrees around axis k= [kx, ky, kz]T: Rk,θ =   k2 xvθ+cθkxkyvθ−kzsθkxkzvθ+kysθ kxkyvθ+kzsθk2 yvθ+cθkykzvθ−kxsθ kxkzvθ−kysθkykzvθ+kxsθk2 zvθ+cθ   (3.7) where cθ= cos θ,sθ= sin θand vθ= 1 −cos θ. 3. From quaternion (q= [qr, qi, qj, qk]T) to rotation matrix R=   q2 r+q2 i−q2 j−q2 k2qiqj−2qrqk2qrqj+ 2qiqk 2qrqk+ 2qiqjq2 r−q2 i+q2 j−q2 k2qjqk−2qrqi 2qiqk−2qrqj2qrqi+ 2qjqkq2 r−q2 i−q2 j+q2 k   (3.8) 4. From rotation matrix to euler angles —considering R= [rij] and X,Y,Z angles as ψ, θ, φ: φ= atan2  r23 −qr2 11 +r2 12 ,r33 qr2 11 +r2 12   θ= atan2 r13,qr2 11 +r2 12 ψ= atan2  r12 −qr2 11 +r2 12 ,r11 qr2 11 +r2 12   (3.9) 5. From rotation matrix to quaternion — considering R= [rij] : 32 3.3 3D computer vision •If Trace(R)≥0 qr=√1 + r11 +r22 +r33 2 qi= sign(r32 −r23)√1 + r11 −r22 −r33 2 qj= sign(r13 −r31)√1−r11 +r22 −r33 2 qk= sign(r21 −r12)√1−r11 −r22 +r33 2 (3.10) •If Trace(R)<0 then pick the largest leading diagonal element. Assuming it is r11 (works equivalently if is another element): s= 2√1 + r11 −r22 −r33 qr=(r32 −r23) s qi=s 4 qj=(r12 +r21) s qk=(r13 +r31) s (3.11) 6. From quaternion to euler angles: φ= atan2 2 (qrqi+qjqk),1−2q2 i+q2 j θ= arcsin (2 (qrqj+qkqi)) ψ= atan2 2 (qrqk+qjqj),1−2q2 j+q2 k (3.12) 7. From axis-angle to quaternion — θdegrees around axis k: q= cos θ 2+ sin θ 2ˆ k,with ˆ k=k kkk(3.13) 3.3 3D computer vision The artificial vision processes start from an image frame captured by a camera. The scheme on Fig. 3.4 exemplifies the notation for the axis of the image frame: horizontal and vertical axis uand v, respectively, are the basis of the image space; a pixel pis defined by its coordinates p= [up, vp]T. The value of the pixel is denoted F(u, v) and can be one dimensional (grey-scale image) or three dimensional (colour image). The origin of the image space is at the top left corner. In the example, the image resolution is 8 ×8 pixels. 33 3. BACKGROUND AND NOTATION v u p= [up, vp]T Figure 3.4: Image Notation - The standard frame used in image processing. Pixels are identified by their position (u, v) in the image frame/matrix. 3.3.1 Camera Model In order to understand the phenomena of capturing a scene into an image (using a camera and lenses) a model has to be established. The camera pinhole model is arguably the most commonly used to that end. Fig. 3.5 holds a scheme from which the pinhole model can be understood and derived. It synthesizes the projection of a world point into the image frame and how the different coordinate frames are related. The required notation: 1. Mis a 3D world point and has coordinates m= [mx, my, mz]T, with respect to the world frame W={xw, yw, zw}; 2. The corresponding pixel to mis pm= [um, vm]T; 3. The image plane Ihas a frame {ˆx, ˆy}centred in p0= [u0, v0]T( the principal point); the usual frame for image processing (due to the matrix representation) is at the top left corner: {u, v} 4. The focal plane Fhas the camera coordinate system {x, y, z}, centred in c— called the optical centre. 34 3.3 3D computer vision 5. The orthogonal distance between the planes Fand Iis f, the focal length; the line that connects p0and cis the optical axis. I Image Plane v u ˆx ˆy p0 pm F Focal Plane x y z c f M FHWxW yWzw W Figure 3.5: Camera Pinhole Model - The geometric relationship in a perspective projection. The pinhole model can be derived from this scheme (based on [58]). The projection of minto pmhappens in two moments: first there is the transformation of world coordinates into camera’s coordinates; then, the actual projection occurs. As for the former, it is necessary to describe the position of the camera in the world frame, i.e, specify cin terms of W; this is accomplished by the translation vector FtW. The alignment of the frames, i.e, {x, y, z}matching with {xW, yW, zW}, is achieved by a rotation: FRW. The homogeneous transformation FHW="FRWFTW 031#(3.14) holds the so called extrinsic parameters of the camera: how it is positioned with respect to the world. Regarding the 3D→2D transformation, it is described by the camera’s intrinsic 35 3. BACKGROUND AND NOTATION (a) (b) Figure 3.9: (a) Standard acquisition: The scene is captured with no timings constraints. The exposure and lense aperture make the image too dirt to be processed. The background lighting obfuscates the marker. There are many noise sources, mainly the fluorescent lamp. (b) Synchronous acquisition: The lenses aperture are reduced to a minimal. Exposure is very low (around 3ms). The background noise is eliminated and the markers shine robustly in the image. Under these conditions, clustering is straightforward. 42 3.4 Industrial Manipulators exactly for the purpose of implementing the skill transfer framework. Without loss of generality, the methods for interfacing and programming the robot were developed aiming a MOTOMAN PX2050 robot. This is an articulated manipulator, with 6 degrees of freedom (DoF) and a payload of 10Kg. Precision/repeatability (how close to the same position the robot end-effector is able to move to) is rated at ±0.5mm. In terms of accuracy (when the robot moves to a pre-defined point in space, how close it gets to the desired coordinates), manufacturers do not provide such data; this is some times referred to as volumetric accuracy, and usually falls down to a millimetre or two. It is due to this volumetric inaccuracy that online jogging and teaching is preferred over offline programming in high precision operations. For a real-time control of the robot, a TCP/IP interface with the robot controller can be used. A specific network protocol must be implemented in order to control robot movements, read its state and upload offline generated programs. As for the programming language, there are three types of movements which are also common across every brand of industrial robots: 1. Joint moves, or MOVJ: this instruction uses joint interpolation for moving the robot. This means that it travels from point Ato point Bwithout a particular path restriction; the controller moves each joint independently in order to achieve the desired position. This type of control must be used with caution since there is no a priori knowledge about where the tip or each link is going to move to. Only the final positioning is assured. 2. Linear moves, or MOVL: this type of control instructs the robot to go from position Ato Busing linear interpolation in the cartesian space, i.e, the robot will draw a straight line from Ato B; 3. Circular moves, or MOVC: this instruction controls the robot to perform a circular movement; it is usually fed by enough data points (3) to define a circumference in 3D space — the centre, the arc starting point and the arc ending point. Together with the most basic movement instructions there are also a number of parameters that can be controller for a refined motion control such as acceleration, deceleration and tolerance (how close to the desired point the robot goes). 43 3. BACKGROUND AND NOTATION A robot program is but a collection of successive movement instructions (either of the presented) with sensor readings and actuation signals set in-between those instructions. 44 Chapter 4 Motion Imitation Framework This chapter presents the methodology, the design and implementation of the humanrobot skill transfer framework. The first section is a brief snapshot of the proposed solution. It exposes all the modules and how they interface each other. From here, the remaining sections provide an in-depth analysis and description of each subsystem. The structure and ordering of the sections resemble the actual system flow on the real application: the motion capture/tracking, the data processing and the interface with the robot. 4.1 System Architecture : Overview This research is conducted towards a feasible industrial solution: the development of all system modules takes in concern implementation costs, reduction of hardware apparatus and cutback of setup and processing times. It is also important to minimize the impact on the production process, on the shop floor and ultimately on the operator task. The proposed solution puts together a tracking framework and a set of routines for data processing which aim to enable/simplify the interface and playback with an industrial manipulator. The sincrovision (see Background section 3.3.4) offers the possibility to develop a new kind of marker for gesture tracking. The technique is based on multi-view artificial vision and requires luminous markers. Using cameras to capture movement presents numerous advantages: it is a contactless method, operators do not have to wear extra 45 4. MOTION IMITATION FRAMEWORK devices (uncomfortable and unusual to their daily tasks), calibration is permanent as long as cameras remain unmoved. Also, there is a wide range of cameras with varying resolution and price. So, for a specific application there are many options to chose from available on the market. Furthermore, stereoscopy can be used starting with only two cameras (low cost) but more can be added as necessary to achieve the desired precision or to cover larger workspaces. This flexibility makes the stereoscopy based solution available to many industrial applications like painting, welding, bending, polishing, etc. From an industrial cell point of view, the required changes to install a stereoscopy based tracking are small: •Install a set of cameras; •Attach the marker to the work tool; •Connect the cameras to a PC and deliver power to the marker. The added hardware apparatus is reduced to a cabinet that can hold the stereoscopic setup (a set of industrial cameras and the synchronization device). The robot and the human worker operate in the same area: first, the operator demonstrates then he is replaced by the robot that is going to mimic the operation. The marker must be attached to the operator tool. In the following sections, the design considerations are described in order to achieve a robust and easy to plug luminous marker. The skill transfer framework limits how the human interacts with the robot, i.e, provides abstraction from the programming language but also from the teach pendant. A minimal interaction with a computer is needed nonetheless: to start and stop the demonstration, to calibrate the system and to playback desired programs. The framework is divided into the following stages: 1. Calibration. In this step, two calibrations take place: the camera↔robot calibration and the human-tool↔marker↔robot-tool calibration. The former needs the operator to mount a calibration tool on the robot end-effector; after that, the robot executes a program with no further human interaction. When the program ends the stereo is calibrated. Human-tool↔marker↔robot-tool calibration needs the operator to hold the work tool in front of the calibrated cameras. Calibration in done from an image frame of the scene. From this point, the tracking system 46 4.2 Camera and Stereo Calibration is ready to perform (these steps are detailed in the forthcoming sections). It is important to note that the system calibration only needs to be done once as long as the cameras remain in the same spot relative to the robot. The procedures can be done during the actual installation of the system, so it is transparent to the end user. 2. Demonstration. Through a computer interface, the operator starts the demonstration process. It takes a single click of a button. Then, he executes the movements and, at the same time, the data is captured and processed. After finishing the demonstration, the final trajectory processing is carried out and the robot program is generated. In this stage, the operator needs only to start and stop the process through the PC interface. The demonstration happens in the most natural way, as the operator executes a task as he would normally do. There is no use of an extra tool or any change to the operators’ behaviour. 3. Playback. Again, using only a software interface, the operator chooses a robot program. The code is transferred to the robot’s controller and the movement mimic is executed. The operator needs only to evaluate the machine performance by inspection. The motion imitation is achieved in a short time. The image processing is done in real time; the full trajectory analysis and robot code generation are also just a few seconds long which make the robot almost instantaneously ready to mimic the operator. The stereoscopy tracking requires camera calibration and a luminous marker; the marker itself must be able to follow the tool path and retrieve its position and orientation in space; the data must be processed in the shortest time possible; also, it must be optimized to interface with an industrial robot, i.e, limited to the movements the machine has available. These features, the design and implementation details that make this a feasible industrial system, are presented in the next sections. 4.2 Camera and Stereo Calibration As depicted in Chapter 3, camera calibration is a vastly researched subject. There are many available tools (software libraries) that implement the required routines that 47 4. MOTION IMITATION FRAMEWORK estimate the camera model parameters. Most of them are based on a list of points retrieved from the checker-board patterns and implement either the Tsai calibration method [61] or the more recent Zhang’s method [62]. The sincrovision, however, poses a problem to the use of checker-board patterns. Since the lenses’ aperture is shut to its maximum, it is very hard to observe the pattern. Even if the exposure is maximized, the images are too dark to be processed. It would require intense adaptive thresholds or added hardware apparatus to use light flashes. A new method to retrieve 2D↔3Dcorrespondences has been developed. First, the sincrovision is expected to be used with intense synchronous markers. So, the options are to build a checker-board with as much LEDs as there would be square corners in a printed pattern or to show a single LED at different known positions. Additionally, 3D calibration methods (recall the review on 0/1/2/3D calibration techniques presented in Chapter 3, section 3.3.3) are known to be very efficient but are sometimes disregarded since they require more apparatus and precisely prepared setup. To overcome this limitation the proposed technique uses the industrial manipulator to calibrate the cameras and the stereo. The robot can move in 3D, can hold the synchronous LED required by sincrovision and has high precision. With this approach, the LED attached to the robot’s end-effector describes a path with well known way-points. At these control points, the LED is lit and captured by the cameras. The world position is given by the robot controller and the LED is captured simultaneously by the cameras so building the 2D↔3Dcorrespondence list is straightforward. The robot has the ability to move and draw any shape (for instance, a cube), which simulates the use of two or three orthogonally positioned checker-board patterns. In addiction, the robot can move inside that cube which means the calibration method can have point/pixel correspondences from all over the workspace without extra hardware. Figure 4.1(a) shows an industrial robot performing the calibration path. It moves in a grid pattern and the LED is lit at a regular interval. Figure 4.1(b) has the final calibration grid, after the robot has moved in the entire workspace. The grid density is easily adjusted to have extra points for a more robust calibration or to have few and take less time. With the pixel–world-point correspondence list, the estimation method proposed by Faugeras [63] can be followed: it is a linear estimation of the camera’s projection 48 4.2 Camera and Stereo Calibration (a) A A z x y Workspace (b) Figure 4.1: (a) Robot Path: The manipulator moves in an incremental path and the LEDs are turned ON at regular intervals (red dots). Care is taken that all positions are visible to both cameras. (b) The final calibration grid: After the robot has moved around the entire workspace, the result is a calibration grid with 3D points with have also been captured by both cameras. This data can be used for camera and stereo calibration and is already described in robot coordinates. 49 4. MOTION IMITATION FRAMEWORK matrix. Recall the camera model and the perspective projection equation (equ.3.16): pm=PM , where P=AFHW The set of npoints in space, Mi= (Xi, Yi, Zi,1), captured by a pair of cameras generates a set of nconjugate pairs of pixels (pi,p0i) (corresponding pixels). For each camera we have n2D↔3Dmappings pi= (ui, vi)↔Mi= (Xi, Yi, Zi,1) which, according to equ. 3.16, originate:         XiYiZi1 0 0 0 0 uiXiuiYiuiZiui 0 0 0 0 XiYiZi1viXiviYiviZivi . . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . . XnYnZn1 0 0 0 0 unXnunYnunZnun 0 0 0 0 XnYnZn1vnXnvnYnvnZnvn         p=0(4.1) where p= [p11, p12, . . . , p34]Tand 0is an 1 ×2nnull vector. This system of homogeneous equations Gp =0can be solved using linear estimation. The error produced by this procedure is sub-pixel and acceptable for human hand motion capture. The least squares solution is as usual the singular vector associated with the smaller singular value of GTG, i.e, the last column of Vfrom SVD(G) = USV T. To calibrate the stereo from the known Pand P0matrices, the relation from Equ. 3.19 is used: F=P0c×P0PTPPT−1 This calibration method has the added benefit that cameras and stereo are calibrated in the robot’s coordinate frame. No additional frame translation and rotation is needed. When computing a 3D position from the images, the coordinates are directly used in the robot controller. Also, the manipulator is already supposed to exist, i.e, is an available asset as it integrates the motion imitation framework. Using it reduces the cost of having to develop hardware and complex mechanics that could provide a precise positioning of the 3D pattern. More so, this calibration technique avoids the major positioning accuracy error on offline programming of industrial manipulators. These robots execute with great precision but a mediocre accuracy — see Fig. 4.2, from [64]. Precision, or repeatability, 50 4.3 Motion Tracking describes how close the robot can move back to a given position. Usually this indicator is provided by manufacturers and can be lower than 0.1mm. Accuracy defines the ability to move to some exact 3D coordinates in space. Manipulators can move to the same position over and over again with great precision yet they may still fail the desired position by a considerable amount. Usually manufacturers do not provide this indicator. Robot manufacturer ABB claims that their own robots may have a volumetric error of about 5 to 15 mm [65]. For offline programming solutions (where absolute positions/coordinates are used to generate programs) this feature may jeopardize the task performance as the robot moves to the simulated positions but adds a considerable error. By the proposed method for camera calibration, the camera model inherits the error pattern of the robot positioning. Thereafter, the offline programming based on coordinates read from camera images significantly reduces this interference from the robot inaccuracy. Accuracy and Calibration Issues of Industrial Manipulators 133 Poor Accuracy Poor Repeatability Good Accuracy Poor Repeatability Poor Accuracy Good Repeatability Good Accuracy Good Repeatability Poor Accuracy Poor Repeatability Good Accuracy Poor Repeatability Poor Accuracy Good Repeatability Good Accuracy Good Repeatability 3. Calibration Overview There has been a lot of work on the subject of improving the positioning accuracy of industrial robot manipulators ((Hayati & Mirmirani, 1985), (Mooring & Pack, 1987), (Driels & Swaze, 1994) and (Roth et al., 1987) among many others). Most of the authors considered the main source of errors to be only geometric, with the exception of (Chen at al., 1987) and Whitney et al. (Whitney et al., 1986), who included explicitly non-geometric errors as well. Although some introduced their own models (Whitney et al., 1986), the majority used models that are universally valid and widely accepted, such as the Denavit-Hartenberg or modified versions of it ((Khalil et al., 1991), (Driels, 1993) and (Harb & Burdekin, 1994)). Much previous work is based only on computer simulations, but some validation work used real measurements ((Chen at al., 1987), (Whitney et al., 1986), (Stone, 1987) (Stanton & Parker, 1992) (Khalil et al., 1991),(Driels, 1993),(Driels & Pathre, 1994) and (Abderrahim & Whittaker, 2000)), and very recently there is even commercial application dedicated to robot calibration ((Renders, 2006) and (Fixel, 2006)). Stone (Stone, 1987) developed a model and also a novel general identification method to estimate his S-model parameters, based on the circle-point analysis (Mooring et al., 1991) which lead to what he designated as joint features. These joint features are the plane of rotation, centre of rotation and radius of rotation. If required, the D-H parameters can then be extracted from the S model. Stone's motivation for developing his model was because “the D-H Model is not amenable to direct identification” (Stone, 1987). However, with small modification, the D-H Model has been used successfully for calibration in several of the papers referred to above. Although the S-Model can be identified using the method proposed in (Stone, 1987), it still suffers the same disproportion as the D-H model when consecutive joint axes are parallel or near parallel. The real problem here is that the control software of existing industrial manipulator does not use the S-model parameters. The physically explicit significance of the D-H model and its widespread use in robot control software make it very desirable to develop identification methods that obtains the D-H parameters directly, whilst at the same time is able to deal with the case where consecutive joint axes are parallel. Our procedure proposed in (Abderrahim & Whittaker, 2000) makes use of the Figure 4.2: Precision/Repeatability vs Accuracy - Interpretation for the concepts of repeatability and accuracy. Industrial manipulators report to the 3rd example: they provide a good repeatability but volumetric accuracy is less feasible. 4.3 Motion Tracking 4.3.1 6-DoF Marker This section describes a marker — hereafter referred to as luminous marker, icosahedron or simply marker — for a complete 6D (six degrees of freedom: position, (x, y, z), and orientation, (φ, θ, ψ) ) motion tracking. As pointed earlier, the major concerns on the development of this tracking tool were to achieve a device that provides an accurate measure of the pose of the human hand/tool while maintaining costs low, reduced processing times and low impact on the process and on operator movements. 51 4. MOTION IMITATION FRAMEWORK Rg RrRb +V Trigger +V RGB LED CV (a) Synchronization Device (µC) Marker Camera 2 Camera 1 Camera 1 Trigger (2-wire) Camera 2 Trigger (2-wire) Marker Trigger (3-wire) (b) Figure 4.6: (a) Schematic and Components: the LED drivers for the synchronous operation are based on the most simple electronics; each colour has a series resistor in order to optimize each component individually. The mosfet does the triggering. (b): Connections and Cabling Diagram: the required connections and cabling are minimal. Each camera receives a pair with trigger+reference; the marker, in addiction to those, also receives power. The complete apparatus is minimal. 58 4.3 Motion Tracking (a) (b) (c) Figure 4.7: (a) Scene captured by a hand-held camera: a normal photo of an operator holding the worktool with the luminous marker. (b,c): Stereo sincrovision Capture: the same scene of (a) captured by a pair of industrial cameras with the synchronization effect. 59 4. MOTION IMITATION FRAMEWORK (a) R YG C B P 0◦ 60◦ 120◦ 180◦ 240◦300◦ Hue Chroma (b) Figure 4.8: (a) HSV model: Cylindrical geometry of the colour space. The Hue component is the angular dimension that describes the colour itself; for a given colour, the value/lightness tells how close it is to white or black. (b) Primary and Secondary colours in HSV space: The hexagon representation of the HSV space gives a feel of how close the colours are to each other and how they combine. In order choose a set of different colours for the proposed marker, the hexagon scheme is used so that the colours are the most separated as possible. This improves image processing and cluster classification. 60 4.3 Motion Tracking ness or even intensity, all refer to the same property even though each has a slightly different formula, which maps colour into a grey-scale representation. The marker consists of red, green, blue, yellow and purple lights. The most simple definition of intensity (and respective threshold function) is the average of the three RGB components: FGrey(u, v) = 1 3(R+G+B)⇒F(u, v) = (0,if FGrey(u, v)< threshold F(u, v),otherwise (4.3) but this is a poor evaluation when expecting only primary and secondary colours. Each LED light is composed by only one or two of the components; averaging the three components every time makes the intensity estimation lower then the actual value as at least one of the arguments will be always close to zero. The algorithm starts by thresholding each component then computes brightness from the active ones. This is possible because there is a priori knowledge from the light sources: the LED drivers are designed to provide strong intensity of a given primary colour; in the case of a secondary colour, each component intensity is reduced such that the sum of the two intensities is similar to the primary colour alone. In addiction, this has the effect that the size of all clusters in the image is fairly the same. From the thresholded image follows the clustering algorithm. It is based on horizontal sweeps of the image frame: first, horizontal segments are detected; then they are merged together with segments from the rows below according to their relative positioning. Both large and small clusters (compared to the expected cluster size) are disregarded. Finally, the centre of mass of each light is computed. The threshold and clustering stages are a single shot algorithm, meaning that only one entire image sweep is required. This reduces processing time keeping the whole tracking real-time capable. After the cluster detecting comes the colour classification. Again, the HSV model is used. For reasons made clear further ahead, a total of five different colours are needed for a perfect unambiguous identification and tracking of the icosahedron. The colour information is kept on the hue component of the HSV system which is an angular dimension. For an easy classification and distinction of the required five colours, these are chosen having the most hue distance from each other. Red, yellow, 61 4. MOTION IMITATION FRAMEWORK green, cyan, blue and purple and separated by at least 60◦from one another — Fig. 4.8 (b). After some tests, cyan was dropped as it was harder to get using the RGB LED; the green/cyan and cyan/blue pairs caused ambiguous detections so the five icosahedron colours were finally set to red, yellow, green, blue and purple. The HSV is then divided in 6 classification areas as seen in Fig. 4.9. R YG B P Rh max Rh min Yh max Yh min Gh max Gh min Bh max Bh min Ph max Ph min Shaded gray areas indicate that colour classification fails, i.e no colour is assigned to the cluster Figure 4.9: Colour classification based on HSV - The hexagon of HSV colour model is divided into 6 classification zones: one for each colour plus the zones of indetermination(gray). For each cluster in the image, the hue quantity was computed as an average of each pixel hue, H, defined as: α=1 2(2R−G−B) β=√3 2(G−B) H=atan2 (β, α) (4.4) 62 4.3 Motion Tracking R YG C B P 0◦ 60◦ 120◦ 180◦ 240◦300◦ (a) (b) Figure 4.10: (a) HSV Calibration: Example of calibration of the colour classification algorithm. Samples are collected for each colour and the boundaries are set accordingly. This is a per-camera analysis. Remark: only the hue quantity is evaluated so all the samples are drawn in the maximum-chroma circle. (b) Cluster Detection: a zoomed image captured by one camera of a stereo configuration. The LEDs are detected and identified according to the average hue value of all pixels. Equation 4.4 is a simplified and hence faster computation of hue, ignoring the peculiarities of the hexagon vs circle shaped HSL model (RGB cube projects into an hexagon HSV space; the formula assumes a circular space instead; the error of this approximation is smaller than 1.2◦therefore negligible). Since there is a thick margin to the hue value of each colour, classification is robust to changes in the LEDs output, or even distortions from light sources pointed towards the marker. Fig. 4.9 shows a theoretical/perfect division of HSV space. In practice, the classification areas are not pre-defined but result from a colour calibration process: The colours are shown, each at a time, to both cameras. The samples are collected from the whole workspace. The boundaries between classes (hue regions) are then set individually and are different for each camera — Fig. 4.10(a) shows an example of the calibration of HSV colour classes for cluster identification; several samples are read from each colour and the limits to the hue values are set. On (b), the clusters are outlined in a real image. 4.3.1.4 Stereo — cluster matching Following the detection of individual clusters on each image, the next stage is matching them over a set of synchronized images from different cameras. For the sake of simplic- 63 4. MOTION IMITATION FRAMEWORK Table 4.1: Cluster data after processing images from both cameras: The data is about the colour and the centre of mass of each visible LED. The stereo will have to pick clusters from both lists and match them. Clusters Camera 1 Camera 2 Colour Position Colour Position u v u v Red 448 462 Red 321 422 Green 430 464 Green 301 425 475 463 Blue 455 481 Blue 330 441 Yellow 474 481 Yellow 299 446 428 484 Purple 460 451 Purple 329 411 444 494 316 455 ity, the fundamentals of this step are presented for a two-camera framework; N-camera setups are processed in equal terms, considering two cameras at a time. The starting point is a colour-ordered list of clusters from each image — an example is shown in Table 4.1. The position entry refers to the centre of mass of the cluster. The stereo fundamental matrix, the one that defines the relationship of the two cameras to the 3D world, plays now its role: the relationship l0=Fp defines the epipolar line; for a given pixel pin camera 1, the epipolar line on camera’s 2 image holds the possible corresponding pixels, p0. Figure 4.11(c-right) shows three epipolar lines for a red, green and blue led on (c-left); with a precise calibration of the stereo setup, the epipolar lines go through the matching pixel on the other image. Image (a) and (b) are fullsize examples of two camera view. The matching algorithm picks every cluster (centre) on camera 1 and computes the 64 4.3 Motion Tracking (a) (b) G R B G’ R’ B’ (c) Figure 4.11: (a) Camera 1 Image with clusters: an image from camera 1 with a set of clusters. (b) Camera 2 Image with Epipolar Lines: the red, green and blue lines (not straight due to barrel distortion) are epipolar lines from some clusters in image (a). (c) Zoom on Epipolar Lines and Cluster Correspondence:the highlighted and labelled red, green and blue clusters — on the left, zoomed from (a) — need a matching pair in the other camera image so that 2D↔3Dis possible. Finding the correspondence is achieve by colour and the geometric constraint given by the epipolar lines — on the right, zoomed from (b). 65 4. MOTION IMITATION FRAMEWORK corresponding epipolar, e0; then, if any cluster of the same colour, on camera 2, lies at a parametrized distance to the epipolar, it is considered a good match. It is possible, for some specific icosahedron poses, that two clusters of the same colour fall close to the epipolar: RR’ R” Figure 4.12: Multiple matches - In some cases, both the colour and the epipolar constraints fail to deliver an unique match of cluster pairs. In this example, the epipolar line of the red cluster on the left goes near two red clusters in the right image. Both hypothesis are considered. In this case, more than one match is registered for a given cluster. At this point, it is not possible to reject either in favour of the other so both hypothesis are considered, i.e, (R, R0) and (R, R00). On the next section, while estimating the marker position, these ambiguities are solved. Still on Fig. 4.12, the R00 cluster is actually a yellow one. In such a narrow point of view, the HSV analysis misclassified it as being red. Even with the epipolar uncertainty and the misclassification, the pose estimation algorithms succeeds and proves robust to worst case scenarios of the marker detection. 4.3.1.5 Estimating Position The 3-dof related to the marker translation are computed taking advantage of the spherical positioning of the LEDs. Since the 3D coordinates of the matched clusters are already available, the world points are used to estimate the sphere shell in which 66 4.3 Motion Tracking they lie — Fig. 4.13 shows a 3D scene with the luminous markers and the sphere shell in which they lie at. Figure 4.13: 3D Scene with LEDs and a Sphere - To estimate the whole marker position each individual LEDs contributes for a sphere fitting algorithm. The resulting sphere centre is used as the marker position in 3D space. The more LEDs are visible the more robust the estimation gets. There are two main methods of data fitting to sphere surfaces, namely the geometric [66] and the algebraic fitting [67]. The former uses the most ”obvious” cost function; from the sphere equation 4.5 (xi−xc)2+ (yi−yc)2+ (zi−zc)2=r2(4.5) it minimizes the orthogonal distance, di, from each point to the sphere shell 4.6. F(xc, yc, zc, R) = X i d2 i(4.6) The vector [xc, yc, zc]Tdenotes the centre of the sphere and Rits radius. Expanding 4.6 since di=ri−R , ri=q(xi−cx)2+ (yi−cy)2+ (zi−cz)2 67 4. MOTION IMITATION FRAMEWORK Unique ”Y” With 5 colours there are 20 unique sets (a) (b) Figure 4.15: (a) Coloured Dodecahedron Graph:The schlgel diagram provides an intuitive way to view the distribution of LEDs around the dodecahedron. Using 5 colours, it is possible to colour the vertices with a pattern that allows a quick identification of the marker orientation. As soon as a star/Yis completely visible in the images, orientation is known. (b) Y Detection: Detection of a complete star/Yin a real image capturing the luminous marker. The Yis identified and it is enough to know the full orientation of the marker in world coordinates 74 4.3 Motion Tracking Table 4.3: Dodecahedron Vertices: Coordinates, Colour and Neighbours Dodecahedron Vertices No. Colour* Coordinates Missing Colour Neighbours No. x y z Ngb 1 Ngb 2 Ngb 3 1 1 -0.38197 0.525731 0.850651 4 2 5 8 2 2 0.381966 0.525731 0.850651 5 1 3 9 3 3 0.618034 -0.20081 0.850651 1 2 4 10 4 4 3.28E-08 -0.64984 0.850651 2 3 5 6 5 5 -0.61803 -0.20081 0.850651 3 1 4 7 6 1 -2.29E-08 -1.05146 0.200811 5 4 12 13 7 2 -1 -0.32492 0.200811 1 5 13 14 8 3 -0.61803 0.850651 0.200812 2 1 14 15 9 4 0.618034 0.850651 0.200811 3 2 11 15 10 5 1 -0.32492 0.200811 4 3 11 12 11 1 1 0.32492 -0.20081 2 9 10 18 12 2 0.618034 -0.85065 -0.20081 3 6 10 19 13 3 -0.61803 -0.85065 -0.20081 4 6 7 20 14 4 -1 0.32492 -0.20081 5 7 8 16 15 5 2.29E-08 1.051462 -0.20081 1 8 9 17 16 1 -0.61803 0.200812 -0.85065 3 14 17 20 17 2 -3.28E-08 0.649839 -0.85065 4 15 16 18 18 3 0.618034 0.200812 -0.85065 5 11 17 19 19 4 0.381966 -0.52573 -0.85065 1 12 18 20 20 5 -0.38197 -0.52573 -0.85065 2 13 16 19 *Colours: 1-Red; 2-Green; 3-Blue; 4-Yellow; 5-Purple 75 4. MOTION IMITATION FRAMEWORK nth vector in Qstores the current world position of the nth stand-by LED in P. The kabsch algorithm [69] provides a mean to solve this problem. This method finds the rotation matrix that optimally describes (in a root-mean-squared-error sense) the rotation from two paired 3D point lists: 1. Pand Qmust have origin-centred vectors so the first step is subtracting both sets their respective centroid. 2. Compute the covariance matrix Adefined as: A=PTQ 3. Compute the singular value decomposition of A: A=USV T and the optimal rotation matrix W∗comes from : d=sign(det(V UT)) →W∗=V   1 0 0 0 1 0 0 0 d  UT(4.11) (The auxiliary parameter dis used to insure a right handed coordinated system.) At this point we have the full (6-dof) characterization of the movement of the marker, with both position (3-dof) and orientation (3-dof). 4.3.1.7 Limitations The icosahedron shaped marker provides the most complete movement tracking, with full 6-DoF capture of the human operator. Most of the properties of this shape have proved very useful and effective regarding handling and algorithms. Even so, there are some known limitations: •The smaller and most common hi-power LEDs, that can be driven bright enough to get captured using sincrovision, are around 3 to 5 mm in size — side of a square shaped LED. This restricts the minimum size of the marker (radius) at about 30mm. This restriction is required in order to prevent light superposition — in an undersized marker the lights get mixed up. 76 4.3 Motion Tracking •The sphere fitting algorithm behaves well with observations from all around the full sphere shell. This means that cameras should be placed on two different/opposing sides for optimal performance. This way, the collected 3D points are balanced throughout the spherical surface. A single pair of cameras provides measures from just one side, which causes individual LED noise to have a greater effect on the centre estimation. This happens because the measure along the depth axis of the stereo is where the error is larger so the centre estimation tends to have greater variance and bias in that direction. •The most cheap arrangement, with the minimum of two cameras, has the combined disadvantages of the previous two statements. On one hand it greatly influences the size of the marker: even though a proper choosing of lenses may provide a complete workspace coverage, the stereo precision is limited to how much the cameras can be placed apart; the depth precision can only be improved with more cameras rather than with better ones (more resolution). One of the must crucial and laborious tasks is to achieve a perfect trade-off between number of cameras, tracking precision and marker size that can satisfy the demanded system precision, work volume, shop-floor restrictions for camera instalment and the size/weight of the marker that will be attached to the operator’s tool. •The further the number of cameras is reduced, the more susceptible the system is to occlusions. The tracking algorithms work for a minimum of 4 visible LEDs; while the framework attempts to be the less intrusive possible in the process, the operator still needs to be cautious not to stand in-between marker and cameras. •The synchronization process requires cabling. Even though some industrial tools are active (actively powered, electrically or by means of compressed air for instance) as in painting, welding, etc, some processes are passive (grinding, polishing, etc); in the case of active tools, the extra marker cabling may be an acceptable overhead while in passive processes it may present itself as an extra apparatus that the operator may have to learn how to cope with. 77 4. MOTION IMITATION FRAMEWORK 4.4 Interfacing an Industrial Manipulator The tracking subsystem provides, in short, a set of time-stamped world coordinates. Due to the camera calibration process presented earlier, the coordinates are already referenced to the robot’s base frame which simplifies the interface process. Nevertheless, there is still much to an operators’ task beyond the pure movement. The most critical point in order to achieve a perfectly timed mimic is the interface with peripherals. Capturing the wrist pose can be complemented with reading the actuation of the main control signals of the process such as a blowtorch on/off, the spray gun trigger, the suction cup enable/disable, etc. These main interfaces are synchronously captured and only then can the robot perform a timely imitation. The developed synchronization device outputs the camera and marker triggers (synchronous signals) and is also able to keep the same synchronization across the peripherals in the industrial cell — Fig. 4.16. Should the operator interact with any of those commands (asynchronous signals), the action is recorded with a time stamp. The robot interface then starts from two synchronized lists of human movements and human-device interfaces, as depicted in the bottom part of Fig. 4.16. 4.4.1 Data Filtering This section deals with data smoothing, for both position and orientation. Rather than using online filters, the focus sets on using all points to create a smoother path. This means that a given 6D point Miis filtered using past and future poses Mfilt i= f{Mi}i+p i−p, with pbeing the filter window width,i.e, how many past and future points are used. Position and orientation are treated separately but both approaches focuses on delivering a smooth path (either in position or orientation space). 4.4.1.1 Position Smoothing Position is described by a translation vector kT0. It represents the position of the marker at time kin coordinates of the robot’s base frame (because cameras where calibrated using the robot). In order to simplify notation, each translation vector will now be treated as a position Pkin space. This change of notation is needed so to maintain a certain degree of standardization in the notation of the smoothing method. 78 4.4 Interfacing an Industrial Manipulator Position No. Time Stamp Translation Orientation 1105781087 1T0 1R0 2105821050 2T0 2R0 3105861072 3T0 3R0 4105901112 4T0 4R0 5105941005 5T0 5R0 6105981091 6T0 6R0 … … …… 6D Trajectory Points Time Stamp I/O Change 105821301 SprayGun RE 105901889 Conveyor Move RE 105941333 SprayGun FE 106485213 Conveyor Move FE ……… Synchronized Data * * RE: Rising Edge, FE: Falling Edge Figure 4.16: Synchronization across images and devices - The synchronization device delivers the triggers for the cameras and the marker. At the same time it reads the changes to I/Os. The video tracking outputs a list of 6D positions while the monitoring of the I/Os provides a synchronous list that can be merged into the trajectory using the time stamp. 79 4. MOTION IMITATION FRAMEWORK 1350 1400 1450 1500 1550 1600 1650 1700 1750 1800 1850 −100 −50 0 50 100 150 200 250 300 350 Target Points Piecewise Linear Real Spray Painting Path (Dimensions in mm) 400 (a) 1200 1400 1600 1800 2000 −100 0 100 200 300 400 550 600 650 700 Target Points Piecewise Linear Real Spray Painting Path (Dimensions in mm). (b) Figure 4.17: (a) 2D Upper View, (b) 3D View: These plots show a set of captured marker positions in a real spray painting application. The ”*” represent the spatial position and the lines are but a linear piecewise approximation for the path. Despite the synchronous capture, the position estimation is still noisy. Even though the tracking system is very robust to disturbances, the output path comes affected by noise. It has roots on the camera sensor, which captures noisy images despite the sincrovision effect, and on the position estimation algorithm, particularly when a small number of cameras is used and the marker is only visible from one of the sides (already discussed in section 4.3.1.5). Figure 4.17 shows an example of a real trajectory where each position is connected by a line. In order to remove some of the noise, and achieve an equivalent smoother path, a spline based smoothing is proposed. Splines are polynomials defined piecewise, i.e, a set of n-degree polynomial functions connected together in a smooth fashion. The motivation for the use of splines comes from their extensive and successful use in computer graphics and CAD systems, to approximate arbitrarily complex curves and surfaces. Also, there are already numerous contributions on industrial machining problems and even industrial robotics (for instance, Jia Pan et al [70]) that take advantage of splines. The main advantages of this smoothing/modelling tool are the numerical stability, easiness and flexibility of construction and the ability to fit complex curves (like a free hand movement). The numerical stability is closely related to the possibility of interpolating data (as in polynomial interpolation) with low-degree polynomials which avoids the Runge’s phenomenon for single high-degree polynomial interpolation. For 80 4.4 Interfacing an Industrial Manipulator this reason, the most commonly used splines are of 3rd degree, i.e, the so called cubic splines. Moreover, there are numerous forms of splines which vary on how they are constructed or which features they offer. The most commonly used (generally, but also particularly in curve fitting) are B-splines: a spline that is itself a (linear) combination of splines and offers means to easily ensure continuity across a set of chained splines used approximate a whole curve. This introduction leads to the definition of a B-spline as a linear combination of splines: S(u) = n X i=0 PiNi,p (u) (4.12) The points Pi, for a total of n+ 1, P={P0, P1, ..., Pn} are called the control points. It is to these positions that the final spline curve tries to stick to. Ni,p (u) are the splines which are linearly combined to obtain S; they are called the basis functions. From the definition above, equ. 4.12, it is easily seen that the final B-Spline is not defined as a function of (x, y, z) positions. Instead, Sstands as a parametric function with parameter utaking values in the interval [0,1]. Yet, u was represented as lower-case bold letter because it is a vector u={u0, u1, ..., um} where each ujis a value in [0,1] representing break points on the curve, that is, the whole curve is segmented in smaller curves. Each of these is itself a linear combination of splines. So it is easy to understand that the ujsequence must be crescent (moving along de curve, from 0 to 1, and breaking it along the way): uj⩽uj+1 ,0< j < m −1 Vector uis known as the knot vector. The last component that makes Sare the basis functions Ni,p (u). pis the degree of the basis functions and, as such, is the degree of the B-Spline because the latter is a linear combination of the former. 81 4. MOTION IMITATION FRAMEWORK According to Krebs, H. et al. [71], a human-like movement can be well described by a combination of bell shaped basis functions. This is the shape of a cubic basis function — see Figure 4.18. For this reason, cubic B-splines are used in the smoothing algorithm. The zero-order basis function (constant), Ni,0(u), is defined as — from [72]: Ni,0(u) = (1 if ui⩽u⩽ui+1 0 otherwise (4.13) The next higher order basis functions are recursively computed from Ni,0(u): Ni,p (u) = u−ui ui+p−ui Ni,p−1(u) + ui+p+1 −u ui+p+1 −ui+1 Ni+1,p−1(u) (4.14) 0 0.5 1 1.5 2 2.5 3 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 Figure 4.18: B-Spline Cubic Basis Function - Illustration of the cubic basis function for a 3rd degree B-Spline. It has the so called bell shape. At this point, where a path with Pipoints awaits for smoothing, the only thing that is not already available is the knot vector. As pointed before, this is where the entire curve gets broken into smaller curves. As such, the knot positions have a major influence on the final layout of S. First, the number mof knots must respect the relationship: m=n+p+ 1, i.e, the number of points, n+ 1, plus the degree of the polynomial. To define values for uthere are different strategies (covered in [73] ); in short, the sequence may be uniform, u= [0,1/(m−1) ,2/(m−1) , ..., 1], or nonuniform (which result in the so called uniform or non-uniform B-Splines, respectively); additionally, the sequence can be closed, clamped or open which result, respectively, in: a closed curve where the last point is the same as the starting one (not useful in 82 4.4 Interfacing an Industrial Manipulator smoothing an unpredictable human move); a curve clamped to the first and to the end points, smoothing all positions in-between; an open curve which has no restrictions. In this case the clamped method is used as it is desirable that the robot playback starts and ends at the same place as the human did. In addiction, a non-uniform sequence must be used because data is not equally spaced (it is in time dimension but not in spatial dimensions). The method for clamping both ends is to set the first and last values of uto 0 and 1 respectively. The number of 0s and 1s is related to the degree of the polynomial — p+ 1 repetitions at each end: u= [u0, u1, . . . , up, . . . , um−p, um−p+1, . . . , um] =   0,0,...,0 | {z } p+1 ,...,1,1,...,1 | {z } p+1   (4.15) To fill in the middle of the knot vector the method of chord length was used: each point Piis given a parameter t(actually this is still a uvalue but it is named tnot to be confused with the uvalues that belong to the knot vector). This parameter t is proportional to the length of the lines connecting the control points Pi; that is, t parameters are as spaced as points are: d= n X k=1 kPi−Pi−1k2 ti=Pi j=1 kPj−Pj−1k2 d (4.16) Then, the uvalues that compose the knot vector are defined as: u0, . . . , up= 0 up+1, . . . , um−p=uh+p=1 p h+p+1 X k=h tk um−p, . . . , um= 1 (4.17) where the middle values, uh+p, are generated from the average of pparameters. With this formulation, the B-Spline is completely defined. Points Pifrom the path serve as control points, and the ratio of their relative distance to the whole path gives rise to the knot vector. From the definition of S, recovering points along the curve (also called evaluating the spline) is done by giving values to u, from 0 to 1. This step shows the major disadvantage of spline fitting: as discussed above, B-Splines are defined in a parameter space of uand not in actual 3D space; this means that it is quite hard 83 4. MOTION IMITATION FRAMEWORK 5.4 Some examples of visualization In this section we show some examples of the visualization of the angular velo city graphs and the interp olation curves. The interp olation metho ds are describ ed in section 6; we only describ e prop erties of the resulting visualizations here. The interp olation is p erformed on the frames given in table 5.1. The key frames are given by a general rotation. As noted ab ove, we cho ose the rotation angle and axis such that all the rotations lie in the same three-dimensional hyp erplane. In gures 5.1 through 5.3 we discuss dierentpropertiesofthe visualizations. Note that there is no obvious connection b etween the rotations in gure 5.1 and the p oints on the surface of the sphere. This is b ecause the table contains general rotations, while the visualizations show the corresp onding quaternions. Since we are only interested in the geometric shap e of the curves, the absolute p ositioning of the key frames on the sphere is irrelevant. Rotation angle  2 ] ; ;  ] Rotation axis v 2 R 3 1 (1,3,0) 1.9 (-1,0,0) 0 (-2,1,0) -2 (3,4,0) -1 (-1,4,0) 1 (1,3,0) Table 5.1: Key frames 0 0.2 0.4 0.6 0.8 1 1.2 0 100 200 300 400 500 600 700 800 Frame nr. ’Angular Velocity.’ ’Key Frames.’ Figure 5.1: The interpolation curve stays on the surface of the sphere, but it is not dierentiable in any key frames; the curve \breaks" when it passes through the key frames. The angular velocity graph is piecewise continuous and shows that the angular velocity is constant between keys. This method of interpolation is cal led Slerp and is described in section 6.1.5. 36 (a) 0 0.2 0.4 0.6 0.8 1 1.2 0 100 200 300 400 500 600 700 800 Frame nr. ’Angular Velocity.’ ’Key Frames.’ Figure 5.2: The interpolation curve is now dierentiable through al l key frames. Compare, for example, the key frame in the midd le of the gurewith the corresponding key frame in gure 5.1. The angular velocity graph is continuous and assumes local minima at the key frames. This interpolation curve is cal led Squad, and it is described in section 6.2.1. 0 0.2 0.4 0.6 0.8 1 1.2 0 100 200 300 400 500 600 700 800 Frame nr. ’Angular Velocity.’ ’Key Frames.’ Figure 5.3: This interpolation curve dips below the surface of the three-dimensional unit sphere. This means that the interpolated points arenot unit quaternions, and thus the points do not lie on the surface of the sphere. The angular velocity graph is piecewise linear. This interpolation curve is cal led LinE ul er , and is described in section 6.1.1 In general we will illustrate the interp olation metho ds with the last two visualization metho ds: Sphere and graph. Wehave included the animated sequences for the sake of completeness, since it is in this context that the interp olation serves its practical purp ose. A few examples of these animated sequences can b e seen at http://kantine.diku.dk/~myth/gif/ 37 (b) Figure 4.21: (a) Slerp: Interpolation of a consecutive number of orientations (a path of orientations) with Slerp yields an edged path, non-differentiable. This is similar to affine space’s linear interpolation. (b) Squad: The same set of nodes interpolated using Squad gives birth to a smooth path. It is a differentiable curve and, additionally, angular velocity is also differentiable.(images credits to Erik B. Dam et all [75] ) f(qi−2, qi−1, qi+1, qi+2). tcan be computed using the chord length method presented in the previous section; the euclidean distance is replaced by an angular measurement: t=cos−1(qi−1qi) cos−1(qi−1qi) + cos−1(qiqi+1) •The final filtered orientation is a weighted interpolation between the smooth qs iand the measured orientation qi. For this, Slerp can be used. So: qfilt i= Slerp (qs i, qi, t). As ttakes values from 0 to 1 it gives more weight to the Squad result or to the measured orientation. 4.4.2 Path Segmentation This stage of data processing focus on breaking the whole trajectory in smaller segments. Industrial robots programming is about chaining movement instructions and I/O control commands. As such, path segmentation is performed on 2 steps: I/O based segmentation and movement-type segmentation. The first step splits the path according to the synchronized I/O list (recall the synchronized lists from Fig. 4.16). This is accomplished by looking at the I/O signal 90 4.4 Interfacing an Industrial Manipulator time-stamp on the list and then grouping the 3D trajectory points between two I/O changes – Fig. 4.22 illustrates this procedure. This is a necessary step due to how industrial robot controllers deal with external I/O interfaces. The use of these signals, either being it reading an input or writing an output, takes place in-between movement instructions. As such, the move-type-instruction chaining must pause to insert the I/O control; then it makes sense to break the path when such event occurs is it follows the natural way robot controllers deal with path points and I/Os. I/O Change I/O Change I/O Change I/O Change Segment 1 Segment 2 Segment 3 Segment 4 Figure 4.22: Trajectory Segmentation Based on I/O Changes - The first stage of segmentation is based on the I/O change list. The 6D points are grouped into sets of consecutive points in-between two I/O changes. This is a mandatory action since robot controllers execute movement instructions and I/O control sequentially. The second step for segmentation is the interpretation of trajectory points as well defined geometric movements. Programming interfaces from standard manipulators already implement linear interpolation of both position and orientation between two 6D points; so, it is the job of segmentation to cluster a set of 6D points and write them as a single linear movement. Doing it for the entire path makes possible to chain consecutive move-linear instructions and automatically create a robot program. First, parts of the trajectory that do not show any type movement must be detected, i.e, it is necessary to identify motion stops. This is accomplished by analysing the velocity between to consecutive points: if the value is smaller than a given threshold, kvk2< vthres, than the marker is assumed to be stopped in the same position. Computing velocity from the trajectory data is straightforward since both position (M) and time(t) are known 91 4. MOTION IMITATION FRAMEWORK are each instant i: vi=Mi+1 −Mi ti+1 −ti (4.24) The remaining of the trajectory points represent a motion of some kind and are now processed in order to achieve the desired segmentation. As there are different applications and requirements, two methods are proposed: 1. Segmentation of a free hand movement. This method is adequate for any application where the operator may need to perform free movements, i.e, movements with high degrees of liberty. For instance, a spray painting of elaborated shapes where the spray gun needs to execute complex, unstructured moves. This method can be the starting point for any application since it is assumed that the output path is very unpredictable. This type of trajectory segmentation uses all the points collected from the tracking system and simply creates a robot instruction that moves to each point — Fig. 4.23. Velocity is computed using the 3D position and time stamp as referred above on equation 4.24. A set of move-line instructions are used to reproduce the path, making the robot perform a straight line between each point. Figure 4.23: Moving linearly to each point - In this method of trajectory segmentation all the points are used. A move-linear instruction is used to follow the path by going through every point. The corresponding robot code is extensive but the resulting path is more faithful to the captured trajectory 2. Path Segmentation into Move-Linear Instructions. This method fits better to applications where there is some a priori knowledge about the type of movement 92 4.4 Interfacing an Industrial Manipulator the human operator is supposed to perform. For instance, welding of metal sheets; unlike the previous method, here it is expected that the operator performs a set of straight lines instead of a complex free movement through the whole workspace. This path segmentation method uses 4D-line fitting to break the trajectory into line segments. Given a set of points in space, Mi= (xi, yi, zi), there is a line that best fits the points, in a least squares sense [78]. The line l(t) is defined by l(t) = ¯ M+td(4.25) where ¯ Mis a point on the line and dis the (unit) direction vector. Each point Mican be decomposed into two components: one along the line (md) and another orthogonal to it (m⊥): Mi=¯ M+mdd+m⊥di⊥(4.26) where di⊥is the unit vector orthogonal to the line passing through Mi.m⊥is the component of Mithat contributes to the fitting error, i.e, the orthogonal error. The squared distance is ei= (kmi⊥di⊥k2)2=m2 i⊥(4.27) Then, the least squares minimization sets its goal to min n X i=0 ei= min n X i=0 m2 i⊥(4.28) From Equation 4.26: m2 i⊥=Mi−¯ M−mid2(4.29) The solution for this minimization [78] sets ¯ Mas the average of the points Mi ¯ M=¯x¯y¯z,¯x=1 n n X i=1 xi(4.30) that is, the line goes through the average of points. The direction dis given by the singular value decomposition of the covariance matrix Q: A=    M1−¯ M . . . Mn−¯ M    =   x1−¯x y1−¯y z1−¯z . . .. . .. . . xn−¯x yn−¯y zn−¯z   (4.31) Q=ATA(4.32) 93 4. MOTION IMITATION FRAMEWORK hUSVTi= SVD(Q) (4.33) dis the eigen vector vicorresponding to the largest singular value σiof Q V= [v1,v2,v3] ; S= diag (σ1, σ2, σ3) (4.34) Since each point of the trajectory has a time stamp, it means that the path can be seen as a 3D-positions time series. To split the entire path into lines, the line fitting is recursively used in the following steps: •Fit all data available to a 3D line and compute the error: e= n X i=1 dist⊥(Mi, l)2(4.35) dist⊥is the procedure that computes the orthogonal distance from the point to the line. •If the error is too large, e>σmax (σmax is an adjustable parameter, defining how rough the approximation can be), find the point Mme that has the largest error maxi(ei). •Take all points up to Mme (up to its time) and start again. •When a line is fitted, re-run the algorithm for the remaining points (from Mme onwards). The 3D fitting has a problem with backtracks, i.e, if the path follows one direction and then comes back (going back and forth in the same direction), the whole set of points are approximated by a single line. Fig. 4.24 (a) shows an example of this situation; red points move from left to right and blue points from right to left. A simple way to solve backtracks is to extend the 3D line fitting into 4D where the added dimension is time. As such, equations 4.25-4.34 are extended into 4 dimensions with Mi= (xi, yi, zi, ti) — those equations remain valid for nD. The geometric interpretation is shown in Fig. 4.24 (b): backtracks clearly become distinct directions. The previous algorithm is computationally fast given that the trajectory has been previously split by I/O changes and motion stops — so that the number of points to consider in each step is already reduced. 94 4.4 Interfacing an Industrial Manipulator (a) t (b) Figure 4.24: (a) A back track in 2D/3D: using only spacial information backtracks are not detected. The red dots represent positions of a movement going from the left to the right; blue circles are a path in the opposite direction. Using all the points in a 3D line fitting method comes up with the grey line. (b) Adding time as an extra dimension to data: the image represents a scheme of adding a 4th dimension (time) to each point. Backtracks now clearly point in a different direction. Note: the noise on red/blue dots are not in the time axis; this is still a variation on the xy plane; the visual feeling results from the 2D view. 95 4. MOTION IMITATION FRAMEWORK Figure 4.25: Trajectory Segmentation in Linear Movements - After the recursive 4D line fitting algorithm the trajectory is composed of consecutive lines. This method is useful for applications where it is known that the operator wants to execute well structured movements; this segmentation removes much of the noise associated with hand jitter. The resulting robot path is more ”rigid” than the previously presented method since there are now less and longer segments — Fig. 4.25. Finally, the sequence of line segments li(t) defined by the start and end points, li(0) and li(1), make up the path. Yet, in long lines, care must be taken for non-uniform linear and angular velocity. To address this issue, each line segment is evaluated at different positions t, computed using once again the chord length of the original points. This way, there is no averaging the velocity, and linear interpolating rotation, between the start and end points. Instead, the segment is divided and, for each piece, the velocity is computed from the original points, and orientation is linearly interpolated within each piece. This method forces the whole line to have different linear and angular velocities, and does not assume the shortest path of orientation between ends. If the original path does not have such dynamics than this is just a point over-head in the final program; if such changes do occur, the playback is able to mimic it. The line-segmentation has the added effect of smoothing both position and orientation. Since a group of consecutive points is replaced by a line, the noise between the start and end points are substantially reduced. Additionally, the move-line instruction of industrial robots also implements a linear interpolation of orientation so rotation is also smoothed using this approach. At this point, by either method, the list of consecutive linear movements can be used to automatically generate a program for the industrial manipulator. 96 4.4 Interfacing an Industrial Manipulator 4.4.3 Automatic Code Generation The last stage on the programming by demonstration framework is to generate the robot program. Taking the points/lines obtained from the previous algorithms and stacking up a list of strings with robot instructions is rather simple. Yet there is one last issue that must be addressed: velocity smoothness. It is not related to the data itself but to how robot controllers interprets the program and do the joint control. When the robot travels from point M0to point M1by a move-linear instruction instruction: move-linear, M1,V=V1, Tolerace=Tol (4.36) the linear velocity Vmust be specified along with a tolerance, tol parameter. As already discussed, velocity is computed from the current and previous point and their respective time stamp: vi= (Mi−Mi−1)/(ti−ti−1) (or the start and end points of line segments). Tolerance sets how close to position M1the robot actually moves to. Usually this parameter is specified in millimetres. Figure 4.26 (left) shows a geometric interpretation of this parameter (in 2D): as soon as the robot’s tool tip is at a distance tol from the target M1the controller assumes the movement has been accomplished and stops the robot or starts the next instruction. Additionally, the robot controller implements a trapezoidal control for robot velocity, which means that when it leaves point M0it starts accelerating then it reaches nominal velocity V1during the line, and finally, starts decelerating until M1. If the tolerance parameter is kept too low, for instance zero (the robot moves to M1with full accuracy) then the robot will decelerate until a stop and only then moves on to the next target. This generates a “hiccup-like” movement due to the full stop at each point. If the target points from the tracking system are directly used in the movement instructions then two situations can happen: 1. The tolerance parameter is set to zero, tol = 0, to insure the robot goes exactly through the points captured by the vision system. This is the ideal in terms of positioning. Yet, due to the full stops at each point, the movement has no velocity continuity; instead of continuously flowing through the points, the robot stops at each line-end causing the sobbed behaviour. 2. The tolerance parameter is set to some value grater than zero, in such a way that when it enters the tolerance sphere it has not started to decelerate (the tolerance value must be accessed by investigating the acceleration and deceleration 97 4. MOTION IMITATION FRAMEWORK parameters of each robot type/brand). If there are any further instructions, the robot will start executing them before coming to a stop. This ensures velocity is smooth as lines are performed one after the other with no deceleration due to the positioning controller. This smoothness comes with the price of adding error to the position; the target points from the tracking are not fully respected. To overcome this issue additional control points are computed from the desired path. So, for a sequence of moves M0→M1→M2, control points M0 1and M00 1are created as an extension in the direction of the movement — Fig. 4.26 (right) — such that M0 i=Mi+tol ∗Mi−Mi−1 kMi−Mi−1k2 (4.37) It means that instead of moving to M1the robot will move to M0 1which is further away from M1by the distance tol in the same direction of the movement. Then, the tolerance parameter can be effectively applied because the robot will not reach M0 1: it will start moving in that direction and will stop (or proceed to the next step) when it is at a distance tol from M0 1therefore being over M1.M00 1is a point in the direction of M2but closer to M1so that the robot does not follow the line M0 1—M2but stays on M1—M2. tol M0 M1 M2 M0 M1 M0 1 M00 1M2 Figure 4.26: Tweaking the Robot Trajectory Controller Tolerance - On the left side of the picture there is a geometric interpretation of the robot tolerance parameter: upon reaching at a distance tol of the target point the robot starts executing the next instruction; it does not go exactly over M1. On the right side there is a scheme for the compensation of this feature. The robot is given a target point a little bit further ahead from the real target in order to assure that it actually goes through M1. 98 4.4 Interfacing an Industrial Manipulator This tweak ensures velocity smoothness along the path as well as smoothness in the transition between consecutive lines due to the small arc the robot performs in order to maintain velocity constant. From here, the code generation is straightforward as points give rise to robot instructions: Robot Program MOVJ P1 : VINI MOVL P2 : V=V2 MOVL P3 : ... MOVL P6 : ... MOVL P7 : ... MOVL P9 : ... MOVL P11 : ... MOVL P12 : ... MOVL P17 : ... Figure 4.27: Automatic Robot Program Generation - From the 6D points and velocities is it easy to automatically generate a robot program: each point or line end is mapped into a move-line instruction. This approach is valid for any robot brand as this instructions work the same way in industrial manipulators. 99 5. TESTS AND RESULTS 5.5 shows the CAD model of the developed tool which holds the calibration LED and is attached to the robot end-effector. Figure 5.5: CAD Model of the Calibration Tool - This object is attached to the robot end-effector and holds a single LED near the tip. This LED is turned ON at each node of the calibration grid and allows capturing a pair of images corresponding to the node position in space. Tables 5.1 and 5.2 shows de calibration error for the stereo arrangement. The analysis is done in two ways: the deviation in each axis alone, x/y/z, and the absolute deviation of the stereo 3D point to the real known coordinate. The error is defined by the ncalibration points Pi= (xi, yi, zi) and the corresponding estimates from the stereo ˜ Pi= (˜xi,˜yi,˜zi). The n×3 error matrix E(xyz)is defined as P=   x1y1z1 . . .. . .. . . xnynzn   =   P1 . . . Pn    E(xyz)=P−˜ P E(xyz) iis the cartesian deviation on point i. The total deviation error at each point is given by Ei=  E(xyz) i  2, i.e, the distance from the real and the estimate position. Figures 5.6,5.7 and 5.8 hold plots for the variation of the absolute error in the x,y and zaxis. 106 5.2 Tests and Results Table 5.1: Calibration error on x,yand zaxis: Four measures are presented for each axis: the mean error, the mean absolute error (MAE), the maximum absolute error and the root mean squared error (RMSE). Since the model is unbiased, ¯e≈0, the RMSE coincides with the standard deviation. Calibration Error (X, Y, Z) (all measures in mm) x y z Mean Error: ¯ E(xyz)=1 nPE(xyz)2E-05 -5E-04 3E-05 Mean Absolute Error: MAE= 1 nPE(xyz) 0.36 1.23 0.34 Max. Absolute Error: maxei=  E(xyz)  ∞ 2.20 5.29 1.22 Standard Deviation: σ=s1 n−1P iE(xyz) i20.47 1.58 0.42 Table 5.2: Calibration error: It is measured as the euclidean distance from the expected position Pto the estimated ˜ P. Calibration Error —   P−˜ P  2 (all measures in mm) Mean Error 1.4 Max Error 5.7 Std. Deviation 9.8E-01 107 5. TESTS AND RESULTS Table 5.1 shows that the stereo model is unbiased in every direction since the mean error is approximately zero in each axis. As expected, the smaller errors are present in xand zaxis as they are fairly aligned with camera’s uand vaxis, respectively — the absolute error is almost the same for xand y. The measures along the yaxis show larger errors and are the major responsible for the total deviation error presented on Table 5.2. The average position error is 1.4mm and the average yerror is 1.3mm; the same happens for the maximum error. This is justified with the fact that the yaxis stands as the stereo depth axis. With a two camera arrangement it is expected that points further away present larger errors. This can be seen at Figure 5.7: the negative Y coordinates are further away from the cameras and show increasing error as distance increases (cameras’ yposition coordinate is approximately 3000mm). On the other hand, the error remains almost constant among xand zdirections — Figures 5.6 and 5.8, respectively. The xaxis has increased error in the plot’s rightmost end since the positions get closer to the image border thus being affected with lenses distortion. Even though, the error show much more independence on xand zaxis whilst it clearly increases in the ydirection (right to left means stepping away from the cameras). It can be concluded that increasing camera resolution will have limited benefit to the global stereo precision as it primarily affects uand vdirections, xand zcorrespondingly; instead, having more cameras can significantly enhance the system precision. Particularly, having a second camera pair opposite to the first pair can be most advantageous. In such scenario, the error for negative ycoordinates would be a mirror of the positive coordinate tendency. 5.2.2 Marker Detection 5.2.2.1 Colour Calibration Colour calibration is achieved by moving the marker on the entire workspace with only one colour lit at a time. Figure 5.9 shows the HSV circle with the sampled hue values for each colour (each line represents a measure). It can be clearly seen that any two set of samples are disjoint except for yellow and red. Red is the most well defined colour (lowest hue variance among the samples) but yellow LEDs are made up from red and green; the red contribution imposes in some conditions and yellow clusters 108 5.2 Tests and Results 1,000 1,100 1,200 1,300 1,400 1,500 1,600 1,700 1,800 1,900 0 0.5 1 1.5 2 2.5 3 X coordinate (mm) Error (mm) Error = f(x) Figure 5.6: Error variation in the Xaxis - The figure plots the calibration error as a function of the position’s xcoordinate. −500 −400 −300 −200 −100 0 100 200 300 400 500 0 0.5 1 1.5 2 2.5 3 Y coordinate (mm) Error (mm) Error = f(y) Figure 5.7: Error variation in the Yaxis - The figure plots the calibration error as a function of the position’s ycoordinate. 109 5. TESTS AND RESULTS 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 0 0.5 1 1.5 2 2.5 3 Z coordinate (mm) Error (mm) Error = f(z) Figure 5.8: Error variation in the Zaxis - The figure plots the calibration error as a function of the position’s zcoordinate. are evaluated as red. As it will be made clearer ahead, this class interception do not jeopardize the marker tracking. 5.2.2.2 Detection and Pose Estimation The sincrovision concept, allied to optimized camera exposition and LED driver electronics allow a very robust detection of each individual LED in the image. Camera exposure was set to 3ms which is also the ON time for the LEDs. With this short duty cycle, 3ms@25fps = 7.5%, LEDs were driven at 10 times their rated current. The detection was evaluated according to the number of (un)successful marker detection: how many times individual LED colours were misinterpreted, how many times position and orientation estimation failed. Remark: These results intend to state the quality and robustness of the implemented algorithms and not of any specific hardware. Therefore, the following results do not take in concern possible hardware failures; for instance, the USB cameras failing to deliver some image frames and/or the operating system drivers failing to put together 110 5.2 Tests and Results R YG B P 0◦ 60◦ 120◦ 240◦300◦ Figure 5.9: HSV Colour Classes Calibration - The figure shows the collected samples from each LED after moving it around the workspace. Almost all classes are separable with exception to yellow and red. the received data in the USB bus thus bringing forth a misconceived image. Some of these problems were experienced in the industrial setup and worsen as more cameras were plugged into the same computer. Despite being rare occurrences, the results for this section were evaluated only on good image frames. The following results were determined after the evaluation of 50000 paired image frames from roughly 30 different human demonstrations. Table 5.3 summarizes the accuracy for image cluster classification. That is, given an image with a number of visible LEDs, how many times each colour was misclassified. The evaluation was done over 50000 stereo frames and this analysis is image-wise, therefore the results are for a total of 100000 image frames. False positives (F/P) for red mean that the cluster is of another colour and is classified as red; false negatives (F/N) mean that the cluster is red and was classified as other; the same reasoning applies to all other colours. For the 50000 stereo pairs, the successfulness of pose estimation is resumed in Table 5.4. It is divided in position and orientation estimation because different factors contribute for the output of each algorithm. Additionally, for the unsuccessful measures, it is given the number of failures (in brackets) derived from colour misclassification. The colour classification results, from Table 5.3, are clearly in tune with the results 111 5. TESTS AND RESULTS Table 5.3: Number of misclassification of image clusters sorted by colour: F/P are the false positives (another colour classified as the current) and F/N are false negatives (the current colour classified as some other). Image Analysis: 100000 frames Cluster Colour Classification F/P F/N Red 4544 (4.544%) 0 Green 0 0 Blue 0 0 Yellow 0 4544 (4.544%) Purple 0 0 obtained in colour calibration (discussed above, in Figure 5.9). All the colours are perfectly classified except for yellow. Yellow LEDs evaluation on hue parameter is very close to red. As such, there are many detections where a yellow cluster is tagged as being red. Despite that, the pose estimation algorithm is robust enough to eliminate these misclassification; as depicted in Table 5.4, only 37 detections went wrong due to the bad classification. On one hand, the misclassified yellow do not have a matching cluster on the other image so it will never give birth to a 3D point that can used in the position estimation; the sphere fitting is unaffected by colour classification. On the other hand, if the yellow LED would complete a ”Y” in the image — the pattern used for orientation estimation — then the misclassification may lead to having no complete ”Y”; this is the scenario that contributes for 37 orientation estimation failures; the remaining are rare situations where no complete ”Y” is seen yet all colours are well classified. Over the 30 demonstrations used for these tests, the pose could not be estimated for an average of 3 times per demonstration. It means that there are three 40ms ”holes” in the final path. This is completely negligible over a 1500-positions/one-minute-long trajectory. The smoothing algorithms will later fill in these holes. 112 5.2 Tests and Results Table 5.4: Evaluation of the position and orientation estimation: The success and failure rate for each algorithm is presented for a total of 50000 successfully paired image frames. Since orientation depends on colour classification, the number of failures due to colour misclassification is shown in brackets. The complete pose estimation performance is held at the last sub-table. Stereo Frames: 50000 pairs Position Estimation Success Failure 50000 [100%] 0 [0%] Orientation Estimation Success Failure (due to colour) 49919 [>99.8%] 81 (37) [<0.2%] Complete Pose Estimation Success Failure >99.8% <0.2% average/per demonstration (1500 frames) <3 fails 113 5. TESTS AND RESULTS 5.2.3 Marker Accuracy in the Workspace The pose precision was accessed using the same principle of camera calibration: the marker was attached to the robot’s end-effector and the same routines were used to sweep the entire workspace. Therefore, the robot moved in a grid like pattern and samples were collected at each node. To estimate position accuracy the manipulator was set to move in a 100mm grid. This renders a total of 305 positions; at each position 10 samples were collected. The (robot) coordinates from the 305 test positions are well known as they are read from the robot controller; also, the manipulator was moved to the target positions and allowed to remain there for 4 seconds in order to minimize vibrations. To estimate orientation accuracy, the robot was stopped at 5 different positions. At each one, the orientation was incrementally changed by 30◦for a total of 60 different orientations: for example, Rx= [0,30,60]×Ry= [0,30, ..., 90]×Rz= [−60,−30, ..., 60]. In the end there are 300 orientations to evaluate. Tables 5.5 and 5.6 resumes the marker pose accuracy; the analysis is done along each direction and also for the euclidean error/shortest angle between the position/orientation estimate and the ground truth. Table 5.5: Marker position error on x,yand zaxis: Four measures are presented for each axis: the mean error, the mean absolute error (MAE), the maximum absolute error and the standard deviation. Marker Pose Error (X, Y, Z) — (Rx, Ry, Rz) (all distances in mm, angles in degrees – ◦) x y z RxRyRz Mean Error 0.52 -2.1 0.9 0.5 -0.2 -0.5 Mean Absolute Error 1.1 3.2 1.9 1.0 0.8 1.1 Max. Absolute Error 3.6 8.2 5.4 4.1 3.9 3.6 Standard Deviation 1.5 2.9 1.7 2.2 2.1 1.8 114 5.2 Tests and Results Table 5.6: Marker pose error: Marker position error measured as the euclidean distance from the expected position Mto the estimated ˜ M. For orientation, the absolute error is the shortest path (angle) between the two orientations which is computed from the angle between the two corresponding quaternions, qMand q¯ M. Marker Position Error: E=  M−˜ M  2, and Orientation Error: θ= 2 cos−1q−1 Mq∗˜ M ( all distances in mm, angles in degrees ◦) E θ Mean Error 3.8 1.7 Max Error 8.9 6.2 Std. Deviation 2.7 2.1 ∗shortest angle between 2 quaternions Comparing these results (Tables 5.5 and 5.6) with those for a single LED in the calibration procedure (recall Tables 5.1 and 5.2) it can be seen that the error has increased globally. With the two-camera arrangement, going from one LED (which tracks translation alone) to the whole marker (which tracks six degrees of freedom) penalizes accuracy in a few millimetres. First, the error pattern is no longer unbiased; it is specially noticeable along the ydirection, i.e, the depth axis. This happens due to the biased placement of the cameras, that is, the pair of devices being installed only on one side of the workspace; the sphere fitting algorithm receives samples from just a small area around the sphere. Since the cameras are aligned horizontally, i.e, along the robot xaxis, the position error tends to be lower along that direction. Concerning orientation, each direction seems equally affected by the estimation noise. 5.2.4 Filtering and Smoothing Evaluating the performance for the B-Spline smoothing is not easy since there is no measure of the real path of the human hand; that is, there is no ground truth for the free hand movement. Therefore, a set of path segments were analysed and are presented for visual inspection. The comparison is always done against the piecewise linear path, i.e, when the tracking points are connected through a line. 115 5. TESTS AND RESULTS 1,450 1,500 1,550 1,600 1,650 1,700 1,750 1,800 1,850 1,900 −200 0 200 450 500 550 600 650 700 Real Spray Painting Path (dimensions in mm) B-Spline 350pts — 2xFt Piecewise Linear Figure 5.17: Sampling of the B-Spline at 2 times the Tracking Frequency - The plot shows the piecewise linear approximation and the B-Spline curve. The spline is drawn using twice as much points as were originally captured by the tracking system. The linear tracks are still visible. Table 5.7: Sampling of the B-Spline Curve: This table shows the resulting number of points, their average spacing, the computational time and the final curve length for various sampling rates. The first entry is the original path, without spline smoothing. The next entries are for spline sampling at rates proportional to the tracking frequency. Sampling Rate No Points Chord Length (mm) Avg. Point Spacing (mm) Comp. Time (ms) Piecewise Linear @ Ft 1750 64580 37.0 0 1xFt 1750 62590 35.8 40 2xFt 3500 62830 18.0 64 4xFt 7000 62870 9.0 115 8xFt 14000 62890 4.5 215 16xFt 28000 62890 2.2 426 32xFt 56000 62890 1.1 839 122 5.2 Tests and Results 1,450 1,500 1,550 1,600 1,650 1,700 1,750 1,800 1,850 1,900 −200 0 200 450 500 550 600 650 700 Real Spray Painting Path (dimensions in mm) B-Spline 700pts — 4xFt Piecewise Linear Figure 5.18: Sampling of the B-Spline at 4 times the Tracking Frequency - The plot shows the piecewise linear approximation and the B-Spline curve. The spline is drawn using 4 times as much points as were originally captured by the tracking system. The path appears smooth and the linear tracks are not visible. 123 5. TESTS AND RESULTS 1,450 1,500 1,550 1,600 1,650 1,700 1,750 1,800 1,850 1,900 −200 0 200 450 500 550 600 650 700 Real Spray Painting Path (dimensions in mm) B-Spline 1400pts — 8xFt Piecewise Linear Figure 5.19: Sampling of the B-Spline at 8 times the Tracking Frequency - The plot shows the piecewise linear approximation and the B-Spline curve. The spline is drawn using 8 times as much points as were originally captured by the tracking system. Visually there is no improvement over the 4 times the tracking frequency, presented in Figure 5.18. Yet, it costs double its computational time and twice more points. 124 5.2 Tests and Results hand movement is quite precise: x(t) shows how linearly the movement is going from the beginning until the end of the tray at constant velocity; z(t) is the distance to the work piece, and the human operator can keep it almost constant over the entire path, i.e, the spray gun is kept at constant distance from the object ensuring the constant spraying over the surface; y(t) is an almost perfect periodic movement of the side to side swinging over the surface. As a whole, this path clearly shows the expertise of the operator. 01234567 −500 0 500 1,000 1,500 2,000 t[s] position [mm] X(t) Y(t) Z(t) Figure 5.20: Path decomposed into X(t),Y(t)and Z(t) - The x,yand zcomponents of the painting path plotted against time. It gives some insight on the precision of the human operator movements. Figure 5.21 shows the same data adding the B-Spline to each curve. The spline and the original positions are almost indistinguishable; despite that, it has already been shown that the B-Spline is actually smoothing the path. This shows how in spite of smoothing through the points and not passing over them, the B-Spline still holds the essence of the movement, i.e, it does not change the pattern nor the speed of the original path; the real operator’s know-how is kept after the path smoothing. Looking closer, as in Figure 5.22, the B-Spline is eliminating the noisy data while preserving the frequency and the geometry/shape of the demonstrated trajectory. 125 5. TESTS AND RESULTS 01234567 −500 0 500 1,000 1,500 2,000 t[s] position [mm] X(t) Y(t) Z(t) Spline Figure 5.21: B-Spline smoothing of X(t),Y(t)and Z(t) - The B-Spline curve does not change the main shape of the trajectory; instead it cleans up noise and hand jitter. The resulting path is very similar to the original one. 5.2.5 Timings One of the most advantageous features of this motion mimic framework is to deliver an instant playback of the demonstrated movement. Even if the high level programming is achieved, it is important to reduce setup times. Also, a given demonstration may not be successful on the first try; if the movement mimic consumes too much post-processing time (i.e, the operator needs to wait an extended time to see the result) then the high level interface is still carrying expensive downtime and becomes unfeasable. Table 5.8 presents the processing times for both the online and offline processes that make up the motion demonstration system. The online stages are those being executed as image frames arrive; it includes the image debayer (conversion of the bayer pattern into the RGB in some colour cameras), cluster detection and classification, matching clusters from different cameras and 3D retrieval, and finally pose estimation. The offline steps include the trajectory smoothing and the generation of the robot program. The tracking (all processes up to the marker pose estimation) is done in real-time which adds another powerful feature to the framework: the robot can be moved in real- 126 5.2 Tests and Results 2.4 2.5 2.6 2.7 2.8 2.933.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4 1,700 1,720 1,740 1,760 1,780 1,800 1,820 1,840 1,860 t[s] X position [mm] X(t) Spline (a) 1.4 1.5 1.6 1.7 1.8 1.9 2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3 −400 −300 −200 −100 0 100 200 300 t[s] Y position [mm] Y(t) Spline (b) 2.4 2.5 2.6 2.7 2.8 2.933.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4 400 420 440 460 480 500 520 540 560 580 600 t[s] Z position [mm] Z(t) Spline (c) Figure 5.22: (a,b,c) Zoom view of B-Spline with X(t),Y(t)and Z(t): the spline eliminates the high frequency noise while preserving the shape of the path. 127 5. TESTS AND RESULTS time, for instance in an attempt of accessing reachability and reproducibility before the definitive demonstration, or for teleoperating the robot in some applications. The B- Spline smoothing and code generation take place after the demonstration is concluded but the processing time involved is far below 1 second which makes it perfectly unnoticeable to the user. Even the communication with the robot controller and uploading the program do not consume more than a couple of seconds. Therefore, the robot is ready to perform right after the demonstration has ended. Moreover, looking at the online processing times it can be concluded that less than 15% of the available time is being used — 6ms at 25 frames per second means 6ms/40ms = 0.15. This makes it possible to increase camera resolution or even the frame rate whilst maintaining the real-time capability. 128 5.2 Tests and Results Table 5.8: Processing times for every stage of the motion demonstration: The results are divided in online and offline: the former set is done in real-time as the images come in from the cameras; the later include the routines that need the whole trajectory and, as such, can only be executed when the demonstration is complete. The offline processes clearly dominate processing time yet they barely take more than one second. The tests were run on a core i7 @2.8GHz , under a Fedora 16 installation. Routine Time (ms) Online Image Debayer 2.2 Cluster Detection & Classification 2.6 2-Camera Cluster Matching and 3D Retrieval 0.5 Pose Estimation 0.6 Total <6 Offline Filtering and Smoothing 74.7 Robot Program Generation 220 Communication and Upload 1000 Total <1300 129 5. TESTS AND RESULTS 130 Chapter 6 Conclusions 6.1 Global Assessment and Conclusions In the domain of industrial applications, this research begun with the two available workforces: on one side, the skill-full human operator; on the other, the productive robotic manipulator. In-between there are set of companies, SMEs, that mostly rely on the former to deliver quality, and eager for the other to have the edge in an increasingly competitive global economy. Technology-unaware operators and complexlyprogrammable machines fail to interface each other. This thesis described a high level programming framework that ultimately delivers the possibility of transferring human know-how to the industrial manipulator. It proposes a new mean for human motion tracking based on an innovative marker together with a collection of routines that allows a real-time interface with the robot. And it does so while caring for the most crucial elements for a successful industrial implementation in low budget companies: the low cost, the simplicity (minimal changes required to working cells, minimal intrusion in the process, minimal human interface), readiness (instant output, real-time capability) and flexibility (possible different marker sizes, number of cameras, workspace volume, adjustable precision). The goal of allowing an human to program an industrial manipulator with complete abstraction of programming concepts has been achieved. But in addiction, it happens while the operator is kept in his area of comfort: doing the everyday tasks, putting his skills on work. Instead of an human-robot interaction scheme where the operator needs to learn a new tool to intuitively command the robot, this framework also allows 131