TREBALL FI DE GRAU

Grau en Enginyeria Mecànica

MECHANICAL DESIGN OF A PHOTOGRAMMETRY IMAGING PLATFORM FOR PROTOTYPE MESHING

Volume I (of III)

Report

Author: Carlos Gómez Gaibar Director: Pedro Ortiz Morón Call: June 2017

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

TABLE OF CONTENTS

1. OBJECTIVE, BACKGROUND AND MOTIVATION ...... 1

2. PHOTOGRAPHY AND PHOTOGRAMMETRY: A BRIEF DESCRIPTION ...... 2

2.1. Photography ...... 2

2.2. Photogrammetry ...... 2

3. WORKING PRINCIPLES AND APPLICATIONS OF PHOTOGRAMMETRY ...... 4

4. PATH TOWARDS THE CHOICE OF A SPECIFIC APPROACH ...... 6

4.1. Laser reconstruction and Surface from Motion (SFM) ...... 6

4.1.1. The use of laser in 3-D reconstruction operations ...... 6

4.1.2. Direct, realistic results ...... 6

4.2. Turntable vs orbiting camera ...... 6

4.2.1. Shadow casting issues ...... 7

4.2.2. Need for a static scene ...... 7

5. PROBLEM SOLVING AND IMPLEMENTED SOLUTIONS ...... 9

5.1. Design restrictions and guidelines ...... 9

6. COMMERCIAL ELECTRONICS ...... 11

6.1. ACER emachines EM355 Netbook ...... 11

6.2. Raspberry Pi Model B ...... 11

6.3. Logitech QuickCam Pro 9000 ...... 12

6.4. Stepper motor ...... 14

6.5. ULN2803 Stepper controller ...... 16

6.6. Raspberry Pi GPIO cobbler breakout board ...... 17

6.7. Wiring diagram ...... 20

7. INTRODUCTION TO STEPPER MOTORS ...... 21

I

Report

7.1. Stepper motors ...... 21

7.2. Advantages of stepper motors ...... 21

7.3. Limitations of stepper motors ...... 22

7.4. Step Count ...... 23

7.5. Gearing ...... 23

7.6. Coils and Phases ...... 24

7.7. 5-Wire motor ...... 25

7.8. 6-Wire Motor ...... 25

7.9. 8-Wire Motor ...... 26

8. COMMERCIAL MATERIALS ...... 27

8.1. Vertical support (617CV00) and horizontal beam (617CH00) ...... 27

8.1.1. T-nuts for slotted 20x20 square aluminum extrusion profile ...... 27

8.1.2. Aluminum L-plates (617CU00)...... 28

8.2. Mechanical union elements ...... 29

8.3. Low friction idle shaft subjection (617CR00)...... 30

8.3.1. Considerations regarding low friction solutions ...... 30

8.3.2. Load absorption and spacing ...... 31

8.4. Timing pulleys (617CP00) ...... 33

8.5. Timing belt (617CP0A/B/X) ...... 34

8.5.1. Option 1: Open-ended timing belt (617CP0X)...... 35

8.5.2. Option 2: Closed loop timing belts (617CP0A/B) ...... 36

9. MANUFACTURED PARTS ...... 38

9.1. Bearing support (617MH01) ...... 38

9.2. Stepper support (617MH00) ...... 39

9.3. Idle shaft (617MR00) ...... 41

9.4. Base clamp (617MV00) ...... 42

II

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

9.5. Base (617MB00) ...... 43

9.6. Webcam support (617MR02) and Fixing cap (617MR03) ...... 43

9.7. Rotating beam (617MR01) ...... 44

9.8. Safety jail (617MS00) ...... 45

10. WEBCAM DETECTION, SOFTWARE NEEDED AND SETUP ...... 47

10.1. Logitech QuickCam Pro 9000 compatibility with Raspberry Pi ...... 47

10.2. List and description of software packages to install ...... 47

11. STEPPER MOTION CONTROL VIA USER-FRIENDLY, EDITABLE CODE ...... 50

11.1. Control interface designs ...... 50

11.2. Python modules ...... 51

11.2.1. Tkinter and PyGTK ...... 51

11.2.2. RPi.GPIO module import ...... 51

11.3. System software calls from Python ...... 52

12. NETWORK AND INTERFACE SETUP ...... 53

12.1. Controlling the Raspberry Pi through a tactile display ...... 53

12.2. Connecting the Raspberry Pi directly to a computer ...... 53

12.2.1. Establishing a static IP for the Raspberry Pi ...... 54

12.2.2. Setting up the computer to allow the direct link ...... 55

12.2.3. Accessing the Raspberry Pi ...... 57

12.3. Calling the Control Interface ...... 59

13. OPERATION AND TESTING ...... 63

13.1. Device setup and motion control ...... 63

13.2. Logitech Webcam XML profile import...... 65

13.3. Image capture ...... 65

13.4. The use of VisualSFM for surface reconstruction...... 66

13.5. Mesh quality improvement by using MeshRecon ...... 68

III

Report

13.6. Post-processing ...... 71

13.6.1. Mesh cleaning ...... 71

13.6.2. Mesh texturization ...... 71

13.6.3. Final preparations ...... 73

14. RESULTS ...... 77

14.1. Quick review of the actions taken in this project ...... 77

15. ENVIRONMENTAL IMPACT STUDY ...... 80

15.1. Design phase ...... 80

15.2. Manufacturing and assembly ...... 80

15.3. Machine usage ...... 81

15.4. End of lifecycle ...... 81

15.5. Conclusions on the environmental impact study ...... 81

16. ECONOMIC IMPACT STUDY ...... 82

16.1. Material costs list ...... 82

16.2. Sales plan (5 years) ...... 83

16.2.1. Estimated production cost (per unit) ...... 83

16.2.2. Sales plan for 6170000 (5-year plan) ...... 84

16.2.3. Estimated sales (5-year plan) ...... 85

IV

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

INDEX OF FIGURES

FIGURE 6.1. ACER EMACHINES EM355 NETBOOK...... 11 FIGURE 6.2. RASPBERRY PI MODEL B MINI-COMPUTER...... 12 FIGURE 6.3. LOGITECH QUICKCAM PRO 9000 WEB CAMERA...... 12 FIGURE 6.4. WEBCAM WITH DISASSEMBLED MOUNT PART, AS UTILIZED FOR THIS PROJECT...... 13 FIGURE 6.5. 28BYJ-48 5-WIRE UNIPOLAR STEPPER MOTOR...... 14 FIGURE 6.6. 28BYJ-48 EXTERNAL DIMENSIONS AS PROVIDED BY THE MANUFACTURER...... 15 FIGURE 6.7. 28BYJ-48 STEPPER MOTOR INNER WIRING...... 15 FIGURE 6.8. 28BYJ-48 STEPPER MOTOR. BY OPENING THE TOP LID THE 64:1 GEAR TRAIN CAN BE OBSERVED...... 16 FIGURE 6.9. ULN2803APG DARLINGTON ARRAY...... 17 FIGURE 6.10. RASPBERRY PI GPIO COBBLER BREAKOUT BOARD...... 17 FIGURE 6.11. RASPBERRY PI GPIO EXTENDER CABLE...... 18 FIGURE 6.12. JUMPER CABLE SET TO CONNECT THE STEPPER TO THE BREADBOARD...... 18 FIGURE 6.13. BREADBOARD...... 19 FIGURE 6.14. STEPPER MOTOR DRIVER BOARD...... 19 FIGURE 6.15. SIMPLIFIED WIRING DIAGRAM...... 20 FIGURE 7.1. 28BYJ-48 GEARED STEPPER MOTOR, USED IN THIS PROJECT...... 21 FIGURE 7.2. VARIOUS TYPE OF SMALL SIZE STEPPER MOTORS AVAILABLE...... 22 FIGURE 7.3. 28BYJ-48 STEPPER MOTOR. BY OPENING THE TOP LID THE 64:1 GEAR TRAIN CAN BE OBSERVED...... 24 FIGURE 7.4. DIFFERENCES BETWEEN BIPOLAR MOTOR WIRING (LEFT) AND UNIPOLAR MOTOR WIRING (RIGHT)...... 24 FIGURE 7.5. FIVE-WIRE UNIPOLAR MOTOR...... 25 FIGURE 7.6. SIX-WIRE UNIPOLAR MOTOR...... 25 FIGURE 7.7. EIGHT-WIRE UNIPOLAR MOTOR...... 26 FIGURE 8.1. SLOTTED 20X20 ALUMINUM EXTRUSION PROFILE...... 27 FIGURE 8.2. SLIM T-NUTS WITH M4 THREAD...... 28 FIGURE 8.3. BUTTON HEX M4X10 MACHINE SCREWS...... 28 FIGURE 8.4. ALUMINUM L-PLATE...... 29 FIGURE 8.5. L-PLATES ASSEMBLING THE MAIN FRAME...... 29 FIGURE 8.6. PAIR OF Ø8XØ22X7 ABEC5 BALL BEARINGS...... 30 FIGURE 8.7. Ø8XØ22X7 FLANGED BALL BEARING...... 31 FIGURE 8.8. DETAIL OF THE WIDER SECTION OF THE IDLE SHAFT...... 32 FIGURE 8.9. BALL BEARINGS SPACED ALONG THE DRIVEN SHAFT...... 33 FIGURE 8.10. 20 TEETH, GT2 TIMING PULLEY...... 33 FIGURE 8.11. 36 TEETH, GT2 TIMING PULLEY...... 34 FIGURE 8.12. GT2 TIMING BELT TOOTH PROFILE (DIMENSIONS IN MM)...... 35 FIGURE 8.13. OPEN ENDED GT2 TIMING BELT...... 36 FIGURE 8.14. CLOSED LOOP GT2 TIMING BELT WITH A LENGTH OF 200 MM...... 37 FIGURE 9.1. BEARING SUPPORT...... 38 FIGURE 9.2. DETAIL OF THE BEARING PLACEMENT INTO THEIR SOCKETS...... 39 FIGURE 9.3. STEPPER SUPPORT...... 40 FIGURE 9.4. SLIDING ADJUSTMENT THAT ALLOWS CLOSED LOOP 200 MM TIMING BELTS AS WELL AS CUSTOM LENGTHS. . 40 FIGURE 9.5. IDLE (OR SECONDARY) SHAFT...... 42 FIGURE 9.6. BASE CLAMP COMPONENT...... 42 FIGURE 9.7. 15 MM PVC BASE...... 43 FIGURE 9.8. WEBCAM SUPPORT...... 43 FIGURE 9.9. FIXING CAP FOR WEBCAM SUPPORT...... 44 FIGURE 9.10. ROTATING BEAM...... 44 FIGURE 9.11. DETAIL OF THE SHAFT SOCKET...... 45 FIGURE 9.12. SAFETY JAIL...... 46 FIGURE 9.13. DETAIL OF THE OPENINGS FOR CABLE MANAGEMENT...... 46 FIGURE 10.1. COMPATIBILITY TABLE OF LOGITECH QUICKCAM PRO 9000...... 47 FIGURE 11.1. HTML5 INTERFACE LAYOUT, INITIALLY DESIGNED TO RUN FROM ANY WEB BROWSER CLIENT...... 50 FIGURE 11.2. MAIN INTERFACE MADE IN PYTHON...... 51 FIGURE 12.1. 7" CAPACITIVE TOUCHSCREEN FOR RASPBERRY PI MODEL B...... 53

V

Report

FIGURE 12.2. CMDLINE.TXT IN THE OS INSTALLATION SD CARD...... 54 FIGURE 12.3. SYSTEM SETTINGS UNDER TRISQUEL GNU/...... 55 FIGURE 12.4. NETWORK PANEL WITHIN SYSTEM SETTINGS. WIRED CONNECTION IS SELECTED...... 56 FIGURE 12.5. WIRED CONNECTION OPTIONS MENU, WITH SELECTED IPV4 SETTINGS TAB...... 57 FIGURE 12.6. 3D SCANNER.DESKTOP APPLICATION ON RASPBIAN’S BOTTOM PANEL...... 59 FIGURE 12.7. 3D SCANNER.DESKTOP SCRIPT CONTENTS...... 60 FIGURE 12.8. MAIN INTERFACE MADE IN PYTHON...... 60 FIGURE 13.1. ROOT DESKTOP WITH MAIN INTERFACE READY...... 63 FIGURE 13.2. DETAIL OF THE TARGET OBJECT PLACED ON THE CENTER OF THE SCANNING BASE...... 64 FIGURE 13.3. DETAIL OF THE CAMERA PITCH AND TILT, WHICH NEED TO CORRECTLY AIM TOWARDS THE OBJECT...... 64 FIGURE 13.4. SCANNING DEVICE CONNECTED AND READY TO FUNCTION...... 64 FIGURE 13.5. DETAIL OF A SERIES OF 15 OUTPUT IMAGES CAPTURED WITH THE DEVICE...... 66 FIGURE 13.6. SPARSE RECONSTRUCTION FROM VISUALSFM IN MANUAL MODE...... 67 FIGURE 13.7. DENSE RECONSTRUCTION USING VISUALSFM IN MANUAL MODE...... 67 FIGURE 13.8. POINT SET AFTER IMPORTING THE PROJECT INTO MESHLAB...... 68 FIGURE 13.9. CONTENT OF THE MESHRECON MAIN FOLDER...... 69 FIGURE 13.10. CONTENTS OF THE RESULTS FOLDER AFTER ANALYSIS...... 69 FIGURE 13.11. DETAIL OF THE NON-TEXTURED, NON-REFINED MESH_INIT.PLY...... 70 FIGURE 13.12. DETAIL OF THE NON-TEXTURED, REFINED MESH_REFINE.PLY THAT WILL BE USED FOR AS REPLICA...... 70 FIGURE 13.13. "PARAMETRIZATION + TEXTURING FROM REGISTERED RASTERS" OPTION IN MESHLAB...... 72 FIGURE 13.14. TEXTURIZED MESH. SOME DETAILS OF THE BASE AND BACKGROUND CAN BE OBSERVED...... 72 FIGURE 13.15. MESH_REFINE.PLY IMPORTED TO BLENDER...... 74 FIGURE 13.16. BASE VERTEX CLEANING BEFORE EXTRUDING...... 74 FIGURE 13.17. VERTEX EXTRUSION THAT WILL CONFORM THE OBJECT BASE...... 75 FIGURE 13.18. FACE FILLING OPERATION THAT CLOSES THE MESH BY THE STANDING PLATFORM...... 75 FIGURE 13.19. FINAL MESH SHAPE, AFTER POST-PROCESSING IN BLENDER...... 76 FIGURE 14.1. REAL SAMPLE OBJECT...... 77 FIGURE 14.2. 3D MESH AFTER RECONSTRUCTION...... 78 FIGURE 14.3. 3D PRINTED OBJECT, WHICH SHOWS SIMILAR COLOR FEATURES THAN THE ORIGINAL...... 78 FIGURE 16.1. SALES ESTIMATION GRAPH FOR A 5-YEAR SALES PLAN...... 85

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

VI

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

ABSTRACT

Photogrammetry is a technique which allows to determine the geometrical properties of objects or scenes from bi-dimensional images. Said technique is based on the use of complex algorythms which are able to detect similarities among different images that represent views of a single point in the space.

This project aims to be an example of application of protogrammetry techniques through open-source software, in order to make it accessible to anyone who wants to reproduce what is shown here. In order to do this, the minimum resources have been utilized to invent, design and build a machine which is capable to take a series of photographies in a stable, automatic fashion. Said machine is controlled by a Raspberry Pi mini-computer, equipped with a distribution of the GNU with the Linux kernel, which executes orders expressed in scripts in the Python language. These scripts are in charge to send the approppriate signals that make a small stepper motor installed on the machine structure to make a web camera to orbit around a small object.

Once the images are taken, they are extracted and introduced into a computer with enough processing power to perform the object’s 3D reconstruction tasks. Once this is finished a refined and optimized mesh is obtained, which contains the reconstructed geometry of the object. Then repairing and texturing tasks are carried through. Following to this, manual modifications are applied in order to obtain a mesh whose surface is free of holes, and the result of this is ready to be 3D printed by using any of the printing techniques currently available.

This project exposes the issues that have been addressed when thinking up this device, as well as the implemented solutions to accomplish a working prototype and its components, both as commercial solutions as well as regarding the design and manufacturing of the specific components. The designed parts have been 3D printed in polyamide by placing a manufacturing order, although the use of this technique and material has been chosen based on previous experience and it is not mandatory for this project. This being so, it can be accomplished by choosing materials which provide the same or higher mechanical features, the same way that it is possible to modify the geometry of said parts in order to make their manufacturing easier, as long as said modification does not affect their working principle.

VII

Report

RESUM

La fotogrametria és una tècnica que permèt determinar les propietats geométriques d’objectes o escenes a partir d’imatges bidimensionals. L’esmentada tècnica es basa en l’ús de complexes algoritmes que són capaços de detectar similituds entre diferents imatges que representen vistes d’un mateix punt a l’espai.

Aquest projecte pretèn ser un exemple d’aplicació de les tècniques de fotogrametria mitjançant programari de codi lliure, de manera que sigui accessible a qualsevol que pretengui reproduïr allò que aquí es mostra. Per a tal fi això s’han fet servir els mínims recursos necessaris per a idear, dissenyar i construïr una màquina que sigui capaç de prendre una sèrie de fotografies de manera estable i automática. L’esmentada màquina està controlada per un miniordinador Raspberry Pi equipat amb una distribució del sistema operatiu GNU amb nucli Linux, que a la vegada executa ordres expressades en scripts en llenguatge Python. Aquests scripts són els encarregats d’enviar els senyals adequats que fan que un petit motor pas a pas instal·lat a l’estructura de la màquina sigui capaç de fer orbutar una càmera web al voltant d’un objecte petit.

Un cop capturada la sèrie d’imatges es procedeix a la extracció i posterior introducció de les mateixes a un ordinador amb suficient potència de processament com per a dur a terme les tasques de reconstrucció 3D del objecte. A l’acabar aquest procés s’obté una malla refinada i optimizada que conté la geometria reconstruïda de l’objecte, i es procedeix a la seva reparació i texturitzat. A continuació s’hi apliquen modificacions manualment per a aconseguir una malla la superfície de la qual no presenti forats, i el resultat d’això està llest per a imprimir-se en 3D utilitzant qualsevol de les tècniques d’impressió disponibles actualment.

Aquest projecte exposa la problemàtica que s’ha abordat a l’hora d’idear el dispositiu, així com les solucions adpotades per a dur a terme un prototip operatiu i els seus components, tant en forma de solució comercial com en quant a disseny i fabricació dels components específics. Les peces dissenyades s’han imprès en 3D sota comanda, en poliamida, tot i que l’ús d’aquesta tècnica i material s’ha escollit basant-se en experiències prèvies i no és imprescindible per a aquest projecte. Així doncs, es pot realitzar escollint materials que proporcionin iguals o majors característiques mecàniques, d’igual manera que és possible modificar la geometria de les esmentades peces per a facilitar la seva fabricació, sempre que aquesta modificació no afecti al seu principi de funcionament.

VIII

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

RESUMEN

La fotogrametría es una técnica que permite determinar las propiedades geométricas de objetos o escenas a partir de imágenes bidimensionales. Dicha técnica se basa en el uso de complejos algoritmos que son capaces de detectar similitudes en distintas imágenes que representan vistas de un mismo punto en el espacio.

Este proyecto pretende ser un ejemplo de aplicación de las técnicas de fotogrametría mediante software de código libre, de modo que sea accesible a cualquiera que pretenda reproducir lo aquí mostrado. Para ello se han utilizado los mínimos recursos necesarios para idear, diseñar y construír una máquina que sea capaz de tomar una serie de fotografías de manera estable y automática. Dicha máquina está controlada por un miniordenador Raspberry Pi equipado con una distribución del sistema operativo GNU con núcleo Linux, que a su vez ejecuta órdenes expresadas en scripts en lenguaje Python. Dichos scripts son los encargados de enviar las señales adecuadas que hacen que un pequeño motor paso a paso instalado en la estructura de la máquina sea capaz de hacer orbitar una cámara web alrededor de un objeto pequeño.

Una vez capturada la serie de imágenes se procede a la extracción y posterior introducción de las mismas en un ordenador con suficiente potencia de proceso como para llevar a cabo las tareas de reconstrucción 3D del objeto. Al terminar este proceso se obtiene una malla refinada y optimizada que contiene la geometría reconstruída del objeto, y se procede a su reparación y texturizado. A continuación se aplican modificaciones manualmente para conseguir una malla cuya superficie no presente agujeros, y el resultado de ello está listo para imprimirse en 3D usando cualquiera de las técnicas de impresión disponibles actualmente.

Este proyecto expone la problemática que se ha abordado en el momento de idear el dispositivo, así como las soluciones adoptadas para llevar a cabo un prototipo operativo y sus componentes, tanto en forma de solución comercial como en cuanto a diseño y fabricación de los componentes específicos. Las piezas diseñadas se han impreso en 3D bajo pedido, en poliamida, aunque el uso de esta técnica y material se ha escogido basándose en experiencias previas y no es imprescindible para este proyecto. Así pues, se puede realizar escogiendo materiales que proporcionen iguales o mayores características mecánicas, de igual modo que es posible modificar la geometría de dichas piezas para facilitar su fabricación, siempre que dicha modificación no afecte a su principio de funcionamiento.

IX

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

1. OBJECTIVE, BACKGROUND AND MOTIVATION

The main objective of this project is to design, manufacture and materialize the results of applying photogrammetry software techniques. This report describes the reasoning and phases to create an automatic image capturing platform that allows to take photographs of a small object in an orbiting fashion and export the images with the purpose of further processing. After processing and post-processing results will be shown in the form of a 3D-printed object that will be similar to the source object in shape and chromatic features.

This project does not intend to provide a commercial, end-user solution, but to offer a functional prototype that shows how photogrammetry can be applied with few resources to obtain not only the shape but also the color of a small object.

Some parts might need to be modified in geometry in order to make them manufactured instead of 3d- printed.

Other electronic parts might be substituted by others with different technical specifications such as computing power or output torque, according to the circumstances or particular needs. This action might require a different set of electronics in order to correctly control the system.

This project has been concluded with the intent to connect several academic skills such as engineering concepts of structural analysis electronics, programming, part design and drawing, and project and time management, together with various personal interests and motivations, like creation of user-friendly graphical interfaces, micro-robotics and 3D printing technology.

1

Report

2. PHOTOGRAPHY AND PHOTOGRAMMETRY: A BRIEF DESCRIPTION

2.1. PHOTOGRAPHY

Photography in its broadest sense is a process that converts the real tri-dimensional world into flat, bi- dimensional images. The camera is the imaging device that makes this transformation or mapping from three dimensions to two dimensions. Unfortunately the tri-dimensional world cannot be mapped onto two dimensions completely given that some information, such as depth, is lost.

2.2. PHOTOGRAMMETRY

Photogrammetry “reverses” the photographic process described above. Photogrammetry is a measurement technology in which the three-dimensional coordinates of points on an object are determined, starting from bi-dimensional views that present geometrical similarities and additional viewing angles of the same feature. This is achieved by stereoscopy, which is measurements made in two or more photographic images taken from different camera angles and locations. The most common ways to obtain data is by using photographs, but it may be also imagery stored electronically on tape or disk taken by video cameras or radiation sensors such as scanners, MRI machines, and other similar devices. However, since information is lost in the photographic process, the 3-dimensional world cannot be completely reconstructed with just one photograph. As a minimum, two different photographs of the same object are required in order to reconstruct its tri-dimensional features.

- The results after processing the input imagery can be: - Coordinates of the required object-points - Topographical maps - Rectified photographs (orthophotography) - Partial or total tri-dimensional reconstruction of the target subject

One of its most important features is the fact that the objects are measured and represented without even being manipulated or touched. Therefore, the term "remote sensing" is often used instead of "photogrammetry". Remote sensing is a rather young term which was originally confined to working with aerial photographs and satellite images. Today it includes also photogrammetry, although it is still associated rather with image interpretation and processing.

2

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Photogrammetry can be primarily divided into range photogrammetry (mostly aerial) and close range photogrammetry (mostly terrestrial and/or small scale photogrammetry), which is in fact the main objective in this document.

3

Report

3. WORKING PRINCIPLES AND APPLICATIONS OF PHOTOGRAMMETRY

In principal, the 3D coordinates define the locations of object points in the 3D space. The image coordinates define the locations of the object points' images on a film or an electronic imaging device. The exterior orientation of a camera defines its location in space (translation) and its view direction (orientation). The inner orientation defines the geometric parameters of the imaging process. This is primarily the focal length of the lens, but can also include the description of lens distortions. Further additional observations play an important role in extracting this relations for “solving” the images, such as: scale bars, basically a known distance of two points in space, and known fix points (anchor points), the connection to the basic measuring units is created. The three-dimensional coordinates produced from the measurements of multiple photographs are the end result of photogrammetry.

Photogrammetry uses the basic principle of Triangulation, whereby intersecting lines in space are used to compute the location of a point in all three dimensions. However, in order to triangulate a set of points, the camera position and aiming angles (together called the orientation) for all the pictures in the set must be known. A process called Resection does this. Some camera calibration has to be done in order to define its errors and remove them from the process (some cameras are to Self-calibrate). Usually these procedures are performed simultaneously in a process called Bundle Adjustment. The methodology is measuring common points that are identified on each image. A line of sight (or ray) can be constructed from the spatial camera location (focal) to a point on the object. The intersection of these rays (aerial triangulation) that determines the three-dimensional location of each point measured.

In principal, there are more sophisticated algorithms that can exploit other information about the scene that is known before the photographing procedure is done, for example symmetries, allowing the reconstruction of 3D coordinates from only one camera position. Mathematical algorithms for photogrammetry typically express the problem of minimizing the sum of the squares of a set of errors, mainly exist in the set of measurements (LSM – least squares method).

Nowadays photogrammetric methods rely largely on images produced from aerial or satellite imagery (or scans produced by digital cameras), and radar or laser produced data (i.e. remote sensing). The applications of photogrammetry are widely spread. Predominantly, photogrammetry is utilized for object interpretation (identification of shape, quality or quantity) and object measurement (location and general dimensions). Aerial photogrammetry is mainly used to produce large scale topographical maps or digital terrain models (DTM), representing the terrain relief. It is also used to combine live action with computer generated

4

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing imagery in movie post-production. Among the users of close-range photogrammetry are architects and civil engineers (supervising buildings, document their current state, deformations or damages), archaeologists, geophysicists, geodesists, surgeons or police departments (documentation of traffic accidents and crime scenes).

5

Report

4. PATH TOWARDS THE CHOICE OF A SPECIFIC APPROACH 4.1. LASER RECONSTRUCTION AND SURFACE FROM MOTION (SFM) 4.1.1. The use of laser in 3-D reconstruction operations

The use of laser is currently one of the most precise methods to obtain a point cloud out of an existing object, which is converted into a tri-dimensional mesh with a high degree of fidelity. Nonetheless there is a limiting factor when it comes to texture mapping and color reproduction, given that there are no ways to retain the color while the geometry is being captured. When the external appearance has relevant importance, laser imaging is effective when it comes to ensure a high degree of fidelity with respect to the original shape, but further in time the object textures must be implemented and correctly mapped in a separate process, which often translates to an increased time consumption as well as the need of a higher set of skills and knowledge regarding mapping techniques. These factors increase the production time, which directly reflects into the final production cost and lead time.

Laser 3-D reconstruction is often achieved by using a turntable whose movement is, mostly, automatically controlled, spinning either at a certain angular velocity or step by step thanks to a stepper motor driver.

The most simple laser 3-D scanners work with a single, linear beam of light that curves itself according to the object’s relief, and bounces back into the receiver, capturing one fraction of the object shape at a time. Not being these types of scanners able to capture colors or different shades or shadows casted onto the subject to scan, laser scanners are because of this reason more suitable to be used in any lighting conditions, only losing information relative to color, which is often required at the same time of the reconstruction.

4.1.2. Direct, realistic results

On the other side, Surface from Motion (shortened as SFM in advance) is a much more convenient way to obtain rough replicas of an object or location by the only use of an image capturing device such as an everyday smartphone camera or a more powerful digital compact, to mention some options.

It can also be done by selecting determined frames from a video recording, where the frames will act as individual image captures to be processed.

4.2. TURNTABLE VS ORBITING CAMERA

6

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

4.2.1. Shadow casting issues

Using a laser to capture the differences in shape of an object does not need to consider a viable way to ignore the shadows being projected onto the surface, even if it is the surface of the target object.

The laser beam only takes information of the shape of the object by processing the shape of a linear beam, which is colliding onto the surface and returning into the sensor. Afterwards this information will be put together and presented in the form of a 3-D volume. This volume will be richer in detail when the distance between slices or scans is comparatively small.

Nonetheless, by using a photographic camera in order to capture individual scenes, it can be found that the subtle color variations produced by the casting of external or even own shadows onto the scene surfaces cause an unwanted effect: the points taken as reference to be matched in different captured images where they appear (in order to later establish geometrical and spatial relationships between them) present problems when the shadow cast is always in the same absolute orientation, this meaning it not remaining in the same position with respect to the current scene image. This creates a surface which does not present the same color in all the captures where it appears, being seen by the system as a different scene or orientation. This will therefore cause the software to compute the images in a wrong way and potentially distorting the final point cloud.

4.2.2. Need for a static scene

According to what is explained in Section 4.1. , laser reconstruction offers an excellent choice when it comes to accuracy of measure. When using lasers it is highly recommended to make use of a rotating platform in order to capture every corner of the object shape.

Given the nature of the chosen system, a turntable has been proven to be ineffective. By capturing several photographs of the same object by rotating it and leaving the camera in a fixed position, the SFM reconstruction will not match the similar points efficiently, due to the fact that the software matches points belonging to every surface present in the capture, like the supporting platform itself, the walls, or anything that is correctly focused on the image.

If only the object shape is rotated but the scene (the rest of objects that compose the background) remains still, a change in the relative position between both parts occurs. From the camera point of view, an image captured will not have enough in common with the next one, given that the two images will present

7

Report different candidate points due to the different orientation of the object respect to its background. This means that a scene that keeps the same relative position and angulation is needed, therefore the camera position and orientation must be variable whereas the scene containing the object must be fixed.

8

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

5. PROBLEM SOLVING AND IMPLEMENTED SOLUTIONS 5.1. DESIGN RESTRICTIONS AND GUIDELINES

The final product configuration will be developed reflecting the following main guidelines, including at the same time any piece of machinery necessary to transmit power, torque or any other type of variable which has to be taken into consideration. Some of the points are restrictions that intend to force a viable solution for this project to be found and validated by using resources that are immediately available, or easily purchased. Such factors are, for example, the use of a determined software and computing device, or the choice of a camera instead of a laser. Nonetheless, and for the purpose of showing a functional prototype, the designed parts will be 3D-printed in polyamide in order to provide a quick way to obtain them.

- The controlling system will be based on GNU/Linux by using a Raspberry Pi Model B mini- computer equipped with Raspbian, a free, open source operating system based on . The usage of Python software package and others which will be listed will guarantee an easy to learn programming language, as well as the capability to communicate with the operating system, the rest of devices and the stepper motor controller circuit. - A commercial USB video camera, in this case a Logitech QuickCam Pro 9000, will act as an image capture device. The use of this particular model is of great importance given that this camera has shown to be highly compatible with the Raspberry Pi and has a sufficient static picture resolution. - The machine will be solid enough as to hold its position and capture images of a small object located in the center of a platform. Image reconstruction will be done by using a computer with more processing capabilities, such as a desktop PC, and a set of open source software such as VisualSFM (within MeshRecon) and Meshlab. - The image capture device will orbit around the scene and capture a pre-set number of frames in which the object geometry must appear. This is how any shadow casting issue will be avoided, making the image reconstruction much easier and clear. - The motion will be provided by a stepper motor, given its ability to advance in very precise, easily programmable steps and generate an elevated torque at low angular velocity. The stepper will function thanks to the set of electronics necessary to correctly wire, energize and drive the stepper motor, stressing flexibility, versatility and ease of both use and code modification.

9

Report

- The rotating mechanism will allow one complete spin in order to reproduce only a region of the object, if required, or the whole 3-D profile. Afterwards, the system will undo the spin until the same starting position is reached, in order to avoid the camera USB cable to twist and possibly receive damage over time. Cable management will be crucial. - An interesting point will be the possibility to choose the camera tilt so it can capture a wide variety of vertical orientations within the same heading plane. - The platform on which the small object will rest must be flat and show a uniform color and texture that will help the point matching process of the VisualSFM software recognizing similarities between pictures, avoiding reflections as much as possible.

- A torque transmitting mechanism must be built in order to allow the loads to hang separate from the motor driving shaft. Given that the shaft of an electric motor is not designed to resist axial loads as much as to overcome opposing torque, the orbiting section will have to rest its weight on a different point, this meaning that the motor will need to transmit its torque along a certain distance until it connects to the orbiting section.

- In order to provide the machine with some safety feature, a safety jail will be designed and manufactured. Such cover will prevent a human hand to access the torque transmitting mechanism and the motor itself, having to disassemble it in order to replace or adjust any parts.

- The rotating section will not be covered but the base will be wide enough to ensure that no moving parts exceed the base geometry, which will limit the extension of the machine. - The way to control the rotation must be as editable as possible, allowing the user to make as many changes as required. The control scripts must offer an easy, understandable way to apply such changes without the need of knowing how to program in the chosen language. This can be achieved by adding clear indications in the form of comment lines in every script, explaining the functions every critical part does.

10

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

6. COMMERCIAL ELECTRONICS 6.1. ACER EMACHINES EM355 NETBOOK

In order to access and control the stepper motor via graphical interface, and according to the methodology that is to be followed in further sections, the use of a Linux equipped netbook will be required. The installation of certain software packages and/or applications will be described in Section 10.2. below.

Figure 6.1. ACER emachines EM355 Netbook.

Source: HTTP://MEDIA.APCMAG.COM

6.2. RASPBERRY PI MODEL B

The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and in developing countries.

The Raspberry Pi Model B version will be the release utilized for this project.

11

Report

Figure 6.2. Raspberry Pi Model B mini-computer.

Source: HTTP://WWW.NEXUSCYBER.COM

6.3. LOGITECH QUICKCAM PRO 9000 WEBCAM

In order for the image capture to be possible an USB web camera will be used. In this particular case the Logitech QuickCam Pro 9000 is already available and there is therefore no need to acquire a new device.

Its most relevant feature is that it comes with Autofocus, although the focal distance can be manually adjusted by using third party software packages, described in Section 10.2. .

Figure 6.3. Logitech QuickCam Pro 9000 web camera.

Source: HTTPS://WWW.PCCOMPONENTES.COM

In order to mount the camera and make it rotate around the idle shaft component, the base will be disassembled in such a way that two metallic plates will be exposed.

12

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 6.4. Webcam with disassembled mount part, as utilized for this project.

- USB cable management

Initially the camera was intended to do a complete revolution around the target object, then stop its movement until the next scan round, where the webcam would spin again in the same durection. The issue this would generate is an unwanted twist in the USB cable, which would receive as many spins as scanning cycles until it got manually unplugged from the Raspberr Pi, which is not the wanted procedure. The cable would then continuously twist without the possibility of undoing the revolutions.

The idea of a slip ring that allows free rotation was considered, but given the high price that these pieces of electronics have, it was quickly rejected.

Instead of this, the solution that has been finally implemented is to modify the motion scripts in such a way that the camera does a full spin around the object, then returns to the initial position by spinning in the opposite direction. This should be applied only in every script that controls the captures or a quick motion simulation, and is as easy to modify as introducing one final iteration that makes the stepper run back 360 degrees, rotating the beam in the opposite direction. The details and code of these set of scripts will be described in depth in the corresponding Annex in this project..

13

Report

6.4. STEPPER MOTOR

The 28BYJ-48 stepper motor selected for this specific application, and taking into account the nature, direction and magnitude of the forces applied on the system, will be a small, 5-wire, unipolar stepper motor, that does not need additional current for this purpose, which is highly convenient.

Figure 6.5. 28BYJ-48 5-Wire unipolar stepper motor.

Source: HTTPS://CDN.INSTRUCTABLES.COM

Datasheet: HTTP://ROBOCRAFT.RU/FILES/DATASHEET/28BYJ-48.PDF

Given its small size and relatively high power, this stepper motor model is enormously recommended for starting DIY projects as well as more professional applications that involve a precise motion and speed control.

14

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 6.6. 28BYJ-48 external dimensions as provided by the manufacturer.

Figure 6.7 shows the unipolar configuration of this 5-wire stepper motor. The common (red) wires divide each one of the two coils into two halves, which will be energized following a specific sequence that will be detailed in the motion control 6scripts.

Figure 6.7. 28BYJ-48 stepper motor Inner wiring. Note that the red wire (connecting the centers of the two coils) gives the motor a unipolar configuration. Bypassing the red wire will result in a bipolar configuration, which means increased currents and output torque.

The output shaft of this stepper motor features a 64:1 gear train (as shown in Figure 6.8) that guarantees a maximum of 512 micro-steps per revolution, making possible a very precise motion control.

15

Report

Figure 6.8. 28BYJ-48 stepper motor. By opening the top lid the 64:1 gear train can be observed.

6.5. ULN2803 STEPPER CONTROLLER

The ULN2803 is an integrated driver that packs 8 transistor Darlington arrays and its respective damper diodes, and is commonly used as an interface to manage low current pulses or digital signals in such a way that they can drive components that require high currents or voltages.

Their function is to take the electrical signal generated by the digital components and increase its tension and current thanks to power transistors. The diodes act as dampers in order to reduce variations or transient pulses.

One ULN2803 will be used for this priject, being the one in charge to manage the input and output currents from the Raspberry Pi’s GPIO port and into the stepper motor.

Although the GPIO pins will be managed from a series of Python scripts, this Darlington array will prepare the resulting signals to be powerful enough to drive the stepper.

16

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 6.9. ULN2803APG Darlington array.

source: HTTP://WWW.EBAY.COM

Datasheet: HTTP://WWW.TI.COM/LIT/DS/SYMLINK/ULN2803A.PDF

6.6. RASPBERRY PI GPIO COBBLER BREAKOUT BOARD

The use of a small GPIO cobbler (Figure 6.10) results in a highly convenient piece of electronics. This cobbler allows to extend the Raspberry Pi’s GPIO pins onto another circuit board, or in this case, and for showing purposes, onto a Breadboard. This, combined with a GPIO extender cable (Figure 6.11), a set of male jumper cables (Figure 6.12) and a Breadboard (Figure 6.13), provides more than enough space and connectivity possibilities.

Figure 6.10. Raspberry Pi GPIO cobbler breakout board.

Source: HTTPS://CDN-LEARN.ADAFRUIT.COM/GUIDES/IMAGES/000/000/036/MEDIUM800/ID914SOLDERED_LRG.JPG?1448300917

17

Report

Figure 6.11. Raspberry Pi GPIO extender cable. This cable will link the Raspberry Pi’s GPIO pins with the cobbler board.

Source: HTTPS://IMAGES-NA.SSL-IMAGES-AMAZON.COM/IMAGES/I/41-GHEAK4%2BL._SX300_.JPG

Figure 6.12. Jumper cable set to connect the stepper to the breadboard. They are also used to make the connections to establish the adequate relationships between the ULN2803 pins and the GPIO cobbler breakout board.

Source: HTTPS://IMG.FASTTECHCDN.COM/113/1135300/1135300-3.JPG

18

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 6.13. Breadboard. This solderless prototyping board features series and parallel connections that will be of high u tility when establishing the corresponding connections between the different electronic components.

Source: HTTPS://MODERNDEVICE.COM/WP-CONTENT/UPLOADS/IMAGES/PRODUCTS/TW-E40-1020.JPG

Alternatively, the use of a compact stepper driver board is possible as well, although in this particular case, and for displaying purposes, it has been decided to leave the connections executed on top of the Breadboard.

Figure 6.14. Stepper motor driver board.

Source: HTTP://ARDUINO-DIRECT.COM/PHOTOS/SMALLSTEPPERBOARD1.JPG

19

Report

6.7. WIRING DIAGRAM

This is a simplified view of the connections made between the GPIO cobbler breakout board and the ULN2803 driver, up to the stepper motor wires. The pin naming of both the cobbler and ULN2803 can be found on their corresponding datasheets, provided in this project.

Figure 6.15. Simplified wiring diagram. The image shows how to connect the 28BYJ-48 stepper to the ULN2803 controller, and then into the Raspberry Pi’s GPIO port via the Raspberry Pi GPIO cobbler breakout board.

20

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

7. INTRODUCTION TO STEPPER MOTORS 7.1. STEPPER MOTORS

Stepper motors are DC motors that move in discrete steps. They have multiple coils that are organized in groups called phases. By energizing each phase in a certain sequence, the motor will rotate, one step at a time, until the next position determined by the coils.

With a computer controlled stepping you can achieve very precise positioning and/or speed control. For this reason, stepper motors are the motor of choice for many precision motion control applications.

Stepper motors come in many different sizes and styles and electrical characteristics. This guide details what you need to know to pick the right motor for the job.

Figure 7.1. 28BYJ-48 geared stepper motor, used in this project.

Source: HTTPS://LEARN.ADAFRUIT.COM

7.2. ADVANTAGES OF STEPPER MOTORS

- Positioning

Since steppers move in precise repeatable steps, they excel in applications requiring precise positioning such as 3D printers, CNC, Camera platforms and XY Plotters. Some disk drives also use stepper motors to position the read/write head.

21

Report

- Speed Control

Precise increments of movement also allow for excellent control of rotational speed for process automation and robotics.

- Low Speed Torque

Normal DC motors don't have a high torque at low speeds. A Stepper motor has maximum torque at low speeds, so they are a good choice for applications requiring low speed with high precision.

Figure 7.2. Various type of small size stepper motors available.

Source: HTTPS://LEARN.ADAFRUIT.COM

7.3. LIMITATIONS OF STEPPER MOTORS

- Low Efficiency

Unlike DC motors, the stepper motor current consumption is independent of load. They draw the most current when they are doing no work at all. Because of this, they tend to run hot, and this is the reason why at the end of the controlling scripts there will be a last line forcing the de-energization of all coils.

22

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

- Limited High Speed Torque

In general, stepper motors have less torque at high speeds than at low speeds. Some steppers are optimized for better high-speed performance, but they need to be paired with an appropriate driver to achieve that performance.

- No Feedback

Unlike servo motors, most steppers do not have integral feedback for position. Although great precision can be achieved running ‘open loop’. Limit switches or ‘home’ detectors are typically required for safety and/or to establish a reference position.

7.4. STEP COUNT

The next thing to consider is the required positioning resolution. The number of steps per revolution ranges from 4 to 400. Commonly available step counts are 24, 48 and 200.

Resolution is often expressed as degrees per step. For example, a 1.8°/step motor equals to a stepper motor that features a total of 200 steps each 360º, a complete revolution.

The disadvantage of high resolution is speed and torque. High step count motors top-out at lower rpm than similar size. The higher step rates needed to turn these motors result in lower torque than a similar size low-step motor at similar speeds.

7.5. GEARING

Another way to achieve high positioning resolution is with gearing. The stepper motor used in this project (as shown in Figure 7.3 below) has a 64:1 gear train applied to the output shaft of its 4-steps/revolution coil configuration, which means that it can provide 512 different micro-steps when its coils are sequentially energized.

23

Report

Figure 7.3. 28BYJ-48 stepper motor. By opening the top lid the 64:1 gear train can be observed.

A gear train will also increase the torque of the motor. Some small geared steppers are capable to provide a high torque, but the tradeoff is speed. Geared stepper motors are generally limited to low speed applications.

7.6. COILS AND PHASES

A stepper motor may have any number of coils, but these are connected in groups called phases. All the coils in a phase are energized together.

Figure 7.4. Differences between bipolar motor wiring (left) and unipolar motor wiring (right).

Unipolar drivers always energize the phases in the same way. One lead, the "common" lead, will always be negative. The other lead will always be positive. Unipolar drivers can be implemented with simple transistor circuitry. The disadvantage is that there is less available torque because only half of the coils can be energized at a time, which reduces power.

Bipolar drivers use H-bridge circuitry to actually reverse the current flow through the phases as required.

24

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

By energizing the phases and alternating the polarity, all the coils can be put to work turning the motor.

A two phase bipolar motor has 2 groups of coils. A 4 phase unipolar motor has 4. A 2-phase bipolar motor will have 4 wires - 2 for each phase. Some motors come with flexible wiring that allows you to run the motor as either bipolar or unipolar.

7.7. 5-WIRE MOTOR

This style is common in smaller unipolar motors. All of the common coil wires are tied together internally and brought out as a 5th wire. This coil configuration is the same as the 28BYJ-48 stepper used in this project.

Figure 7.5. Five-Wire unipolar motor.

7.8. 6-WIRE MOTOR

This motor only joins the common wires of 2 paired phases. These two wires can be joined to create a 5- wire unipolar motor. By ignoring the common wires it can be possible to treat the motor like a bipolar motor instead of unipolar. This will increase its power and torque, but might as well require other pieces of electronics to manage the circulating currents.

Figure 7.6. Six-Wire unipolar motor.

25

Report

7.9. 8-WIRE MOTOR

The 8-wire unipolar is the most versatile motor of all. It can be driven in several ways:

- 4-phase unipolar (all the common wires are connected together), just like a 5-wire motor. - 2-phase series bipolar (the phases are connected in series), just like a 6-wire motor.

- 2-phase parallel bipolar (the phases are connected in parallel). This results in half the resistance and inductance but requires twice the current to drive. The advantage of this wiring is higher torque and top speed.

Figure 7.7. Eight-Wire unipolar motor.

26

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

8. COMMERCIAL MATERIALS 8.1. VERTICAL SUPPORT (617CV00) AND HORIZONTAL BEAM (617CH00)

In order to provide the structure with a solid supporting frame, the following extruded profiles have been selected.

This aluminum square profile features a 20 mm side and four slots along the faces that allow the introduction of a series of small M4 threaded parts called T-nuts (further described in Section 8.1.1. ), which eliminate the need of drilling holes on the profile surface to screw other parts of the assembly thanks to the mechanical interference created once the two joined parts are screwed together.

For the purpose of this project this slotted shape becomes greatly useful and practical, given the fact that it will allow further manual adjustments of certain parts as they are required, without the need of completely unscrewing the union.

The two cut lengths used in this projects are 145 mm for the 617CV00 vertical support and 177 mm for the 617CH00 beam.

Figure 8.1. Slotted 20x20 aluminum extrusion profile.

Source: HTTPS://WWW.ADAFRUIT.COM/PRODUCTS/1221

8.1.1. T-nuts for slotted 20x20 square aluminum extrusion profile

27

Report

Figure 8.2. Slim T-nuts with M4 thread.

Source: HTTPS://WWW.ADAFRUIT.COM/PRODUCTS/1157

Figure 8.3. Button hex M4x10 machine screws.

Source: HTTPS://WWW.ADAFRUIT.COM/PRODUCTS/1159

8.1.2. Aluminum L-plates (617CU00)

Made of 4 mm thick aluminum plate, these parts guarantee a solid union between the vertical and horizontal supports, as well as act as limit for the maximum distance between the driving pulley and the idle section of the machine. This maximum distance might vary according to the use of a certain length of belt and will also take relevance regarding what is described in Section 9.2. , where the stepper support design is explained in depth.

28

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 8.4. Aluminum L-plate.

Source: HTTPS://WWW.ADAFRUIT.COM/PRODUCTS/1218

Two L-plates have been used in order to assemble the main frame, formed by two different lengths of slotted aluminum extrusion profile at 90 degrees.

Figure 8.5. L-plates assembling the main frame.

8.2. MECHANICAL UNION ELEMENTS

Different metric thread and autothreading wood screws have been used to assemble the device. Although they do not possess a specific reference, they will be named by its diameter or threading, followed by their length.

o 2x Ø4x25 wood screws to fix the 28BYJ-48 stepper motor on the 617MH00 stepper support o 1x Ø4x25 wood screw to fix the 617MR01 rotating beam to the 617MR00 driven shaft o 6x Ø4x16 wood screws to fix the 617MV00 base clamp to the 617MB00 stand

29

Report

o 1x Ø3 wood screw to provide the 617MR00 shaft with a secondary (and optional) fixing point o 2x Ø2x10 wood screws to tighten the adjustment between the 617MR02 webcam support and the 617MR03 fixing cap o 4x Ø2x10 wood screws to fix the Logitech QuickCam Pro 9000 webcam to the 617MR02 support o 22x M4x10 screws to fix the 617MH00 stepper support and 617MH01 bearing support to the 617CH00 horizontal aluminum beam, and also to screw the 617CV00 vertical support and 617CH00 horizontal beam with the use of the 617CU00 L-plates

8.3. LOW FRICTION IDLE SHAFT SUBJECTION (617CR00)

8.3.1. Considerations regarding low friction solutions

- Radial ball bearings

In order to keep the idle shaft in place and allow it to rotate with the least possible friction torque, two ABEC5 shielded radial ball bearings have been chosen. The ball bearings are 7 mm thick and feature an inside diameter of 8 mm, while presenting an external diameter of 22 mm.

Figure 8.6. Pair of Ø8xØ22x7 ABEC5 ball bearings.

Source: HTTPS://AE01.ALICDN.COM

30

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

- Flanged radial ball bearings

Before choosing the above described ball bearings, another type of bearing was also considered. The flanged ball bearings provide an extra space for them to be placed in their sockets. The flange would act as a stop by featuring a mechanical interference between the bearing itself and the socket, leaving the inner crown free to rotate.

Following the guideline that suggested using the least possible resources, the geometry of the bearing support part got changed in order to accommodate the flat version of this bearing, given that these bearings were already available and therefore there was no need of purchasing a new set of bearings.

Figure 8.7. Ø8xØ22x7 flanged ball bearing.

Source: HTTP://CDN3.VOLUSION.COM

8.3.2. Load absorption and spacing

An axial action is required in order to absorb the vertical forces applied over the inner crown of the bearing and creating traction stresses along the idle shaft. This would be typically solved by adding a radial bearing on one side, and a combined effect bearing on the other, this providing the correct type of reaction against both axial and radial stresses. This might also imply the creation of an adjustment between the idle shaft and one of the bearings, ensuring that the adjustment would keep the shaft from moving vertically while supporting the entire weight of the rotary system on that point.

31

Report

The disadvantage of this system in this particular case is the assembling difficulty, given that the tight adjustment between the shaft and the bearing inner crown should get put together beforehand, and then assembled into the system.

The current ball bearing support geometry does not need this type of adjustment. Instead of this, the idle shaft presents a wider section near the upper ball bearing that will actually rest by touching the inner crown’s rim, transferring the entirety of the axial stresses onto the said portion of the bearing.

Vertical load

Figure 8.8. Detail of the wider section of the idle shaft. The weight gets transferred directly to the inner crown.

The second ball bearing has been placed as close from the bottom end as possible, only leaving the necessary space to attach the rotary beam and the geared pulley on its attachment ports. This action will prevent excessive deformations due to the bending induced by the loads on the beam. A distance too far away from the end would cause a great leverage on the shaft which might crack or deform excessively, shortening its duty life. The distance between the two ball bearings has been one of the most critical aspects in order to avoid any problems regarding static failure, and will be mentioned further in the section dedicated to the idle shaft.

32

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

- Figure 8.9. Ball bearings spaced along the driven shaft. The distance between ball bearings is a critical variable, constrained by the shaft length, cross section and attachment ports, and will determine the ability to resist bending stresses and deformations.

Although a ball bearing is not designed to oppose this type of axial loads, the upper bearing can withstand the vertical action thanks to the fact that the axial stress applied on it is extremely low for such bearing. This will be calculated and justified and ensures that the idle shaft will rest over the top ball bearing without it being in danger of static collapse by permanent plastic deformation.

8.4. TIMING PULLEYS (617CP00)

This commercial model of timing pulley features a lightweight aluminium body and one Ø5 mm bore to fix it to a shaft thanks to two treaded holes disposed at 90 degrees on the top flat body. The geared body allows a 6 mm wide timing belt to be attached and it has 20 GT2 teeth which are anti-backlash given the special round tooth geometry. This type of pulleys are indicated for precise movement transmission and are generally utilized for small CNC routers, among others.

Figure 8.10. 20 teeth, GT2 timing pulley.

33

Report

Source: HTTPS://WWW.ADAFRUIT.COM/PRODUCTS/1251

Another version with 36 GT2 teeth was previously considered, but the final choice favors the model with 20 teeth because of the reduced weight and outer diameter. Additionally, the small profile of this geared pulley is enough for the stepper to create de required torque to move the entire rotary portion of the machine and adds very little rotational inertia, even negligible considering the low speeds that are achieved while rotating.

Despite of this project featuring the 20 teeth geared pulleys, the design allows the 36 teeth pulleys to be installed as well, which would only change the length of the belt to use. Their outer diameter is 25 mm, which would require a longer belt loop. A 280 mm closed loop timing belt (mentioned in Section 8.5.2. and named 617CP0B) could be used thanks to the sliding tension adjustment provided by the stepper motor support. The stepper motor support will be described further in Section 9.2. .

4 Figure 8.11. 36 teeth, GT2 timing pulley.

Source: HTTPS://WWW.ADAFRUIT.COM/PRODUCTS/1253

8.5. TIMING BELT (617CP0A/B/X)

The belt that will be used is a 6 mm wide timing belt that features GT2 teeth profile, given its immediate availability on the market.

34

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 8.12. GT2 timing belt tooth profile (dimensions in mm).

8.5.1. Option 1: Open-ended timing belt (617CP0X)

An open-ended GT2 timing belt (part reference 617CP0X) can be selected in order to transmit power from the driving pulley to the idle end. The belt may be lengthened to 308.50 mm (measure justified below by considering the maximum distance between both pulleys), a width of 6 mm and features anti-backlash rounded teeth whose pitch is equal to 2 mm.

The advantage of this system doing a maximum of one spin before returning to the home position is that it allows the timing belt to get adjusted in length in a very simple way. Taking into account that the maximum distance between both centers of the pulleys is 113.25 mm, and considering that one tooth is displaced a total amount of 37.70 mm each revolution, the ends of the timing belt can be secured together and they will not run for a distance greater than the said above maximum distance between pulleys (which equals the distance of one of the tensioned portions of the timing belt once put in place). This means that a loop can be formed by screwing both open ends of the belt by using a geared part, or also by simply overlapping and gluing the ends and making sure that this is done at the center of the straight portion of the belt, equidistant from the two pulleys.

35

Report

Figure 8.13. Open ended GT2 timing belt.

Source: HTTP://G02.A.ALICDN.COM

Nonetheless this will not be finally chosen as an optimal solution, given two main factors:

- The user has to cut and rejoin the belt as if the distance between axles were fixed, whereas such limitation does not exist. Instead of this, and given the advantage that designing a flexible distance between pulleys has been one of the most critical improvements that have been had in mind, closed loop belts can be selected as shown below. - Nothing protects the pulleys against a continuous manual adjustment towards one side or another. Depending on the belt end clamping method utilized, if the clamping plate is purposely displaced in such a way that travels close to one of the pulleys, it could jam or even damage the mechanism.

8.5.2. Option 2: Closed loop timing belts (617CP0A/B)

Alternatively, and finally selected as the installed solution, closed loop timing belts can be found in the market. For this project a closed loop, 200 mm length can be used.

Unlike open ended belts, closed loop timing belts do not need to be joined together and for the purposes of this project this will mean 360 degrees of uninterrupted rotation in a small operating space. Once again, by creating a flexible pulley spacing, any jamming issue has been eliminated.

36

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 8.14. Closed loop GT2 timing belt with a length of 200 mm.

Source: HTTPS://CDN.SHOPIFY.COM

37

Report

9. MANUFACTURED PARTS 9.1. BEARING SUPPORT (617MH01)

The 617MH01 bearing support is the component where the whole weight of the rotating section will rest on. It is composed of two circular sockets that will fit one radial ball bearing each. This part is also providing the center of rotation for the rotating section as the center axis of the Idle shaft runs along the centers of the circular sockets.

Figure 9.1. Bearing support.

The 11 mm spacing between the two bearing sockets has been designed so it allows one ball bearing to slide inbetween in such fashion that the assembly of the bottom bearing can be possible by just placing it over its socket and letting it align and fit by gravity. This action prevents the use of additional fixing elements and makes its replacement quick and easy.

38

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 9.2. Detail of the bearing placement into their sockets.

This spacing allows the Idle shaft to have a better stress distribution along its geometry, given that the most critical bending stresses are damped by this placement choice. This will be explained below in Section 9.3. .

9.2. STEPPER SUPPORT (617MH00)

The stepper support provides a solid anchorage for the stepper motor by fixing it to the support with two Ø4 screws. The support features a 1,5 mm step that positions and aligns the stepper motor so its placement results evident and unique, as well as an arc-shaped stiffener wall that protects the front part of the motor and prevents it to rock forward if the belt tension is excessive (although this is not recommended, given that it would result in serious damage or even fracture of the idle shaft).

39

Report

Figure 9.3. Stepper support.

The stepper mount has been designed with flexibility in mind. The tight sliding adjustment between the stepper support and the main horizontal beam makes the distance between pulleys variable and suitable for either a 200 mm closed loop timing belt or other open-ended belt lengths, if required. It is also possible to replace the 20 teeth geared pulleys with the 36 teeth version, which would require using a 280 mm closed loop timing belt

Figure 9.4. Sliding adjustment that allows closed loop 200 mm timing belts as well as custom lengths.

40

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

9.3. IDLE SHAFT (617MR00)

The idle (or driven) shaft is the part that will receive the motor torque and transmit it to the rotating beam, from where the webcam hangs on.

This axle has been designed to present the minimum contact surfaces possible and also to need very few fixing elements, trying to use self-aligning and gravity in order to avoid the use of any tight adjustment with the ball bearings. This procedure enormously simplifies the assembly and replacement of any of said parts, as well as is considered a viable solution given that a slight vertical disalignment does not affect the working principle of the device in any noticeable way, not even by producing an excessibe wear on the shaft or any other component.

In first place, the entire weight of the idle shaft rests only on one point, which is the Ø11 mm diameter. This section will create a mechanical interference by resting directly on the inner crown of the top ball bearing, which can freely rotate. The bottom ball bearing will absorb loads as well, but its only function with respect to the axle is to provide a second centering guide so the shaft does not present noticeable lateral displacements, and also to make it rotate in a smooth, controlled fashion.

Thanks to this design, the axle does not need to be tightly adjusted to one of the ball bearings, and does not need any additional stress absorption such as an axial effect bearing, given that the loads applied on it are notably small and a standard radial ball bearing can resist said loads without its function being altered in any way. The extremely low rotation speed of the axle contributes to the fact that the loads on the bearings are considered static.

The driven shaft can be easily assembled by sliding it vertically and downwards into the two bearings, and will keep its position by only using gravity, elliminating the need of using extra fixing techniques and making disassembly much easier.

41

Report

Figure 9.5. Idle (or secondary) shaft.

9.4. BASE CLAMP (617MV00)

This is the link between the device’s main structure and the base stand. It features a socket that tightly fits the 617CV00 main aluminum support, even without the need of screwing them together. Its nearly 4 mm thick walls allow it to easily absorb any moderate overload and thanks to its triangular stiffener this part resists especially well the overturn moments that will act on that plane.

Figure 9.6. Base clamp component.

The earlier design of this part was smaller and thinner, but finally it was decided to purposedly oversize it in order to give it a more heavy-duty appearance, aside of creating wider wings that provide a better fixing and resisting area that will also oppose overturn in a better fashion.

42

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

9.5. BASE (617MB00)

The base stand is an industrial PVC plate that features a thickness of 15 mm and provides a sturdy platform where the entire device can rest on.

Figure 9.7. 15 mm PVC Base.

9.6. WEBCAM SUPPORT (617MR02) AND FIXING CAP (617MR03)

The webcam support is a specially designed part that allows the Logitech QuickCam Pro 9000 to alter its tilt angle (up/down movement) as well as its yaw (left to right rotation). It is an extension of the rotating beam that provides a displaced point of view where the webcam can be fixed on with four small screws. In addition it has a cable holder so the USB cable goes upwards, to be then wrapped around the beam and the idle shaft.

Figure 9.8. Webcam support.

The Fixing cap (Ref. 617MR03) is a small cover that will secure the webcam support position through the use of two screws. It has a wide, slim flange that provides a good resting surface that acts as clamping plate on the opposite side of the rotary beam.

43

Report

Figure 9.9. Fixing cap for webcam support.

9.7. ROTATING BEAM (617MR01)

The rotating beam is the horizontal component that will provide the camera with the necessary tilt angle and spacing to take the pictures. Its design minimizes weight by featuring a series of holes and spaces in a way that they do not affect overall stiffness. Also, the core is hollowed in order to reduce the weight and inertia, which later will transform into bending stresses on the driven shaft.

Figure 9.10. Rotating beam.

The shaft socket, which will be the center of rotation, has been especially designed to fit the idle shaft up to a certain point where the bending loads induced by the beam and camera will be distributed along the largest contact surface possible. With the aim of using the least possible unions and fixing parts, the shaft socket has a near rectangular shape that will receive all the torque coming from the driven pulley.

44

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 9.11. Detail of the shaft socket.

This rectangular hole that allows the shaft to slide through the beam is positioned in such an angle that provides the beam with a higher resistance. Previously the hole was made 90 degrees rotated, which meant that the shaft was going to resist the bending stresses from the side of least inertia (thus rigidity). By orienting the shaft socket in the current position the resistance to this type of stresses increases. Given the geometry of the beam and the hollowed core it is also important to stress that the center longitudinal hole has been midified in order to keep more distance between it and the central shaft socket, also with the intention to reduce stress concentrations in that spot.0

9.8. SAFETY JAIL (617MS00)

In order to complain with safety regulations, and mostly to point how safety has been taken into consideration in this project, a polyamide protection has been 3D printed with the purpose of concealing any moving part that is susceptible of damaging or be damaged by an external action.

45

Report

Figure 9.12. Safety jail.

The top part has a series of openings that will guide the webcam USB cable along the upper channel, which willact as cable manager with several possible configurations: USB cable entering the front shaped hole, or any of the two rectangular shaped windows on the top.

Figure 9.13. Detail of the openings for cable management.

This thin cover features six anchor points which are 2 mm thick, that allow it to get firmly attached to the main structure, protecting the bearing support, most of the driven shaft, the stepper motor, the two pulleys and the timing belt. Due to the low speeds and torques that are achieved with this motor, there is no potential risk of damage for a hand to be placed in any point of the mechanism; nevertheless there is a high risk of breakage of this prototype due to its manufacturing nature and dimensions. The cover is 1 mm thick and made of sintered polyamide, which will easily break if a strong enough shock is received by any part of this machine. This is why hits or falls should be avoided at any time.

46

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

10. WEBCAM DETECTION, SOFTWARE NEEDED AND SETUP 10.1. LOGITECH QUICKCAM PRO 9000 COMPATIBILITY WITH RASPBERRY PI

In order for the Raspberry Pi to be able to detect the USB camera, the QuickCam Pro 9000 must be fully compatible with the Raspberry Pi, given the fact that not every webcam in the market works on this platform.

After a research process few information is found, nonetheless enough as to ensure the correct detection and operation of the QuickCam when plugging in this particular model to the Raspberry Pi.

Model Hardware Verified OS Verified Brand Name Verified OS Additional Information Number ID version Resolution QuickCam Logitech raspbian/wheezy Powered by RasPi Pro 9000

Figure 10.1. Compatibility table of Logitech QuickCam Pro 9000.

Source: HTTP://ELINUX.ORG/RPI_USB_WEBCAMS

Further information is found, regarding the maximum image capture resolution, which in this case is of 1600x1200 pixels for a static image (video resolution might be noticeably lower than this value).

10.2. LIST AND DESCRIPTION OF SOFTWARE PACKAGES TO INSTALL

This section is dedicated to show a brief description of the main software packages that are needed for the imaging platform to work. The software that must be run on the Raspberry Pi under Raspbian can be installed mainly by typing in the terminal console: sudo apt-get install software_package_to_install

The sudo (superuser do) command is often used when the line must have root privileges. In this case, and given that the desktop session already has superuser privileges, the word sudo is irrelevant. Nonetheless it would ask for the root password before dong any system-level changes such as installation or removal of any software package present on the system.

- fswebcam (Raspbian) fswebcam is a neat and simple webcam app. It captures images from a V4L1/V4L2 compatible device or file, averages them to reduce noise and draws a caption using the GD Graphics Library which also handles

47

Report compressing the image to PNG or JPEG. The resulting image is saved to a file or sent to stdio where it can be piped to something like ncftpput or scp.

- and uvcdynctrl (Raspbian)

This project aims at providing a simple interface for capturing and viewing video from v4l2 devices, with a special emphasis for the Linux UVC driver. The project provides a control interface based on Gtk3 or Qt5, depending on the build configuration. A console only option is also available. The Linux UVC driver has an implementation for extension controls (these are vendor specific controls and are supported in the UVC spec.). Until today only Logitech has supplied specs for their UVC webcam extension controls, these are supported by guvcview.

- Python (Raspbian)

Python is a widely used high-level programming language for general purpose programming. It has a design philosophy which emphasizes code readability and a syntax which allows programmers to express concepts in fewer lines of code than possible in languages such as ++ or Java. Python will be the chosen language to write the controlling software in charge of the stepper movement and the camera actions.

- VisualSFM integrated in MeshRecon (Windows)

VisualSFM is a GUI application for 3D reconstruction using structure from motion (SFM). The reconstruction system integrates several of the authors’ previous projects: SIFT on GPU (SiftGPU), Multicore Bundle Adjustment, and Towards Linear-time Incremental Structure from Motion. VisualSFM runs fast by exploiting multicore parallelism for feature detection, feature matching, and bundle adjustment.

For dense reconstruction, this program integrates the execution of Yasutaka Furukawa's PMVS/CMVS tool chain. The SfM output of VisualSFM works with several additional tools, including CMP-MVS by Michal Jancosek, MVE by Michael Goesele's research group, SURE by Mathias Rothermel and Konrad Wenzel, and MeshRecon by Zhuoliang Kang.

MeshRecon is a batch file that unifies the processing method of VisualSFM and adds powerful mesh optimization and refining algorythms for superior quality 3D meshes.

48

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

- Meshlab (Windows)

Meshlab is an advanced 3D mesh processing software system that is oriented to the management and processing of unstructured large meshes and provides a set of tools for editing, cleaning, healing, inspecting, rendering, and converting these kinds of meshes. Meshlab is free and open-source software, subject to the requirements of the GNU General Public License (GPL), version 2 or later, and is used as both a complete package and a library powering other software. It is well known in the more technical fields of 3D development and data handling.

The automatic mesh cleaning filters includes removal of duplicated, unreferenced vertices, non-manifold edges, vertices, and null faces. Remeshing tools support high quality simplification based on quadric error measure, various kinds of subdivision surfaces, and two surface reconstruction algorithms from point clouds based on the ball-pivoting technique and on the Poisson surface reconstruction approach. For the removal of noise, usually present in acquired surfaces, Meshlab supports various kinds of smoothing filters and tools for curvature analysis and visualization.

- Blender (Windows/Mac/Linux)

Blender is a professional free open-source, powerful 3D modeling and sculpting application that will be used for mesh preparation before 3D-printing. Aside from the uses intended in this project, Blender is capable of creating animated films, visual effects, art, interactive 3D applications and video games.

49

Report

11. STEPPER MOTION CONTROL VIA USER-FRIENDLY, EDITABLE CODE 11.1. CONTROL INTERFACE DESIGNS

Initially an aesthetic HTML5 interface was designed, having in mind the ease of use from any internet connected client capable of displaying HTML content. The control interface would run on client side and give the server side the necessary orders according to button presses registered on the interface.

Figure 11.1. HTML5 interface layout, initially designed to run from any web browser client.

What seemed a reasonable idea quickly turned into an issue that was technically way too complicated. After installing an Apache server and trying to communicate with PHP, the security policies that rule these systems forbid anyone to run server-side commands from any client-side machine, so this type of communication was purposedly blocked, even if the client itself is also the server.

After encountering this major issue, the final interface has been finished by using Python and Tkinter. The interface looks like so:

50

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 11.2. Main interface made in Python.

11.2. PYTHON MODULES 11.2.1. Tkinter and PyGTK

Tkinter is Python's de-facto standard graphical user interface package. It is a thin object-oriented layer on top of Tcl/Tk and will be used to generate the control interface from Figure 11.2.

11.2.2. RPi.GPIO module import

In order to be able to manage the GPIO pins within Python using the Raspberry Pi, Python needs to have a way to utilize the Python.GPIO module which will allow it to access and control the input and output signals from the GPIO connector featured on the Raspberry Pi board.

In Python, the line to import said module will follow this syntax, and will have to be present in every import section of any script that needs to manage and control GPIO signals: import RPi.GPIO as GPIO import os import time

51

Report

11.3. SYSTEM SOFTWARE CALLS FROM PYTHON

Once the necessary modules have been imported into Python it will be convenient to execute commands relative to software which is present on the system. In order to achieve this, and thanks to the previous adding of the module “OS”, a link between Python and any software package can be created, and it will be of great utility as long as such software package allows the user to control it via command line by typing the line as follows: os.system(“command_to_execute”)

As a brief example, let it be the target software package from which the user wants to operate. Leafpad is a simple plain from the LXDE and is already pre-installed in Raspbian. It can be executed by typing the word leafpad on the console.

Therefore, the Python line that communicates with the system in order to execute any system command from Python will have the following syntax: os.system(“leafpad”)

This would execute Leafpad on a system level and open the application right away.

Thanks to this it will be possible to call system applications to execute, which will make easier the execution of scripts stored in the Raspberry Pi’s memory or additional applications such as file managers or video previews.

52

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

12. NETWORK AND INTERFACE SETUP 12.1. CONTROLLING THE RASPBERRY PI THROUGH A TACTILE DISPLAY

The fist option that was considered was to control the Raspberry Pi’s functions through a flat LCD display, regardless of it being tactile or not. By choosing a multi-tactile display it was ensured to use it as a complete human interface device (HID), suppressing the need for an external mouse and/or keyboard.

Apart from the elevated price of this kind of electronics, this solution would need a powered USB hub to work properly.

Figure 12.1. 7" capacitive touchscreen for Raspberry Pi Model B.

Source: HTTP://WWW.EXP-TECH.DE

12.2. CONNECTING THE RASPBERRY PI DIRECTLY TO A COMPUTER

On the other side, controlling the Raspberry Pi through any available computer would allow a better usage and more flexibility, being this method the one that has been chosen to control the stepper motor through the Raspberry Pi. As an advantage to other types of connections, the direct cable connection guarantees total independence from any wired or wireless external networks.

This section will provide a quick guide to create a direct non-crossover Ethernet cable link between the Raspberry Pi and a GNU/Linux computer, in this case a laptop equipped with Trisquel GNU/Linux, which is a completely free, open source operating system, sponsored by the Foundation (FSF).

This allows the user to change every aspect of the operating system’s source code itself in order to make it fit the user’s needs, as well as to freely distribute exact or custom copies The elements needed are simply:

53

Report

- Acer emachines EM355 Netbook under any GNU/Linux distribution (In this case Trisquel) - An USB powered Raspberry Pi Model B - A normal RJ45 Ethernet cable (this solution works for a non-crossover Ethernet cable)

12.2.1. Establishing a static IP for the Raspberry Pi

Remove the SD card from the Raspberry Pi and insert it into any computer with an SD card reader.

Once this is done, search for a plain text file named cmdline.txt and open it with any text editor available. In this case, the text to introduce corresponds to a specific IP that will allow both the laptop and the Raspberry to identify each other without the need of connecting them into a router, so the connection will work regardless the existence of an external internet network. To assign the direct link static IP to the Raspberry Pi, the following text is entered at the end of the file: ip=169.254.0.2

Figure 12.2. cmdline.txt in the OS installation SD card.

54

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

The IP at the end will become the static IP of the Raspberry Pi for the link to work properly.

12.2.2. Setting up the computer to allow the direct link

Now that the Raspberry Pi has been set to work together with a direct cable connection to the laptop without the intervention of any external device such as a modem or router, the laptop setup must be addressed in order to complete the connection process. The following steps to follow will allow the connection between both devices to be effective.

a) First, open the System Settings by locating the corresponding icon in the main start menu. Then click on the Network preference pane, which is highlighted on Figure 12.3.

Figure 12.3. System Settings under Trisquel GNU/Linux. b) Next to this, select the Wired connection and click on the Options button on the bottom right corner, as shown in Figure 12.4.

55

Report

Figure 12.4. Network panel within System Settings. Wired connection is selected.

c) Once the “Editing Wired connection” window is open, select the “IPv4 Settings” tab. On the “Method” dropdown menu, select “Link-Local Only”, according to Figure 12.5.

56

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure 12.5. Wired Connection Options menu, with selected IPv4 Settings tab. Notice that the “Link” option must be selected in the Method dropdown menu.

12.2.3. Accessing the Raspberry Pi

- Graphical option: VNC access with Remote Desktop Viewer

From the Trisquel GNU/Linux main desktop, open any VNC remote desktop access client. For this purpose the quick access icon for Remote Desktop Viewer has been already pinned to the bottom panel.

Once the VNC viewer software is open, establish a connection to the previously installed Raspberry Pi VNC server. The server IP is 169.254.0.2

This remote access will allow the user to directly control the Raspberry Pi’s root desktop on a graphical interface by using the keyboard and trackpad from the laptop.

57

Report

- Secure shell (SSH) access from Terminal console

If the user prefers to work with the Terminal console, the following command is suggested: ssh –X [email protected]

o ssh starts a secure shell command line. o -X allows to enable the X11 desktop features (this will allow to use a graphical user interface (or GUI) if there is any available when executing an application. o root accesses the computer with root privileges.

Once the password is introduced, the user can launch the scanning application by typing:

/usr/share/applications/3D Scanner.desktop &

58

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

12.3. CALLING THE CONTROL INTERFACE

A small application 3D Scanner.desktop has been created in order to execute the main Python interface script. For convenience purposes a shortcut to this application can be found on the main desktop on the Raspberry Pi’s root desktop. The application’s absolute path can be accessed via terminal console by typing cd /usr/share/applications/3D Scanner.desktop, or via VNC by simply accessing the Raspberry Pi. The application will summon the control interface and can be executed by clicking on the camera lens icon

located in the bottom panel.

Figure 12.6. 3D Scanner.desktop application on Raspbian’s bottom panel. Accessed via VNC desktop viewer.

59

Report

The following lines of code show the content of the 3D Scanner.desktop application. This application is an executable .desktop file that will call the interface.py Python script that will load the main control interface.

[Desktop Entry]

Name=3d Scanner

Comment=Opens the main interface to start scanning

Exec=python /media/pendrive/cloudberrypi/GRADO/TFG/SCRIPTS/interface.py

Type=Application

Terminal=True

StartupNotify=True

Icon=accessories-camera

Figure 12.7. 3D Scanner.desktop script contents.

This application calls interface.py, which will create a set of inputs that will allow the user to control the scanning process and position of the rotating section.

Figure 12.8. Main interface made in Python.

The following list shows the meaning and function of each one of the buttons created for this project, to control the motion of the stepper manually or automatically, as well as the camera adjustments.

60

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

12.3.1.1. Show preview

This button shows a webcam camera stream and loads a set of controls available for this camera. This is useful to correctly orient and position the webcam before starting the capture process.

12.3.1.2. Automatic scan

This button starts the automated scanning by calling autoscan.py. The process does a series of macro-steps (typically 8, 16, 32 or 64) that change the camera view position and saves a picture of the scene at such position.

12.3.1.3. SCAN folder

Opens the folder where all the pictures taken are stored. The scripted default folder can be found at /root/Desktop/PICS/SCAN.

12.3.1.4. CW and CCW micro-adjustment

These buttons allow the user to move a scripted number of micro-steps in the form of one macro-step per button click. The default number is set to 8 micro-steps, which correspond to approximately 5.625º.

12.3.1.5. Manual capture

The manual capture button allows the user to take a picture on demand under a personalized set of conditions such as camera tilt and optical values that might require adjustment in every capture.

12.3.1.6. 45 degree CW/CCW rotation

These two buttons allow the user to quickly rotate the camera 45 degrees clockwise and counter-clockwise. This is intended to achieve any desired position in a fast pace.

12.3.1.7. Motion simulation

The motion simulation offers a quick preview of the automatic scan operation without taking any pictures. It passes through a scripted number of 64 different iterations consisting of 8 micro-steps each, which can be edited at any time for display purposes. After one spin is completed, the script makes the rotating section to return to the home position without twisting the USB cable.

61

Report

12.3.1.8. Reset system

This button reboots the Raspberry Pi immediately.

12.3.1.9. Power off

This button halts the system and shuts down the Raspberry Pi.

62

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

13. OPERATION AND TESTING 13.1. DEVICE SETUP AND MOTION CONTROL

The first thing to do after assemblying the device is to find the correct spot to place it. It should be a horizontal, flat surface, well illuminated and, if possible, with diffuse lighting to avoid mismatches while processing the pictures, due to strong shadows or direct, intense light.

Introduce an empty USB drive into the Raspberry Pi, and plug in both webcam USB cable and the GPIO cable as well.

Connect the computer and the Raspberry Pi directly with an Ethernet cable, as described in Section 12.2. .

Turn both the computer and the Raspberry Pi on.

Access via Remote Desktop viewer to the raspberry Pi, as described in Section 12.2.3. and Section 0.

Figure 13.1. Root desktop with main interface ready.

Place the target object onto the center of the scanning base. Note that, given that this procedure implies optics and is entirely image-processing oriented, this method is sensitive to lighting variations.

63

Report

Figure 13.2. Detail of the target object placed on the center of the scanning base.

Orient the camera pitch and tilt in such way that the target object appears dead center. This will guarantee a good capture flow and a better reconnaisance of similar pixels in different photographies taken.

Figure 13.3. Detail of the camera pitch and tilt, which need to correctly aim towards the object.

Once the correct camera angle is established, the hardware preparation has ended.

Figure 13.4. Scanning device connected and ready to function.

64

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

13.2. LOGITECH WEBCAM XML PROFILE IMPORT

The next thing to do before starting the image capture procedure is to import the correct set of the Logitech QuickCam Pro 9000 dynamic controls that will be handled by the scripts further in time. This is necessary to gain control over the webcam’s Focus and Autofocus. The file to import is called logitech.xml and is currently placed in a folder called CONFIGS. This .xml file needs to be imported from the uvcdynctrl application. This could be achieved by typing the following in a terminal console in every new scan session: uvcdynctrl –i /media/pendrive/cloudberrypi/GRADO/TFG/CONFIGS/logitech.xml

After this, and in order to visually check if the graphical Focus control is enabled, guvcview should be executed by typing guvcview, which is an universal video control viewer in Gtk.

For convenience, this action is already implemented as a command in both capture.py and autoscan.py Python scripts, so there is no need to type it beforehand.

13.3. IMAGE CAPTURE

Once the device is correctly assembled and the system is set up completely, the procedure of image capturing can start. Open the main interface (as described in Section 12.3. ) and select the desired option.

After the operation is complete, a set of images will have been stored in the SCAN folder (/root/Desktop/PICS/SCAN/).

In order to be able to go to the next step, the use of an external USB drive is highly recommended. Cut or copy the images and paste them into the USB drive to transfer them into a Windows computer. The reason is that a high computing speed and memory are required, and this cannot be achieved with a Raspberry Pi, which has been used to act as a controlling device for the stepper motor and the webcam.

65

Report

Figure 13.5. Detail of a series of 15 output images captured with the device.

The imaging platform captures one photograph per step reached by the stepper motor, then gives an automatic name for every picture taken which contains the date and hour of capture. This is so mainly because of this simple reason: if the script orders to store an image and give it a name such as Image01.png, every step reached will generate a new image that will overwrite the previous one. This being so, the user would end up expecting a folder with a determined number of files (depending on the number of steps taken) but only one single image file named Image01.png, which would correspond to the last image captured at the last step of the “for” script loop.

In order to completely remove this problem from the equation, the inclusion of the complete date of capture (SCAN_ddmmyyyy-hhmmss.png) introduces an extra suffix that will be variable over time, eliminating the fact that two images could get overwritten. Therefore, each picture is ensured to have its unique identifier when stored.

The reason why the output format is PNG instead of others is because PNG is a lossless compression format, this meaning that it will be useful while the point matching process is ongoing.

13.4. THE USE OF VISUALSFM FOR SURFACE RECONSTRUCTION

VisualSFM will be used in order to execute the n-view matching, sparse reconstruction and dense reconstruction.

66

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

The way to use it manually as a standalone application would give, after the missing matches computation, a sparse 3D reconstruction that would ressemble what is shown in Figure 13.6. Note that the individual camera positions and orientations are detected. In this case the images have been taken in a steady, circular fashion thanks to the imaging device that has been specifically manufactured for this purpose, but could as well have been taken in any order or angle that is preferred by the user.

Figure 13.6. Sparse reconstruction from VisualSFM in manual mode. The matching information captured by the different camera views is computed and displayed.

After having a first approach with the sparse reconstruction, the dense surface reconstruction takes place. A .nvm file is created, containing all the relevant information about color, position and orientation for a point set that will look as displayed by Figure 13.7:

Figure 13.7. Dense reconstruction using VisualSFM in manual mode.

67

Report

After this, the .ply point set could be imported into Meshlab for post-processing, which would include cleaning, simplification and mesh reconstruction, apart from texturing. This would be a complicated task, in case that the dense reconstruction had lots of unreferenced or distant points that should be deleted by hand.

After some cleaning work, the point set could have the following appearance:

Figure 13.8. Point set after importing the project into Meshlab.

13.5. MESH QUALITY IMPROVEMENT BY USING MESHRECON

The previous section has been a quick explanation about how to achieve an output point set that does not conform a 3D mesh initially, although it can be created with a Poisson surface reconstruction. This would be the usual process, but the quality achieved by anyone who is not a meshing expert would be rather poor.

Nonetheless, a third-party batch task program called MeshRecon that has VisualSFM integrated as the main processing engine for photogrammetry will be used to accomplish the final mesh shape. Since it works internally with VisualSFM, the point matching and surface reconstructions can be done with MeshRecon instead of using VisualSFM directly, but in addition to this, MeshRecon offers a set of excellent mesh optimizing and refining algorithms and will provide an already computed .ply mesh output, which can be directly imported into Meshlab for cleaning and preparation purposes.

68

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

By placing the set of captured images into the img folder inside MeshRecon, the only next step is to execute the run.bat file. This will start the analysis and might take some time to complete the final refined mesh.

Figure 13.9. Content of the MeshRecon main folder.

After reconstruction, optimization and mesh refining, the following output files have been generated and can be found inside the results folder, in the way displayed by Figure 13.10. Contents of the results folder after analysis.:

Figure 13.10. Contents of the results folder after analysis.

- One non-refined MESH_init.ply and one refined MESH_refine.ply Stanford polygon meshes. This output file format was specifically designed to store three-dimensional data from 3D scanners. The data storage format supports a relatively simple description of a single object as a list of nominally flat polygons. A variety of properties can be stored, including color and transparency, surface normals, texture coordinates and data confidence values. The format allows to have and store different properties for the front and back face of a polygon.

MESH_init.ply is not optimized, so given its low fidelity it will not be used to generate the final shape. MESH_refine.ply will be the one that will reproduce the shape with a reasonable degree of fidelity.

69

Report

Figure 13.11. Detail of the non-textured, non-refined MESH_init.ply. Although the mesh reproduces the overall form of the object, the quality presented is way below what is expected.

Figure 13.12. Detail of the non-textured, refined MESH_refine.ply that will be used for as replica. As it can be seen, the quality of this mesh is greatly superior to the unrefined mesh. This is thanks to the optimization and refinement algorythms that MeshRecon provides within its workflow.

- One output.nvm n-view match project file. This will be opened with Meshlab to introduce parameters such as the raster images associated to the model. In addition to this, one .sift and

70

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

.mat files have been generated for each one of the pictures in the img folder, and contain crucial information for the surface reconstruction and texturing to take place. - One output.sfm file, generated by the program. This file, although necessary, will be created but will not have any further relevance for the user in this case.

13.6. POST-PROCESSING

To start cleaning the mesh of possible topological issues, the first thing necessary is to import the information relative to the mesh. This is done by importing the output.nvm as project file in Meshlab. If only the mesh is opened but not the .nvm file, the only mesh properties will be its shape, but it could not be texturized

After this, the MESH_refine.ply mesh file must be opened. This will show the refined mesh and guarantee that the necessary material information is also present.

13.6.1. Mesh cleaning

In order to check a correct mesh topology, some fixing operations need to be done. Although the output mesh quality could almost be taken as is, it could happen that some geometrical elements (vertices, edges, faces) were folded in a way that could present topological problems, but still were mathematically valid, like for example, self-intersection. This is what is called Non-manifold geometry and would be fatal when 3D printing the figure, given that it would present a real world physical impossibility, although matematically the mesh would be correct in geometry.

By navigating to Filters  Cleaning and repairing  Remove faces from non-manifold edges, any face that is generated in a non-manifold configuration will be taken apart from the mesh.

This operation iteratively deletes the smallest area for any non-manifold edge until it becomes 2-manifold.

13.6.2. Mesh texturization

Once the mesh is already clean and without any defects or holes, Meshlab can apply the related raster images associated with every camera step to its true spatial position according the parameters calculated in the 3D reconstruction.

71

Report

In order to do this, there is an option called Parametrization + texturing from registered rasters, which will create a texture map that fits the mesh shape correctly according to the information from the .nvm project file. The options window is shown below:

Figure 13.13. "Parametrization + texturing from registered rasters" option in Meshlab.

This will create a texture map called texture.png, in this case a square of 2048 pixels per side, that will be applied on the refined mesh according to the information stored in the .nvm file that has been previously imported.

The texturized mesh looks like so:

Figure 13.14. Texturized mesh. Some details of the base and background can be observed.

72

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

13.6.3. Final preparations

Now the mesh is correctly textured and the results are visually agreeable for this particular case. It has to be stressed that the image capture has been accomplished by using a commodity webcam which has not been designed for taking very close range shots in a high enough resolution to achieve a higher level of fidelity. The immediate output results look nonetheless sufficient to illustrate the concept of photogrammetry applied to an image capture device.

- Export as OBJ

The final mesh in Meshlab has been exported to Wavefront (.obj) file type, which generates three different outputs.

One .obj object geometry file.

One .mtl material information file which contains texture coordinates and some other relevant information to correctly map the texture on the mesh.

One texture.png image that is the external appearance of the object, and has been generated when the Parametrization and texturing from registered rasters command has taken place.

- Import to Blender and geometry cleanup

The next step will be to delete unnecessary geometry that has no relevance. This is accomplished by importing the .obj file into Blender.

Select the object by right-clicking on it and press Tab, which will engage the Edit mode.

After this, choose the correct position and orientation for the figure to be as aligned as possible with the main coordinate system. This can be done by pressing G (Grab) followed by the X, Y or Z axis along which the geometry needs to be dragged. Alternatively the R (Rotate) key has the same effect and rotates the selected geometry around the corresponding axis.

73

Report

Figure 13.15. MESH_refine.ply imported to Blender.

- Stand creation by mesh modification

Press B and form a rectangle to select vertices that will be deleted. This operation can be accumulated and the previous selection will not be lost. Following to this, select and clean the contour from isolated triangles and align all the contour vertices to the same Z height by pressing S (Scale), Z and then 0, which will scale them up or down to the same level.

Figure 13.16. Base vertex cleaning before extruding.

74

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Now that a perimeter with the same Z values has been created, extrude the vertices by pressing E (Extrude) and Z to create the stand thickness geometry.

Figure 13.17. Vertex extrusion that will conform the object base.

The last step consists in closing the mesh by its newly created stand, which can be done by pressing Alt+F. Since all the selected vertices are already connected by edges, this operation will create triangular faces between the selected points and consequently close the mesh, which is now hollow, watertight and ready to be 3D printed.

Figure 13.18. Face filling operation that closes the mesh by the standing platform.

After these post-processing operations, the final stage of the 3D reconstruction has ended and the figure can be now correctly scaled and printed.

75

Report

Figure 13.19. Final mesh shape, after post-processing in Blender.

The online 3D-printing service named i.materialise.com has been chosen as the only 3D printing manufacturing solution for this project, given previous experiences with this company and the high degree of fidelity and customer satisfaction.

The result has been 3D printed in multi-color plastic, which will highlight the small details of the object’s geometry as well as its color properties.

76

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

14. RESULTS

As a concluding chapter, this is a brief overview of the main stages of this project and the results obtained after establishing the design guidelines, manufacturing the parts and programming the software.

14.1. QUICK REVIEW OF THE ACTIONS TAKEN IN THIS PROJECT

Starting from the idea to join the already acquired engineering knowledge together with a personal and professional interest which is technology and applied image processing, this project starts by proposing to reproduce the shape and color of a small sample object, such as this replica of the Chichén Itzá mexican pyrammid. For the next picture the object has been placed on a thin black foam layer.

Figure 14.1. Real sample object.

After finding an open source photogrammetry software, the needs are aimed to acquire some data that is capable to save the geometry and texture of this figure, which elliminates the use of laser only. With the purpose of accomplishing this task with the least possible sensors, and in order to do it in the most automated way available, it was decided to manufacture a camera-based device that could take a set of pictures and apply photogrammetry algorithms in such a way that the geometry of the figure could be stored and afterwards post-processed, alongside with its texture map.

Thanks to the use of MeshRecon the surface reconstruction has been possible. Meshlab and Blender have made possible to post-process the mesh (cleaning, repairing, texturing) in such a degree of fidelity that the

77

Report ending result looks as shown in Figure 14.2 below , which keeps an enormous similitude with respect to the original shape, in both geometry and color properties.

Figure 14.2. 3D mesh after reconstruction.

After the 3D reconstruction the mesh has been uploaded into an online 3D printing service and a printing order has been placed. The following is the resulting object, which may slightly vary regarding color fidelity. This is caused by the printing technique itself, which, being conscious of its current limitations, should be able to reproduce the color of every single point of the figure with a certain chromatic similitude, although the tonality might not be matched entirely.

Figure 14.3. 3D printed object, which shows similar color features than the original.

78

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

79

Report

15. ENVIRONMENTAL IMPACT STUDY

This chapter aims to define the environmental impact that the activity related to this project will produce. It is going to cover every phase within the lifecycle of this product, which is design, manufacturing and assembly, usage and end of life.

As an initial statement it can be said that this machine and its usage do not present any harmful interactions with the environment. Neither the parts nor the functioning itself are related to materials, byproducts or procedures that require a special consideration regarding any potential environmental risks.

15.1. DESIGN PHASE

The machine design has required the construction of one unitfor displaying purposes, but this prototype has been built as the final result, not as a testing device. The entire design of this machine has been accomplished by the use of 3D modeling software, so no testing units have been required.

15.2. MANUFACTURING AND ASSEMBLY

The presented prototype has been accomplished by 3D printing some of the parts especially designed for it to function as intended, without the need of any machining or more time demanding manufacturing method. Nevertheless a wide variety of manufacturing techniques can be used to obtain these parts, which can avoid polymers to be the building material. The driven shaft, rotating beam and other moving parts can be manufactured in aluminum or steel, which would enormously increase their mechanical properties at the cost of adding extra weight to the system.

The designed parts have been 3D printed in polyamide by using selective laser sintering (SLS) by a company specialised in this type of manufacturing techniques and subject to the belgian legislation regarding synthesis, byproduct and waste disposal of this nature. Nonetheless polyamide is not a dangerous material itself but it should be disposed responsibly and recycled.

The rest of parts are made of aluminum or steel, and the base is made of industrial PVC, which will not react with most of chemical compounds, elliminating the risk of contaminants as byproduct of an accidental chemical reaction between the plastic materials and the environment, if this would happen at any point.

80

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

15.3. MACHINE USAGE

During the usage of this machine no waste is generated.

The machine does not require any maintenance and no lubricants or oils of any nature are used, given that shielded ball bearings are used and they will not achieve any sign of wear during the life of this device. The electrical motor operates free of oils.

Should any part break or wear, the only thing that would be required is the adequate disposal of said part, by bringing it to any recycling point where it could be re-purposed.

The electrical consumption of the whole system is limited to the usage of a mini-computer and a laptop, and for the 3D reconstruction a computer with enough processing power is also required, but even with a simultaneity factor of 100 percent the total consumption is not a value that can be considered an environmental threat and does not reach industrial levels at any point of its lifecycle.

15.4. END OF LIFECYCLE

When the machine reaches the end of its life in service and disposal is require, it simply will need to get disassembled in its different parts, and these grouped according to their nature, then brought to the recycling point.

15.5. CONCLUSIONS ON THE ENVIRONMENTAL IMPACT STUDY

This machine is built by using materials and procedures that do not generate a big environmental impact, and during its lifecycle it does not consume a great electrical power and does not generate any waste product. Its disposal is safe and no special care needs to be taken regarding the nature of the parts that compose this device.

81

Report

16. ECONOMIC IMPACT STUDY

As a last stage of this project it is necessary to evaluate the costs of this machine, as well as ellaborate a brief business plan that allows the material costs, development and general work hours to be returned in the form of economical profit.

In first place, the following tables gather the total material costs associated to this project, expressed in Euros and separated by nature.

16.1. MATERIAL COSTS LIST

The costs of the development, manufacture, construction, modification and revision of a working prototype device are as follows:

Reference / Model Description Unit price Units Quantity Subtotal (€) 28BYJ-48 Stepper motor 3,91 € 1 3,91 Logitech QuickCam Pro 9000 Web camera 71,10 € 1 71,10 Ø2x10 Wood screw 0,04 € 6 0,26 Ø4x16 Wood screw 0,06 € 9 0,53 Ø4x25 Wood screw 0,06 € 2 0,13 M4x10 Metric thread screw 0,01 € 24 0,23 7318.16.0080 T-nut for M4 screw 0,19 € 24 4,53 617CH00 Horizontal main beam 2,96 € 1 2,97 617CP00 GT2 pulley Ø12 z=12 3,14 € 2 6,29 617CP01 GT2 timing belt L=200 mm 2,77 € 1 2,77 617CR00 Radial ball bearing Ø8xØ22x7 0,79 € 2 1,58 617CU00 L-plate 2,33 € 2 4,66 617CV00 Main vertical support 2,96 € 1 2,96 617MB00 Base + Cut 71,02 € 1 71,02 617MH00 Stepper mount 16,18 € 1 16,18 617MH01 Bearing support 16,18 € 1 16,18 617MR00 Idle shaft 14,90 € 1 14,90 617MR01 Rotating beam 16,18 € 1 16,18 617MR02 QuickCam mount 16,18 € 1 16,18 617MR03 Fixing cap 14,49 € 1 14,49 617MS00 Safety jail 70,86 € 1 70,86 617MV00 Base support 24,25 € 1 24,25 - Female-male Jumper wires set 0,08 € 11 0,85 - Breadboard 1,98 € 1 1,98 - Raspberry Pi breakout cobbler 5,49 € 1 5,49 ULN2803 8-channel Darlington array driver 1,54 € 1 1,54 - GPIO ribbon cable for Raspberry Pi 2,33 € 1 2,33 Raspberry Pi Model B Raspberry Pi Model B 23,66 € 1 23,66

82

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

TOTAL 398,01 €

Table 16.1. Material costs of the projected prototype device.

Code Concept Unit price Units Quantity Subtotal ENGC-PRJ Engineering costs 23,70 €/h 592 14.030,40 ENGC-R+D Research and consulting costs 23,70 €/h 7 165,90 WRKC-BLD Assembly and testing costs 17,38 €/h 8 139,04 ENGC-PRT Part modifications 134,91 € 1 134,91 ENGC-TEST Prototype results printing test 43,97 € 1 43,97 HNDL-SHIP Handling and shipping costs 35,55 € 1 35,55 TOTAL 14.549,77 €

Table 16.2. Additional project charges.

By summing the values of material costs and additional project charges, the total value of this project plus prototype ascends to 14.947.78 €, which will have to be repaid by creating a mid-term sales plan that should provide a symbolic revenue at the end of that period.

16.2. SALES PLAN (5 YEARS)

The first stage of the 5-year sales plan is to achieve the lowest possible production costs, which will require of commercial skills and comparisons between different suppliers.

16.2.1. Estimated production cost (per unit)

It can be possible to offer more economical production costs by selecting more affordable manufacturing techniques, such as lathe machining or plastic injection, if a contract allowing discounts for large orders is established. Would some products require the creation of a mold, or a certain preparation time of a CNC mill or lathe, it would also be necessary to increase the final price to cover such additional production expenses.

As an example, the following parts have been supposedly manufactured by using any plastic transformation technique that allows the price to substantially drop, such as long series of plastic injection:

617MH00, 617MH01, 617MR01, 617MR02, 617MR03, 617MS00, 617MV00

Similarly, a conventional or automatic CNC lathe production has been supposed for 617MR00. This means that the price in the following table simulates a medium series production part price which might be achieved by using Ø12 rods of AISI 303 stainless steel (1.4305), machined by using common lathe cutting tools (CNMG 120408 for rough machining and DCMT 11T304 for finishing pass).

83

Report

For commercial products, bulk orders can be placed as well in order to to lower the price even more. This is an estimation of what could be the final prices once the corresponding discounts have been applied.

For example, regarding the price of 617MB00, it is supposed that a fictional bulk order of 300 units of 15 mm thick industrial PVC plates, plus the cutting work, could be provided and discounted, which could reduce the price from the original 71.02 € down to 62.00 € (Excl. VAT).

Reference / Model Description Unit price Units Quantity Subtotal (€) 28BYJ-48 Stepper motor 3,91 € 1 3,91 Logitech QuickCam Pro 9000 Web camera 71,10 € 1 71,10 Ø2x10 Wood screw 0,05 € 6 0,26 Ø4x16 Wood screw 0,06 € 9 0,53 Ø4x25 Wood screw 0,06 € 2 0,13 M4x10 Metric thread screw 0,01 € 24 0,23 7318.16.0080 T-nut for M4 screw 0,19 € 24 4,53 617CH00 Horizontal main beam 2,96 € 1 2,96 617CP00 GT2 pulley Ø12 z=12 3,14 € 2 6,29 617CP01 GT2 timing belt L=200 mm 2,77 € 1 2,77 617CR00 Radial ball bearing Ø8xØ22x7 0,79 € 2 1,58 617CU00 L-plate 2,33 € 2 4,66 617CV00 Main vertical support 2,96 € 1 2,96 617MB00 Base + Cut 62,00 € 1 62,00 617MH00 Stepper mount 2.00 € 1 2.00 617MH01 Bearing support 2.10 € 1 2.10 617MR00 Idle shaft 3.50 € 1 3.50 617MR01 Rotating beam 9.40 € 1 9.40 617MR02 QuickCam mount 7.00 € 1 7.00 617MR03 Fixing cap 1.30 € 1 1.30 617MS00 Safety jail 20.00 € 1 20.00 617MV00 Base support 2.70 € 1 2.70 - Female-male Jumper wires set 0,08 € 11 0,85 - Breadboard 1,98 € 1 1,98 - Raspberry Pi breakout cobbler 5,49 € 1 5,49 ULN2803 8-channel Darlington array driver 1,54 € 1 1,54 - GPIO ribbon cable for Raspberry Pi 2,33 € 1 2,33 Raspberry Pi Model B Raspberry Pi Model B 23,66 € 1 23,66 TOTAL 199.76 €

Table 16.3. Possible final price.

16.2.2. Sales plan for 6170000 (5-year plan)

After a market study it is forecasted that the possible sales along the 5-year period allow to sell 500 units by following Table 16.4:

84

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Period Estimated units sold Estimated sales

Year 1 70 14.000 €

Year 2 110 22.000 €

Year 3 130 26.000 €

Year 4 110 22.000 €

Year 5 80 16.000 €

TOTAL (5y) 500 100.000 €

Table 16.4. Unit and cost estimation, in 5 years.

This is the chart of the sales progression along the 5-year period:

Sales estimation (5 -year pl an)

140 130 120 110 100 110 80 70 60 80 40

20 ESTIMATED UNITS SOLDESTIMATED UNITS 0 0 1 2 3 4 5 YEAR

Figure 16.1. Sales estimation graph for a 5-year sales plan.

16.2.3. Estimated sales (5-year plan)

Supposing a production cost of 200 €/each unit, the sales should be as estimated above:

500 units · 200 €/each = 100.000 € as production costs in 5 years.

It is also important to add the project costs, which include numbers such as the prototype manufacturing and assembly, tests driven, consulting and other tasks accomplished by the R+D department. In addition to this, it is estimated that the expenses in advertisement, packaging and storage will reach the amount of 7.000 € in 5 years:

85

Report

Estimated production costs 100.000 €

Project costs 14.947.78 €

Additional expenses 7.000 €

Estimated profit 8.000 €

Estimated sales (5 years) ≥130.000 €

Table 16.5. 5-year plan data table.

This sample sales plan is intended to repay the development costs and the additional expenses in 5 years. The final price would be as follows:

130.000 € / 500 units = 260.00 €/u + VAT (21%) = 314.60 €/u (market price)

This implies that in 5 years the total project cost is repaid if the sales target is accomplished, plus a revenue of 8.000 €. This amount would increase from the sixth year on, given that the project cost would be entirely recovered. If the sales target would keep steady at 100 units per year for the next five years, it would be possible to obtain a total profit of approximately 23.000 € at the end of said period.

86

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

CONCLUSION AND FINAL WORDS

Applied photogrammetry is currently a great technique that is largely used in mostly military and cartography applications. Nevertheless it is also getting popular in industrial environments, where the techniques to capture the finest details of mechanical parts or even entire scenes are every day more efficient and rentable.

Few resources have been used in order to accomplish this project and have the device ready and working. The only elevated cost has been to 3D print the parts in polyamide through the technique of selective laser sintering (SLS), given that what is presented here is only a working prototype that does not intend in any way to serve as a commercial solution, which would need to cost less in order to be competitive. This project has been the proof that it is possible to add an automated way to acquire the data and add it to the 3D reconstruction workflow.

Once the results, the environmental analysis and a brief economical study have been documented, here concludes this activity report which is the main document in this project.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

87

Report

WORKS AND SUPPORTING REFERENCES USED IN THIS REPORT

1. Schenk, T. Introduction to Photogrammetry. Ohio : s.n., 2005. 2. In a Nut Shell... Direct Network Connection. [Online] https://pihw.wordpress.com/guides/direct- network-connection/in-a-nut-shell-direct-network-connection/. 3. List of Free Linux distributions. GNU website. [Online] https://www.gnu.org/distros/free- distros.en.html. 4. Sijmons, Koert. drm.cenn.org. [Online] http://drm.cenn.org/Trainings/Generation%20of%20geodatabases%20using%20ARCGIS%20and%20ERD AS/Lectures/Introduction%20on%20Photogrammetry.pdf. 5. Falkingham, Dr. Peter L. Trying all the free Photogrammetry! pfalkingham.wordpress.com. [Online] https://pfalkingham.wordpress.com/2016/09/14/trying-all-the-free-photogrammetry/. 6. Adafruit's Raspberry Pi Lesson 10. Stepper Motors. learn.adafruit.com. [Online] https://learn.adafruit.com/adafruits-raspberry-pi-lesson-10-stepper-motors. 7. The Tkinter Button Widget. effbot.org. [Online] http://effbot.org/tkinterbook/button.htm. 8. The Tkinter Pack Geometry Manager. effbot.org. [Online] http://effbot.org/tkinterbook/pack.htm. 9. What is Photogrammetry. geodetic.com. [Online] http://www.geodetic.com/v-stars/what-is- photogrammetry.aspx. 10. Embedding Python in Apache2 with mod_python (Debian Etch). howtoforge.com. [Online] https://www.howtoforge.com/embedding-python-in-apache2-with-mod_python-debian-etch. 11. Stepper Motor basics and Control - How it works. youtube.com. [Online] https://www.youtube.com/watch?v=bngx2dKl5jU. 12. Stepper Motor Control with the Raspberry Pi. youtube.com. [Online] https://www.youtube.com/watch?v=Dc16mKFA7Fo. 13. Python. python.org. [Online] https://www.python.org/. 14. Kang, Zhuoliang. Mesh Reconstruction from Imagery. zhuoliang.me. [Online] http://zhuoliang.me/meshrecon.html. 15. Wu, Changchang. VisualSFM: a visual structure from motion system. ccwu.me. [Online] http://ccwu.me/vsfm/. 16. Blender. blender.org. [Online] https://www.blender.org/. 17. Meshlab. meshlab.net. [Online] http://www.meshlab.net/. 18. GitHub. github.com. [Online] https://github.com/cshorler/webcam- tools/blob/master/uvcdynctrl/data/046d/logitech.xml. 19. Ortiz Morón, Pedro. Diseño de máquina para ensayo de fatiga a flexión rotativa con cuatro puntos de apoyo. 2016.

88

TREBALL FI DE GRAU

Grau en Enginyeria Mecànica

MECHANICAL DESIGN OF A PHOTOGRAMMETRY IMAGING PLATFORM FOR PROTOTYPE MESHING

Volume II (of III)

Appendix A - Calculations

Appendix B - Scripts

Author: Carlos Gómez Gaibar Director: Pedro Ortiz Morón Department : EM Call: June 2017

TREBALL FI DE GRAU

Grau en Enginyeria Mecànica

MECHANICAL DESIGN OF A PHOTOGRAMMETRY IMAGING PLATFORM FOR PROTOTYPE MESHING

Appendix A - Calculations

Author: Carlos Gómez Gaibar Director: Pedro Ortiz Morón Call: June 2017

Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

TABLE OF CONTENTS

A-1. STatic load analysis: methodology to apply ...... A-1

A-1.1. Load configuration ...... A-1

A-1.2. System simplification ...... A-1

A-1.3. Structural analysis based on static equilibrium equations ...... A-1

A-2. Data tables for weight distributions ...... A-3

A-3. Static load analysis on 617MR00 (idle or driven shaft) ...... A-5

A-3.1. Load configuration ...... A-5

A-3.2. System simplification ...... A-6

A-3.3. Structural analysis based on static equilibrium equations ...... A-7

A-3.3.1. Balance of forces ...... A-7

A-3.3.2. Balance of moments ...... A-8

A-4. Static load analysis on 617CV00 (vertical aluminum support) ...... A-9

A-4.1. Load configuration ...... A-9

A-4.2. System simplification ...... A-10

A-4.3. Structural analysis based on static equilibrium equations ...... A-12

A-4.3.1. Balance of forces ...... A-12

A-4.3.2. Balance of moments ...... A-12

A-5. Stress diagrams ...... A-14

A-5.1. Stress diagrams for 617MR00 ...... A-14

A-5.2. Stress diagrams for 617CV00 ...... A-15

A-6. Ball bearing loads ...... A-16

A-I

Calculations

A-6.1. Radial and Axial loads present in the system ...... A-16

A-6.2. Statically demanded ball bearings ...... A-16

A-6.2.1. Static load rating and equivalent static load ...... A-16

A-6.2.2. Static stress factor ...... A-17

A-6.3. Dynamically demanded ball bearings ...... A-18

A-6.3.1. Dynamic load rating and equivalent dynamic load ...... A-18

A-II Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

INDEX OF TABLES

TABLE A-2.1. WEIGHTS AND CENTERS OF MASS OF THE PARTS CONFORMING THE ROTATING SECTION (EXCEPT 617MR00)...... A-3

TABLE A-2.2. WEIGHTS AND CENTERS OF MASS OF THE SECTION MOUNTED ON THE 617CH00 ALUMINUM HORIZONTAL BEAM...... A-4

TABLE A-2.3. VALUE TABLE OF DISTANCES AND MAGNITUDES USED TO CALCULATE THE REACTIONS ON THE BEARINGS AND BASE CLAMP...... A-4

TABLE A-5.1. VALUES OF THE STRESS DIAGRAMS, DIVIDED BY PORTIONS IN MM...... A-14

TABLE A-5.2. VALUES OF THE SHEAR STRESSES ON THE SHAFT, DIVIDED BY PORTIONS IN MM...... A-15

TABLE A-5.3. STRESS DIAGRAMS ON THE VERTICAL SUPPORT...... A-15

TABLE A-6.1. TABLE OF CHARACTERISTICS OF THE BALL BEARINGS...... A-17

TABLE A-6.2. VALUE OF F0 DEPENDING ON BEARING MODEL...... A-19

TABLE A-6.3. TABLE FOR OBTAINING THE X AND Y FACTORS...... A-19 INDEX OF FIGURES

FIGURE A-3.1. ISOLATED COMPONENTS FROM THE ROTATING SECTION, PLUS THE POWER TRANSMISSION FROM THE DRIVING PULLEY...... A-5

FIGURE A-3.2. XY SIDE VEW OF THE PARTS THAT AFFECT THE IDLE SHAFT...... A-6

FIGURE A-3.3. YZ FRONT VIEW OF THE PARTS THAT AFFECT THE IDLE SHAFT...... A-6

FIGURE A-3.4. LOADS APPLIED OVER THE SHAFT (XZ PLANE)...... A-6

FIGURE A-3.5. LOADS APPLIED OVER THE SHAFT (YZ PLANE)...... A-7

FIGURE A-4.1. TRI-DIMENSIONAL VIEW OF THE DEVICE. IT CAN BE OBSERVED THAT A COMPOUND BENDING STRESS WILL APPEAR ON BOTH

617CV00 VERTICAL SUPPORT AND 617MR00 DRIVEN SHAFT...... A-9

FIGURE A-4.2. SIDE VIEW OF THE COMPLETE ASSEMBLY...... A-10

FIGURE A-4.3. REAR VIEW OF THE COMPLETE ASSEMBLY...... A-10

FIGURE A-4.4. LOAD DISTRIBUTION IN THE XZ PLANE...... A-11

FIGURE A-4.5. LOAD DISTRIBUTION IN THE YZ PLANE...... A-12

FIGURE A-5.1. AXIAL AND BENDING MOMENT DIAGRAMS FOR 617MR00...... A-14

FIGURE A-5.2. SHEAR STRESS DIAGRAMS FOR 617MR00...... A-15

FIGURE A-5.3. STRESS DIAGRAMS FOR THE VERTICAL SUPPORT...... A-15 INDEX OF EQUATIONS

EQUATION A-1.1 ...... A-1

EQUATION A-1.2 ...... A-2

EQUATION A-3.1 ...... A-7

EQUATION A-3.2 ...... A-8

EQUATION A-4.1 ...... A-12

EQUATION A-4.2 A- ...... 13

A-III

Calculations

EQUATION A-6.1 ...... A-16

EQUATION A-6.2 ...... A-16

EQUATION A-6.3 ...... A-17

EQUATION A-6.4 ...... A-17

EQUATION A-6.5 ...... A-17

EQUATION A-6.6 ...... A-18

EQUATION A-6.7 ...... A-18

EQUATION A-6.8 ...... A-19

EQUATION A-6.9 ...... A-20

EQUATION A-6.10 ...... A-20

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

A-IV Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

A-1. STATIC LOAD ANALYSIS: METHODOLOGY TO APPLY

A-1.1. LOAD CONFIGURATION

The first thing to do is to isolate the target component and identify all the external forces applied on it. This includes any loads coming from elements that rest on the part as well as the reaction forces present in the clamps, hinges or any other supporting part.

The chosen load configuration should be the most dynamically demanding, since the goal of this simple group of calculations is to know the type of stresses that will affect the structure and critical parts in order to justify their dimensions, materials and shape.

A-1.2. SYSTEM SIMPLIFICATION

Following the rules of the superposition principle, would there be any way to simplify the effect of a set of forces applied over an element, the resulting force would be effectively equal to the sum of each individual action. The application point of said resulting force is then located in such a place that the effect of the equivalent stress provokes the same result as the one coming from the individual actions applied to the system.

A-1.3. STRUCTURAL ANALYSIS BASED ON STATIC EQUILIBRIUM EQUATIONS

One of the two fundamental equations in static analysis expresses that the sum of any external force applied on the target system that has to be studied must be equal to zero. This condition has implicit that the forces existing in a specific axis in the chosen reference system must cancel each other to guarantee that there will not be any displacements that change the object’s spatial position.

푖=푚

∑(퐹⃗ ) = 0⃗⃗ 푖 푋 푖=1 푖=푚 푖=푚 ⃗ ⃗⃗ ∑ 퐹푖 = 0 → ∑(퐹⃗푖) = 0⃗⃗ 푌 푖=1 푖=1 Equation 푖=푚 A-1.1 ∑(퐹⃗ ) = 0⃗⃗ 푖 푍 { 푖=1

The second condition of static equilibrium dictates that an object that is not moving at a certain speed is not enough to be considered in equilibrium, given that it can be rotating around any axis in any possible way

A-1

Calculations without changing its position in space. As a consequence of this, a second equation must be generated, and it keeps a strong similarity with the first one.

The equation indicates that the sum of every individual moment with respect to any point in the space in any one of the X, Y and Z axis must be equal to zero, which signifies that the element will not present any rotations around the X, Y or Z axis, or any combination of them.

푖=푛

∑ (푀(푃) ) = 0⃗⃗ 푖 푋푌 푖=1 푖=푛 푖=푛 ⃗⃗ ∑ 푀(푃) = 0 → ∑ (푀(푃) ) = 0⃗⃗ 푖 푖 푋푍 푖=1 푖=1 Equation 푖=푛 A-1.2 ∑ (푀(푃) ) = 0⃗⃗ 푖 푌푍 {푖=1

Once these two conditions are satisfied, the static equilibrium of a system under load stresses can be guaranteed.

A-2 Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

A-2. DATA TABLES FOR WEIGHT DISTRIBUTIONS

The following tables show a list of references corresponding to the parts that compose the imaging device, with information about their individual weight and position of their individual center of mass once the system has been put in the most stress-demanding position and angle. The first table shows the center of mass positions of the elements that affect the driven shaft, as well as their individual mass and the total values for equivalent load calculations.

LOADS (FOR DRIVEN SHAFT)

Ref Description Mass [g] xcm [mm] ycm [mm] Remarks 617MR01 Rotating beam 20 -74,54 0,00 Furthest away from vertical support QuickCam Pro 9000 Webcam 80 -123,51 -30,69 Most compromised angle = 128º 617MR03 Fixing cap 2 -143,73 8,29 Most compromised angle = 128º 617MR02 Quickcam support 11 -139,90 -22,15 Most compromised angle = 128º

Total mass [g] XCM [mm] YCM [mm]

113 -116,80 -23,73 Total weight [N] XCM [m] YCM [m]

1,11 -0,11680 -0,02373 Table A-2.1. Weights and centers of mass of the parts conforming the rotating section (except 617MR00).

In order to calculate the equivalent load applied over the 617CH00 horizontal beam, which is connected to the 617CV00 vertical support, the individual center of mass positions have been calculated and presented in the following table.

A-3

Calculations

LOADS (FOR 617CV00)

Reference Description Mass [g] xcm [mm] ycm [mm] Remarks

617CP00 Timing pulley (SFT) 6 191,00 0,00 617MR00 Idle shaft 4 191,00 0,00 617MR01 Rotating beam 20 263,86 0,00 Furthest away from 617CV00 QuickCam Pro 9000 Webcam 80 314,51 -30,69 Most compromised angle = 128º 617MR03 Fixing cap 2 329,72 8,29 Most compromised angle = 128º 617MR02 QuickCam support 11 332,42 -22,15 Most compromised angle = 128º 617CP00 Timing pulley (STP) 6 109,86 0,00 617CR00 (sup) Radial bearing 10 191,00 0,00 617CR00 (inf) Radial bearing 10 191,00 0,00 617MH01 Bearing support 41 168,88 0,00 617MH00 Stepper support 22 101,97 0,00 617MS00 Safety jail 40 105,62 0,00 617CH00 Horizontal beam 100 78,50 0,00 617CV00 Vertical support 82 0,00 0,00 28BYJ-48 Stepper motor 37 101,88 0,00 617CU00 L-plate (LEFT) 30 15,37 -12,00 617CU00 L-plate (RIGHT) 30 15,37 12,00

Total mass [g] XCM [mm] ZCM [mm]

531 126,32 -5,05

Total weight [N] XCM [m] ZCM [m]

5,21 0,12632 -0,00505

Table A-2.2. Weights and centers of mass of the section mounted on the 617CH00 aluminum horizontal beam.

Name Value [g], [mm] Value [N], [m]

|푇⃗⃗퐵| 80 g 0,7848 N

|푊⃗⃗⃗⃗푇| 113 g 1,10853 N

y1 20,2 mm 0,0202 m

y2 25 mm 0,025 m

y3 34,5 mm 0,0345 m

x1 116,80 mm 0,11680 m

z1 23.73 mm 0.02373 m

Table A-2.3. Value table of distances and magnitudes used to calculate the reactions on the bearings and base clamp.

A-4 Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

A-3. STATIC LOAD ANALYSIS ON 617MR00 (IDLE OR DRIVEN SHAFT)

A-3.1. LOAD CONFIGURATION

This load configuration corresponds to the most severe load case, which is when the rotating beam is located as far as possible from the main vertical support, and is exerting a stress that bends the shaft in the opposite direction as the moment induced by the belt tension.

Figure A-3.1. Isolated components from the rotating section, plus the power transmission from the driving pulley.

A-5

Calculations

Figure A-3.2. XY side vew of the parts that affect the idle shaft.

Figure A-3.3. YZ front view of the parts that affect the idle shaft.

A-3.2. SYSTEM SIMPLIFICATION

Figure A-3.4. Loads applied over the shaft (XZ plane).

A-6 Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure A-3.5. Loads applied over the shaft (YZ plane).

A-3.3. STRUCTURAL ANALYSIS BASED ON STATIC EQUILIBRIUM EQUATIONS

A-3.3.1. Balance of forces

Making use of Equation A-1.1, the first condition for static equilibrium is expressed as follows:

푖=푚

∑(퐹⃗ ) = 0⃗⃗ → |푇⃗⃗ | + 퐴 = 퐵 푖 푋 퐵 푋 푋 푖=1 푖=푚 푖=푚 ⃗ ⃗⃗ ∑ 퐹푖 = 0 → ∑(퐹⃗푖) = 0⃗⃗ → 퐴푌 = |푊⃗⃗⃗⃗푅| + |푊⃗⃗⃗⃗푆| + |푊⃗⃗⃗⃗푃| = 1.21 푁 푌 푖=1 푖=1 Equation 푖=푚 A-3.1 ∑(퐹⃗ ) = 0⃗⃗ → 퐴 = 퐵 푖 푍 푍 푍 { 푖=1

A-7

Calculations

A-3.3.2. Balance of moments

Proceeding similarly, and according to Equation A-1.2, the second condition of static equilibrium is established as follows:

i=n

∑ (M(P) ) = 0⃗⃗ → −(|⃗T⃗⃗B| · y1) − (BX · y2) + (|W⃗⃗⃗⃗R| · x1) = 0⃗⃗ i XY i=1 i=n i=n ⃗⃗ ∑ M(P) = 0 → ∑ (M(P) ) = 0⃗⃗ i i XZ i=1 i=1 Equation i=n A-3.2 ∑ (M(P) ) = 0⃗⃗ → BZ · y2 = |W⃗⃗⃗⃗R| · z1 i YZ { i=1

These are the resulting values of the components of A and B, which are the reactions on the ball bearings:

B = 4.54 N(←) X AX = 3.76 N(→) 푅푒푠푢푙푡푠: AY = 1.21 N(↑)

BZ = 1.05 N(←) {AZ = 1.05 N(→)

A-8 Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

A-4. STATIC LOAD ANALYSIS ON 617CV00 (VERTICAL ALUMINUM SUPPORT)

A-4.1. LOAD CONFIGURATION

It is observed that the vertical aluminum support will have to be the one in charge to resist the weight of every component that is attached to it. It can be beforehand said that the support will suffer a compression stress due to the weight, and a compound bending, caused by the moment that this set of forces create because of the fact of them existing at determinate distances from the support’s vertical axis, both in the XZ and YZ planes.

Figure A-4.1. Tri-dimensional view of the device. It can be observed that a compound bending stress will appear on both 617CV00 vertical support and 617MR00 driven shaft.

A-9

Calculations

Figure A-4.2. Side view of the complete assembly.

Figure A-4.3. Rear view of the complete assembly.

A-4.2. SYSTEM SIMPLIFICATION

This load configuration can be simplified by calculating the resulting weight (W⃗⃗⃗⃗T) and its application point, whose position (X⃗⃗CM) will be the distance from the equivalent weight’s center of mass to the neutral fiber of

A-10 Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

the vertical support. This will create a moment that will be maximum at the tip of the horizontal beam, and it is going to be this moment what will affect the vertical support until it gets cancelled by the clamp at the base.

In addition, it is known that this fastened component will present an opposing moment (M⃗⃗⃗⃗A,Z) as well as a reaction force (A⃗⃗⃗) that will be equal to the resulting force applied.

The next two images illustrate the final load configuration that affects the vertical support as well as the base clamping part.

Figure A-4.4. Load distribution in the XZ plane.

A-11

Calculations

Figure A-4.5. Load distribution in the YZ plane.

A-4.3. STRUCTURAL ANALYSIS BASED ON STATIC EQUILIBRIUM EQUATIONS

A-4.3.1. Balance of forces

The first thing to do is to consider what is expressed in Equation A-1.1, which will help finding the value of the compressive stress in point A.

푖=푚

∑(퐹⃗ ) = 0⃗⃗ 푖 푋 푖=1 푖=푚 푖=푚 ⃗ ⃗⃗ ∑ 퐹푖 = 0 → ∑(퐹⃗푖) = 0⃗⃗ → −|푊⃗⃗⃗⃗푇| + 퐴 = 0 → 퐴 = −푊⃗⃗⃗⃗푇 = 5.21 푁 (↑) 푌 푖=1 푖=1 Equation 푖=푚 A-4.1 ∑(퐹⃗ ) = 0⃗⃗ 푖 푍 { 푖=1

From the first condition of equilibrium it is concluded that A⃗⃗⃗ is an upwards vertical force that is equal to 5.21 N.

A-4.3.2. Balance of moments

Similarly, by using Equation A-1.2, the values of the two bending effects are calculated.

A-12 Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

푖=푛

∑ (푀⃗⃗⃗(퐴) ) = 0⃗⃗ → |푊푇|· |푋퐶푀| = 푀⃗⃗⃗퐴,푍 = 0.66 푁푚, ⤽ 푖 푋푌 푖=1 푖=푛 푖=푛 ⃗⃗⃗ ⃗⃗ ∑ 푀(푃) = 0 → ∑ (푀(퐴) ) = 0⃗⃗ 푖 푖 푋푍 푖=1 푖=1 Equation 푖=푛 A-4.2 ∑ (푀⃗⃗⃗(퐴) ) = 0⃗⃗ → |푊푇|· |푌퐶푀| = 푀⃗⃗⃗퐴,푋 = 0.03 푁푚, ⤽ 푖 푌푍 { 푖=1 }

And from the second condition of equilibrium it is deduced that the compound bending caused by the resulting weight has a moment whose Z clockwise component of 0.649 N·m will be cancelled by the moment,

M⃗⃗⃗⃗A,Z, which will act in a counter-clockwise fashion. Similarly, there exists an X clockwise moment component that will be cancelled by M⃗⃗⃗⃗A,X with a counter-clockwise value of 0.026 N·m.

퐴⃗ = 5.21 푁 (↑)

푅푒푠푢푙푡푠: {푀⃗⃗⃗퐴,푍 = 0.66 푁푚, ⤽

푀⃗⃗⃗퐴,푋 = 0.03 푁푚, ⤽

A-13

Calculations

A-5. STRESS DIAGRAMS

This chapter will show the stress diagrams of the 617MR00 driven shaft and the 617CV00 main vertical support, in order to display how the system loads affect the stability and resistance in specific points of the components.

A-5.1. STRESS DIAGRAMS FOR 617MR00

Figure A-5.1. Axial and bending moment diagrams for 617MR00.

SHAFT PORTION [mm] N(y) [N] M(z) [Nm] M(x) [Nm] Top (0) 0 ⇾ 0.069 (C) 0 0 0  20.2 0.069 (C) Linear 0 Top bearing (20.2) 0.069 (C) ⇾ 1.167 (T) -0.0158 ⤼ 0 20.2  45.2 1.167 (T) Linear Linear Lower bearing (45.2) 1.167 (T) -0.1294 ⤼ -0.0263 ⤼ 45.2  78.7 1.167 (T) -0.1294 ⤼ -0.0263 ⤼ Bottom (78.7) 1.167 (T) ⇾ 0 -0.1294 ⤼ ⇾ 0 -0.0263 ⇾ 0 Table A-5.1. Values of the stress diagrams, divided by portions in mm.

A-14 Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Figure A-5.2. Shear stress diagrams for 617MR00.

SHAFT PORTION [mm] V(x) [N] V(z) [N] Top (0) 0 ⇾0.78 0 0  20.2 0.78 0 Top bearing (20.2) 0.78 ⇾ 4.54 0 ⇾ 1.05 20.2  45.2 4.54 1.05 Lower bearing (45.2) 4.54 ⇾ 0 1.05 ⇾ 0 45.2  78.7 0 0 Bottom (78.7) 0 0 Table A-5.2. Values of the shear stresses on the shaft, divided by portions in mm.

A-5.2. STRESS DIAGRAMS FOR 617CV00

Figure A-5.3. Stress diagrams for the vertical support.

SUPPORT PORTION [mm] N(x) [N] M(z) [Nm] M(x) [Nm] Top (0) 0 ⇾ 5.21 (C) 0 ⇾ 0.66 ⤽ 0 ⇾ 0.03 ⤽ 0  145 5.21 (C) 0.66 ⤽ 0.03 ⤽ Bottom (145) 5.21 (C) ⇾ 0 0.66 ⤽⇾ 0 0.03 ⤽⇾ 0 Table A-5.3. Stress diagrams on the vertical support.

A-15

Calculations

A-6. BALL BEARING LOADS

A-6.1. RADIAL AND AXIAL LOADS PRESENT IN THE SYSTEM

The axial load (Fa in advance) that the top bearing has to resist is noticeably low, given the reduced weight that has to rest on top of the bearing’s inner crown. The approximated weight acting as thrusting load is 123 g, which indicates that this value will not present any relevant stress for the bearing to function normally. The axial loads that this type of bearings are used to resist are sensibly higher when fixed into a pair of in- line skates. When mounted in such applications, the magnitude of the axial loads that one ball bearing has to endure is usually in the order of kilograms.

The radial load (Fr in advance) applied on the bearings is calculated as the reaction forces that oppose to the bending stresses caused by the rotating section, in order for the driven shaft to keep alignment and verticality. Given that said forces vary depending on the position of one or another bearing, the greater compound value will be considered.

Equation −3 A-6.1 |퐹⃗푎| = 123 푔 = [… ] = 1.20663 · 10 푘푁

Equation 2 2 A-6.2 2 2 |퐹⃗푟| = √|퐵⃗⃗푥| + |퐵⃗⃗푧| = √(463.24 푔) + (107.28 푔) = [… ]

= 4.665 · 10−3 푘푁

A-6.2. STATICALLY DEMANDED BALL BEARINGS

A-6.2.1. Static load rating and equivalent static load

According to manufacturer’s tables, the resistance of a bearing operating at very low speeds is determined by its static load rating, C0. For a shielded Ø8xØ22x7 608.2RS ball bearing made of stainless steel, its static load rating has a value of C0 = 3.25 kN.

A-16 Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Main dimensions [mm] Basic load rates [kN]

d D B Dynamic (C) Static (C0)

Ø8 Ø22 7 3.25 1.37

Table A-6.1. Table of characteristics of the ball bearings.

For a statically demanded ball bearing, the equivalent static load has the following value, which depends on the values of the radial and axial loads applied:

Equation 퐹푎 퐹푎 A-6.3 ≤ 0.8 → 푃 = 퐹 > 0.8 → 푃 = 0.6 · 퐹 + 0.5 · 퐹 퐹 0 푟 퐹 0 푟 푎 푟 푟

Thus, it is concluded that the value of the equivalent static load P0 is equal to the radial load Fr , which is 4.665·10-3 kN.

A-6.2.2. Static stress factor

The static stress factor is a ratio which determines the capacity of the bearing to resist loads before arriving to its maximum static load rate, and can be calculated as follows:

Equation 퐶0 A-6.4 푓 = 0 푃 0

Where:

o C0 is the static load rate [kN]

o P0 is the equivalent static load [kN]

Equation 퐶0 1.37 A-6.5 푓 = = = 293.67 0 푃 4.665 · 10−3 0

From this it can be concluded that the loads present in this system will never exceed the static load capacity of this type of ball bearing, which is almost 294 times higher than the applied loads.

A-17

Calculations

A-6.3. DYNAMICALLY DEMANDED BALL BEARINGS

A-6.3.1. Dynamic load rating and equivalent dynamic load

The equivalent dynamic load calculation can be done as follows:

Equation A-6.6 푃 = 푋 · 퐹푟 + 푌 · 퐹푎

Where:

o X and Y are radial and axial factors,

o 퐹푟 is the radial load [kN]

o 퐹푎 is the axial load [kN]

The X and Y (radial and axial) factors depend on the following relationship:

Equation 퐹푎 A-6.7 푓 · 0 퐶 0

Where:

o 퐶0 is the static load rate,

o 퐹푎 is the axial load,

o 푓0 can be found in tables and depends on the bearing type and its inner diameter. For a 608.2RS

bearing, and a diameter of 8 mm, f0 equals to 12.4.

A-18 Mechanical design and manufacturing of a photogrammetry imaging platform for prototype meshing

Table A-6.2. Value of f0 depending on bearing model.

In this particular case, this relationship has a value of 0.010921, to which corresponds a parameter e that is lesser or equal than the lowest, 0.22. By extrapolating, it would correspond a value of approximately 0.179.

Table A-6.3. Table for obtaining the X and Y factors.

For a normal tolerance bearing, and knowing that the ratio 퐹푎 /퐹푟 = 0.2586 > 푒, it is found that the value of X and Y factors is the following:

푋 = 0,56 푌 = 2

Which allows to evaluate the expression of the equivalent dynamic load, previously seen in Equation A-6.6:

Equation −3 A-6.8 푃 = 0.56 · 퐹푟 + 2 · 퐹푎 = 5.02574 · 10 푘푁

A-19

Calculations

The fatigue life rating of a bearing is defined as the number of revolutions that the bearing can achieve before any sign of fatigue is shown on any of its components, and the manufacturer usually express it as the duration achieved or surpassed by 90 percent of the bearings apparently identical of a big enough sample group.

Equation 푝 A-6.9 퐶 6 퐿10 = ( ) [10 푟푒푣] 푃

Where:

o L10 is the estimated life of the ball bearing, expressed in millions of revolutions,

o C is the dynamic load rate [kN],

o P is the equivalent dynamic load [kN],

o p is the life exponent, which has a value of 3 for ball bearings.

Proceeding as shown, the life of the ball bearings in this device is:

Equation 3 A-6.10 3.25 12 퐿10 = ( −3) = 270.427 · 10 푟푒푣 5.02748 · 10

Which can be considered a practically infinite number of revolutions during its lifecycle. This is nearly impossible to achieve given the application and angular velocity that the motor can generate. It is for this reason that the life of the ball bearings can be taken as infinite during the service of this device.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

A-20

TREBALL FI DE GRAU

Grau en Enginyeria Mecànica

MECHANICAL DESIGN OF A PHOTOGRAMMETRY IMAGING PLATFORM FOR PROTOTYPE MESHING

Appendix B - Scripts

Author: Carlos Gómez Gaibar Director: Pedro Ortiz Morón Call: June 2017

Mechanical design of a photogrammetry imaging platform for prototype meshing TABLE OF CONTENTS TABLE OF CONTENTS ...... B-I

INDEX OF FIGURES ...... B-I

INDEX OF TABLES ...... B-I

INDEX OF EQUATIONS ...... B-II

CODE UTILIZED IN THIS PROJECT ...... B-1

B-1. autoscan.py ...... B-2

B-2. backwards.py ...... B-5

B-3. backwards45.py ...... B-7

B-4. capture.py ...... B-9

B-5. forward.py ...... B-11

B-6. forward45.py ...... B-13

B-7. interface.py ...... B-15

B-8. preview.py ...... B-20

B-9. sim.py ...... B-21

INDEX OF FIGURES FIGURE B-1.1. MAIN CONTROL INTERFACE INTERACTIVE GUIDE...... B-1

INDEX OF TABLES TABLE B-1.1. AUTOSCAN.PY...... B-4

TABLE B-2.1. BACKWARDS.PY...... B-6

TABLE B-3.1. BACKWARDS45.PY...... B-8

TABLE B-4.1. CAPTURE.PY...... B-10

TABLE B-5.1. FORWARD.PY...... B-12

TABLE B-6.1. FORWARD45.PY...... B-14

TABLE B-7.1. INTERFACE.PY...... B-19

B- I TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

TABLE B-8.1. PREVIEW.PY...... B-20

TABLE B-9.1. SIM.PY...... B-23

INDEX OF EQUATIONS EQUATION B-1.1 ...... B-2

EQUATION B-9.1 ...... B-21

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

TFG | Carlos Gómez Gaibar B- II EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

CODE UTILIZED IN THIS PROJECT

The following sections contain the scripting work necessary to control the 28BYJ-48 stepper motor by interacting with the onboard GPIO on the Raspberry Pi.

The scripts have been filled with comment lines that will help the user to have a better understanding of the meaning and specific function of each relevant line of code.

Some scripts have been created with the purpose of serving as foundations for other more elaborated ones. This being so, the reader will find lines of code that are common for many of the scripts presented in this report, since an automatic operation mode is available for the user to choose, as well as several manual control options in the same interface.

Figure B-1.1. Main control interface interactive guide.

B- 1 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

B-1. AUTOSCAN.PY autoscan.py is the result of every single process merged into one automatic scanning operation. It combines clockwise and counter-clockwise movement together with the correct image capture sequence command, all this being fully editable according to the circumstances and needs that every specific project has.

In this script, every step is followed by the next after a certain amount of time, and the camera needs some time to make its own adjustments, focus correctly, capture the pictures and store them.

The camera alone needs 3 seconds to guarantee steadiness and a good focal length acquisition. After that, 5 more seconds are necessary for the camera to take the picture and store it before the rotating beam starts moving, which could spoil the image.

In order to cover a full spin (512 micro-steps), a starting number of 16 iteration packs of 64 micro-steps have been selected, with a spacing of 5 ms in-between. Plus, the counter-clockwise motion has to be included in the form of 512 micro-steps back to home.

512 512 Equation 푡푇푂푇퐴퐿 = ( ) (푛 · (휏 + 푡) + 푡푓 + 푡푝) + 512(τ + t) | ⌈n, ( )⌉ ∈ ℕ 푛 푛 B-1.1

Where:

 n is the number of micro-steps per iteration

 tf [ms] is the time taken by the focus acquisition operation

 tp [ms] is the time taken by the capture and image storage

 t [ms] is the spacing delay between micro-steps

 τ [ms] is the transition time (the time that takes the stepper motor to move from one micro-step to another).

It is important to note the condition that the number of iterations and micro-steps must be natural numbers and related in such way that 512 by the number of micro-steps is equal to the total number of iterations or macro-steps. The reason why is simple: there cannot be decimal values for steps or iterations, and given that the maximum number of micro-steps the motor can deliver is practically 512, there should be such a micro- step grouping that allows the number of iterations to be also a natural number. This forces to choose 1iteration of 512 micro-steps (1 complete spin, as the counter-spin code does), 2x256, 4x128, 8x64, 16x32, 32x16, 64x8, 128x4, 256x2, or 512x1.

TFG | Carlos Gómez Gaibar B- 2 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

#!/usr/bin/python import os #MAKES USE OF "OS" MODULE IN PYTHON import RPi.GPIO as GPIO import time

GPIO.setmode(GPIO.BCM)

enable_pin = 18 coil_A_1_pin = 4 coil_A_2_pin = 17 coil_B_1_pin = 23 coil_B_2_pin = 24

GPIO.setup(enable_pin, GPIO.OUT) GPIO.setup(coil_A_1_pin, GPIO.OUT) GPIO.setup(coil_A_2_pin, GPIO.OUT) GPIO.setup(coil_B_1_pin, GPIO.OUT) GPIO.setup(coil_B_2_pin, GPIO.OUT)

GPIO.output(enable_pin, 1)

def forward(delay, steps): for i in range(0, steps): setStep(1, 0, 1, 0) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(1, 0, 0, 1) time.sleep(delay)

def backwards(delay, steps): for i in range(0, steps): setStep(1, 0, 0, 1) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(1, 0, 1, 0) time.sleep(delay)

def setStep(w1, w2, w3, w4): GPIO.output(coil_A_1_pin, w1) GPIO.output(coil_A_2_pin, w2) GPIO.output(coil_B_1_pin, w3) GPIO.output(coil_B_2_pin, w4)

B- 3 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

os.system("uvcdynctrl -i /media/pendrive/cloudberrypi/GRADO/TFG/CONFIGS/logitech.xml")

for i in range(1, 16): #THESE ARE THE ITERATIONS print "Scan in process, press Ctrl+C to cancel" print "Starting Focus Acquisition" os.system("uvcdynctrl -s Focus 124")

print "Starting Image Capture" os.system("fswebcam -d /dev/video0 -p YUYV -r 1600x1200 --skip 10 --no-banner --save /root/Desktop/PICS/SCAN/SCAN_'%d%b%Y- %Hh%Mm%Ss'.png") print "Picture taken." #FOR VERBOSE

delay = 5 #(MILLISECONDS) steps = 32 #0.703125deg x 8 = 5,625deg x 64 = 360deg 512 x steps = ITERATIONS (Line53). 512 / 16 = 32 print "Advancing to step ", i #TAKES A STEP FORWARD, CLOCKWISE forward(int(delay) / 1000.0, int(steps)) time.sleep(0.5) #SECONDS

#AND THE LAST PHOTO OF THE SERIES os.system("uvcdynctrl -s Focus 124") print "Starting Image Capture" os.system("fswebcam -d /dev/video0 -p YUYV -r 1600x1200 --skip 10 - -no-banner --save /root/Desktop/PICS/SCAN/SCAN_'%d%b%Y- %Hh%Mm%Ss'.png")

setStep(0, 0, 0, 0)

for i in range(0, 1): #DOES A COUNTER-SPIN (CCW) IN ORDER TO COMPENSATE CABLE TWISTING delay = 5 #(MILLISECONDS) steps = 512 #ONE FULL CLOCKWISE ROTATION print "Scan complete. Returning to home position..." backwards(int(delay) / 1000.0, int(steps)) time.sleep(0.5) print "Done."

setStep(0, 0, 0, 0) #DE-ENERGIZES COILS A1, A2, B1, B2, SO THE STEPPER DOES NOT OVERHEAT

Table B-1.1. autoscan.py.

TFG | Carlos Gómez Gaibar B- 4 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

B-2. BACKWARDS.PY

The backwards.py script defines what it means for the system to move counter-clockwise and allows to micro-adjust the position of the stepper. The number of steps can be manually changed at any time by editing this Python script file.

import RPi.GPIO as GPIO import time

GPIO.setmode(GPIO.BCM)

enable_pin = 18 coil_A_1_pin = 4 coil_A_2_pin = 17 coil_B_1_pin = 23 coil_B_2_pin = 24

GPIO.setup(enable_pin, GPIO.OUT) GPIO.setup(coil_A_1_pin, GPIO.OUT) GPIO.setup(coil_A_2_pin, GPIO.OUT) GPIO.setup(coil_B_1_pin, GPIO.OUT) GPIO.setup(coil_B_2_pin, GPIO.OUT)

GPIO.output(enable_pin, 1)

def forward(delay, steps): for i in range(0, steps): setStep(1, 0, 1, 0) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(1, 0, 0, 1) time.sleep(delay)

def backwards(delay, steps): for i in range(0, steps): setStep(1, 0, 0, 1) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(1, 0, 1, 0) time.sleep(delay)

def setStep(w1, w2, w3, w4): GPIO.output(coil_A_1_pin, w1) GPIO.output(coil_A_2_pin, w2) GPIO.output(coil_B_1_pin, w3) GPIO.output(coil_B_2_pin, w4)

B- 5 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

for i in range(0, 1):

delay = 10 steps = 8 print "Advancing to step ", i backwards(int(delay) / 1000.0, int(steps)) setStep(0, 0, 0, 0)

setStep(0, 0, 0, 0)

Table B-2.1. backwards.py.

TFG | Carlos Gómez Gaibar B- 6 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

B-3. BACKWARDS45.PY

This script does the same as backwards.py, but in this case it advances 45 degrees counter-clockwise by moving at a pace of 64 micro-steps for one single iteration, every time the button is clicked.

import RPi.GPIO as GPIO import time

GPIO.setmode(GPIO.BCM)

enable_pin = 18 coil_A_1_pin = 4 coil_A_2_pin = 17 coil_B_1_pin = 23 coil_B_2_pin = 24

GPIO.setup(enable_pin, GPIO.OUT) GPIO.setup(coil_A_1_pin, GPIO.OUT) GPIO.setup(coil_A_2_pin, GPIO.OUT) GPIO.setup(coil_B_1_pin, GPIO.OUT) GPIO.setup(coil_B_2_pin, GPIO.OUT)

GPIO.output(enable_pin, 1)

def forward(delay, steps): for i in range(0, steps): setStep(1, 0, 1, 0) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(1, 0, 0, 1) time.sleep(delay)

def backwards(delay, steps): for i in range(0, steps): setStep(1, 0, 0, 1) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(1, 0, 1, 0) time.sleep(delay)

def setStep(w1, w2, w3, w4): GPIO.output(coil_A_1_pin, w1) GPIO.output(coil_A_2_pin, w2) GPIO.output(coil_B_1_pin, w3) GPIO.output(coil_B_2_pin, w4)

B- 7 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

for i in range(0, 1): delay = 10 steps = 64 #THIS MOVES THE BEAM 45 DEGREES 360/512 X 64 MICRO STEPS = 45 DEGREES print "Advancing to step ", i backwards(int(delay) / 1000.0, int(steps)) setStep(0, 0, 0, 0)

setStep(0, 0, 0, 0)

Table B-3.1. backwards45.py.

TFG | Carlos Gómez Gaibar B- 8 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

B-4. CAPTURE.PY

This script shows clearly how to capture one single frame by using a system call and two software packages: uvcdynctrl and fswebcam.

The package uvcdynctrl is used in order to acquire a suitable focal point for the camera to take the picture. In order for the Focus dynamic control to show, a specific XML configuration file (included in this project) for this webcam, named logitech.xml, must be installed by typing the following: uvcdynctrl –I logitech.xml

The following command will set the camera focus: uvcdynctrl -s Focus 124

This tells uvcdynctrl to execute and set the focal point to 124 mm, measure that has been beforehand tested and validated as optimal for the characteristics and dimensions of the device.

The second package, fswebcam, is the software that will take the image capture according to certain parameters and will store it on a specific given path: fswebcam -d /dev/video0 -p YUYV -r 1600x1200 --skip 10 --no-banner -- save /root/Desktop/PICS/SCAN/SCAN_'%d%b%Y-%Hh%Mm%Ss'.png

Sets the device to the webcam path (/dev/video0)

Establishes a capture color mode (YUYV)

Sets the image resolution to 1600x1200 pixels (the maximum resolution for this camera)

Skips the 10 first frames in order to obtain a steady image

Disables banners such as date of capture or name to avoid pixels drawn on the image

Saves the output images into the SCAN folder, located as a subfolder of PICS, on the root desktop, and adds the current date and time to the file name. The file will then have a name that obeys this structure:

SCAN_ddmmyyyy-hhmmss.png

As an example, SCAN_13052017-183426.png for an image taken on May 13th 2017, at 18:34:26 h.

#!/usr/bin/python

B- 9 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

import os #MAKES USE OF OS MODULE IN PYTHON import time #WILL USE TIME AS WELL

print "Scan in process, press Ctrl+C to cancel" os.system("uvcdynctrl -i /media/pendrive/cloudberrypi/GRADO/TFG/CONFIGS/logitech.xml") print "Acquiring focus..." os.system("uvcdynctrl -s Focus 124") print "Done." print "Starting image capture" os.system("fswebcam -d /dev/video0 -p YUYV -r 1600x1200 --skip 10 - -no-banner --save /root/Desktop/PICS/SCAN/SCAN_'%d%b%Y- %Hh%Mm%Ss'.png") print "Scan Completed." #STRING PRINTING TEST

Table B-4.1. capture.py.

TFG | Carlos Gómez Gaibar B- 10 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

B-5. FORWARD.PY

The Forward script defines what it means for the system to move clockwise and allows to micro-adjust the position of the stepper. The number of steps can be manually changed at any time by editing this Python script file.

import RPi.GPIO as GPIO import time

GPIO.setmode(GPIO.BCM)

enable_pin = 18 coil_A_1_pin = 4 coil_A_2_pin = 17 coil_B_1_pin = 23 coil_B_2_pin = 24

GPIO.setup(enable_pin, GPIO.OUT) GPIO.setup(coil_A_1_pin, GPIO.OUT) GPIO.setup(coil_A_2_pin, GPIO.OUT) GPIO.setup(coil_B_1_pin, GPIO.OUT) GPIO.setup(coil_B_2_pin, GPIO.OUT)

GPIO.output(enable_pin, 1)

def forward(delay, steps): for i in range(0, steps): setStep(1, 0, 1, 0) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(1, 0, 0, 1) time.sleep(delay)

def backwards(delay, steps): for i in range(0, steps): setStep(1, 0, 0, 1) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(1, 0, 1, 0) time.sleep(delay)

def setStep(w1, w2, w3, w4): GPIO.output(coil_A_1_pin, w1) GPIO.output(coil_A_2_pin, w2) GPIO.output(coil_B_1_pin, w3) GPIO.output(coil_B_2_pin, w4)

B- 11 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

for i in range(0, 1):

delay = 10 steps = 8 print "Advancing to step ", i forward(int(delay) / 1000.0, int(steps)) setStep(0, 0, 0, 0)

setStep(0, 0, 0, 0)

Table B-5.1. forward.py.

TFG | Carlos Gómez Gaibar B- 12 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

B-6. FORWARD45.PY

This script does the same as forward.py, but in this case it advances 45 degrees clockwise by moving at a pace of 64 micro-steps for one single iteration, every time the button is clicked.

import RPi.GPIO as GPIO import time

GPIO.setmode(GPIO.BCM)

enable_pin = 18 coil_A_1_pin = 4 coil_A_2_pin = 17 coil_B_1_pin = 23 coil_B_2_pin = 24

GPIO.setup(enable_pin, GPIO.OUT) GPIO.setup(coil_A_1_pin, GPIO.OUT) GPIO.setup(coil_A_2_pin, GPIO.OUT) GPIO.setup(coil_B_1_pin, GPIO.OUT) GPIO.setup(coil_B_2_pin, GPIO.OUT)

GPIO.output(enable_pin, 1)

def forward(delay, steps): for i in range(0, steps): setStep(1, 0, 1, 0) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(1, 0, 0, 1) time.sleep(delay)

def backwards(delay, steps): for i in range(0, steps): setStep(1, 0, 0, 1) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(1, 0, 1, 0) time.sleep(delay)

def setStep(w1, w2, w3, w4): GPIO.output(coil_A_1_pin, w1) GPIO.output(coil_A_2_pin, w2) GPIO.output(coil_B_1_pin, w3) GPIO.output(coil_B_2_pin, w4)

B- 13 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

for i in range(0, 1): delay = 10 steps = 64 #THIS MOVES THE BEAM 45 DEGREES 360/512 X 64 MICRO STEPS = 45 DEGREES print "Advancing to step ", i forward(int(delay) / 1000.0, int(steps)) setStep(0, 0, 0, 0)

setStep(0, 0, 0, 0)

Table B-6.1. forward45.py.

TFG | Carlos Gómez Gaibar B- 14 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

B-7. INTERFACE.PY

This script creates the entire user interface thanks to the Tkinter add-on in Python. The first thing it does is to import the necessary modules into Python and then import, on a system level, the logitech.xml camera control set into uvcdynctrl to ensure that the Focus control is enabled and is going to be shown in guvcview or any webcam preview software available.

Right after this, the different variables that will call the scripts are defined. These variables will make a system command call via the os module, previously imported.

Once the variables are defined, the next step is to create the buttons, assign sizes, colors and positions in the grid, and relate them to a certain action to do when they are clicked.

from gi.repository import Gtk from Tkinter import * import os

os.system("uvcdynctrl -i /media/pendrive/cloudberrypi/GRADO/TFG/CONFIGS/logitech.xml")

def scan(event): os.system("python /media/pendrive/cloudberrypi/GRADO/TFG/SCRIPTS/autoscan.py &")

def capture(event): os.system("python /media/pendrive/cloudberrypi/GRADO/TFG/SCRIPTS/capture.py &")

def fwd(event): os.system("python /media/pendrive/cloudberrypi/GRADO/TFG/SCRIPTS/forward.py &")

def bwd(event): os.system("python /media/pendrive/cloudberrypi/GRADO/TFG/SCRIPTS/backwards.py &")

def sim(event): os.system("python /media/pendrive/cloudberrypi/GRADO/TFG/SCRIPTS/sim.py &")

def poweroff(event): os.system("poweroff")

def reboot(event): os.system("reboot")

def fwd45(event): os.system("python /media/pendrive/cloudberrypi/GRADO/TFG/SCRIPTS/forward45.py &")

def bwd45(event):

B- 15 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

os.system("python /media/pendrive/cloudberrypi/GRADO/TFG/SCRIPTS/backwards45.py &")

def folder(event): os.system("pcmanfm /root/Desktop/PICS/SCAN &")

def preview(event): os.system("python /media/pendrive/cloudberrypi/GRADO/TFG/SCRIPTS/preview.py &")

root = Tk() root.configure(background="#151515") root.grid()

frame = Frame(root) frame.pack(expand = True) frame.configure(background="#151515")

bottomframe = Frame(root) bottomframe.pack(side = BOTTOM)

button_1 = Button(frame, text="Automatic scan", borderwidth=1, fg="#eee", bg="#262666", activeforeground="white", activebackground="#559", disabledforeground="#ccc", highlightbackground="#ccccff", height=6, width=15) button_1.grid(row=1, column=2) button_1.bind("", scan)

button_2 = Button(frame, text="CW micro-adj", borderwidth=1, fg="#eee", bg="#464646", activeforeground="white", activebackground="#666", disabledforeground="#ccc", highlightthickness=0, highlightbackground="#cccccc", height=4, width=15) button_2.grid(row=2, column=1) button_2.bind("", bwd)

button_3 = Button(frame, text="Manual capture", borderwidth=1,

TFG | Carlos Gómez Gaibar B- 16 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

fg="#eee", bg="#262626", activeforeground="white", activebackground="#555", disabledforeground="#ccc", highlightbackground="#ccccff", height=4, width=15) button_3.grid(row=2, column=2) button_3.bind("", capture)

button_4 = Button(frame, text="CCW micro-adj", borderwidth=1, fg="#eee", bg="#464646", activeforeground="white", activebackground="#666", disabledforeground="#ccc", highlightbackground="#cccccc", height=4, width=15) button_4.grid(row=2, column=3) button_4.bind("", fwd)

button_5 = Button(frame, text="Rotate 45deg CW", borderwidth=1, fg="#eee", bg="#464646", activeforeground="white", activebackground="#666", disabledforeground="#ccc", highlightthickness=0, highlightbackground="#cccccc", height=4, width=15) button_5.grid(row=3, column=1) button_5.bind("", bwd45)

button_6 = Button(frame, text="Motion simulation", borderwidth=1, fg="#eee", bg="#464626", activeforeground="white", activebackground="#775", disabledforeground="#ccc", highlightbackground="#ccccff", height=4, width=15) button_6.grid(row=3, column=2) button_6.bind("", sim)

B- 17 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

button_7 = Button(frame, text="Rotate 45deg CCW", borderwidth=1, fg="#eee", bg="#464646", activeforeground="white", activebackground="#666", disabledforeground="#ccc", highlightbackground="#cccccc", height=4, width=15) button_7.grid(row=3, column=3) button_7.bind("", fwd45)

button_8 = Button(frame, text="Restart system", borderwidth=1, fg="#eee", bg="#267726", activeforeground="white", activebackground="#469946", disabledforeground="#ccc", highlightbackground="#ccffcc", height=4, width=10) button_8.grid(row=5, column=1) button_8.bind("", reboot)

button_9 = Button(frame, text="Power off", borderwidth=1, fg="#eee", bg="#cc2626", activeforeground="white", activebackground="#ee4646", disabledforeground="#ccc", highlightbackground="#ffcccc", height=4, width=10) button_9.grid(row=5, column=3) button_9.bind("", poweroff)

button_10 = Button(frame, text="SCAN folder", borderwidth=1, fg="#222", bg="#cccc66", activeforeground="#444", activebackground="#eeee86", disabledforeground="#666", highlightbackground="#eeee88",

TFG | Carlos Gómez Gaibar B- 18 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

height=4, width=10) button_10.grid(row=1, column=3) button_10.bind("", folder)

button_11 = Button(frame, text="Camera Adj", borderwidth=1, fg="#222", bg="#cccc66", activeforeground="#444", activebackground="#eeee86", disabledforeground="#666", highlightbackground="#eeee88", height=4, width=10) button_11.grid(row=1, column=1) button_11.bind("", preview)

#app = App(root) root.mainloop()

Table B-7.1. interface.py.

B- 19 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

B-8. PREVIEW.PY

The preview.py script loads the Logitech.xml webcam settings. Once this is done, it makes an execution call of , a lightweight media player, and then creates a webcam video streaming that will show what the webcam is currently capturing. This is useful to better know how to adjust the camera settings as well as its tilt and yaw.

The next step is to create a set of webcam controls in order to provide the user with advanced exposure, focus, white balance, bright, contrast and saturation values to change according to current lighting conditions or other requirements. With the aim of executing guvcview in the most convenient way possible, a pre-defined settings file called guvcview_settings.gpfl has been created and will be imported beforehand, in order to present an initial balanced picture of the webcam view.

#!/usr/bin/python import os #MAKES USE OF OS MODULE IN PYTHON

print "Generating preview..." os.system("uvcdynctrl -i /media/pendrive/cloudberrypi/GRADO/TFG/CONFIGS/logitech.xml") os.system("mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 5 -ontop &") print "Creating controls..." os.system("guvcview -l /media/pendrive/cloudberrypi/GRADO/TFG/CONFIGS/guvcview_settings.gpf l -o &") print "Done. Press Ctrl+C to exit."

Table B-8.1. preview.py.

TFG | Carlos Gómez Gaibar B- 20 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

B-9. SIM.PY

This motion simulation script has the same function as autoscan.py, except that it presents a much faster movement and excludes the capturing process. This has been created to show the complete range of motion without the need of waiting a determined amount of time required for the webcam to stabilize, get focus, capture the image, rename it and store it onto the corresponding SCAN folder.

In this script, every step is followed by the next after 500 ms, uninterruptedly. In order to cover a full spin (512 micro-steps), 64 iteration packs of 8 micro-steps have been selected, with a spacing of s = 10 ms in between. Plus, the counter-clockwise motion has to be included in the form of 512 micro-steps back to home.

Equation 512 512 t = ( ) (n · (τ + t)) + 512(τ + t)| ⌈n, ( )⌉ ∈ ℕ B-9.1 TOTAL n n

Where:

 n is the number of micro-steps per iteration

 τ [ms] is the transition time (the time that takes the stepper motor to move from one micro-step to another)

 t [ms] is the spacing between micro-steps

It is important to note the condition that the number of iterations and micro-steps must be natural numbers and related in such way that 512 by the number of micro-steps is equal to the total number of iterations or macro-steps.

import RPi.GPIO as GPIO import time

GPIO.setmode(GPIO.BCM)

enable_pin = 18 coil_A_1_pin = 4 coil_A_2_pin = 17 coil_B_1_pin = 23 coil_B_2_pin = 24

GPIO.setup(enable_pin, GPIO.OUT) GPIO.setup(coil_A_1_pin, GPIO.OUT) GPIO.setup(coil_A_2_pin, GPIO.OUT) GPIO.setup(coil_B_1_pin, GPIO.OUT) GPIO.setup(coil_B_2_pin, GPIO.OUT)

B- 21 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

GPIO.output(enable_pin, 1)

def forward(delay, steps): for i in range(0, steps): setStep(1, 0, 1, 0) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(1, 0, 0, 1) time.sleep(delay)

def backwards(delay, steps): for i in range(0, steps): setStep(1, 0, 0, 1) time.sleep(delay) setStep(0, 1, 0, 1) time.sleep(delay) setStep(0, 1, 1, 0) time.sleep(delay) setStep(1, 0, 1, 0) time.sleep(delay)

def setStep(w1, w2, w3, w4): GPIO.output(coil_A_1_pin, w1) GPIO.output(coil_A_2_pin, w2) GPIO.output(coil_B_1_pin, w3) GPIO.output(coil_B_2_pin, w4)

for i in range(1, 64): #CHANGE 64 FOR ANY OTHER VALUE DESIRED.

#PLACEHOLDER FOR WEBCAM IMAGE CAPTURE delay = 10 #THIS IS IN MILLISECONDS steps = 8 #THESE ARE THE MICRO-STEPS PRESENT IN 1 BIG STEP print "Advancing to step ", i forward(int(delay) / 1000.0, int(steps)) time.sleep(0.5) #A SHORT DELAY BETWEEN MOVEMENTS, ONLY FOR DISPLAYING PURPOSES setStep(0, 0, 0, 0)

print "Scan has ended."

for i in range(0, 1): delay = 5 steps = 512 print "Returning to Home position..." backwards(int(delay) / 1000.0, int(steps)) setStep(0, 0, 0, 0) time.sleep(0.5) print "Done."

TFG | Carlos Gómez Gaibar B- 22 EEBE (UPC) | June 2017 Mechanical design of a photogrammetry imaging platform for prototype meshing

setStep(0, 0, 0, 0)

Table B-9.1. sim.py.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

B- 23 TFG | Carlos Gómez Gaibar EEBE (UPC) | June 2017