Full text
Universidade do Minho Escola de Engenharia Simão Pedro Torres Araújo Development of an Integrated ROS Interface for a Time-of-Flight Measurement System of a LiDAR Sensor dezembro de 2021 UMinho | 2021 Simão Araújo Development of an Integrated ROS Interface for a Time-of-Flight Measurement System of a LiDAR Sensor
Simão Pedro Torres Araújo Development of an Integrated ROS Interface for a Time-of-Flight Measurement System of a LiDAR Sensor Dissertação de Mestrado Engenharia Eletrónica Industrial e Computadores Sistemas Embebidos e Computadores Trabalho efetuado sob a orientação do Professor Doutor Jorge Cabral Professor Doutor Rui Machado Universidade do Minho Escola de Engenharia dezembro de 2021
DIREITOS DE AUTOR E CONDIÇÕES DE UTILIZAÇÃO DO TRABALHO POR TERCEIROS Este é um trabalho académico que pode ser utilizado por terceiros desde que respeitadas as regras e boas práticas internacionalmente aceites, no que concerne aos direitos de autor e direitos conexos. Assim, o presente trabalho pode ser utilizado nos termos previstos na licença abaixo indicada. Caso o utilizador necessite de permissão para poder fazer um uso do trabalho em condições não previstas no licenciamento indicado, deverá contactar o autor, através do RepositóriUM da Universidade do Minho. Licença concedida aos utilizadores deste trabalho Atribuição-NãoComercial-SemDerivações CC BY-NC-ND https://creativecommons.org/licenses/by-nc-nd/4.0/ ii
Acknowledgements First, I want to thank Professor Jorge Cabral for supporting my academic development by providing me with the opportunity of being a part of this project and develop this work. Secondly, and of the same importance, to Professor Rui Machado for always guiding me in the development of this dissertation, believing in my capabilities and congratulating my work and effort throughout the several phases. I also want to thank Universidade do Minho and Bosch Portugal for providing the opportunity to work on such relevant topics since their partnership in 2013. They and the Department of Industrial Electronics provided all the conditions necessary for the development of this dissertation. I want to thank my Embedded Systems Research Group colleagues for welcoming me into the team and for all the advice and relevant discussions. To all my fellow academics for the moments and milestones shared in this academic journey. A special thanks to my family, who always trusted my decisions and judgment. This would not be possible without their unconditional support and belief. To Joana, who always brightens up my days and my friends for all the memories. They are my main motivation to pursue my goals in life. This work was supported by the European Structural and Investment Funds in the FEDER component, through the Operational Competitiveness and Internationalization Programme (COMPETE 2020) [Project nº 037902; Funding Reference: POCI-01-0247-FEDER-037902]. Um sincero obrigado a todas as pessoas que, de alguma forma, me motivaram a alcançar os meus objetivos. iii
STATEMENT OF INTEGRITY I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of the University of Minho. iv
Resumo Desenvolvimento de uma Interface ROS Integrada para o Sistema de Medição de Tempo de Voo de um Sensor LiDAR Com a evolução da condução autónoma e o desenvolvimento de tecnologias de automação e recolha de dados, surge a necessidade do mapeamento digital preciso do mundo real. Um sensor LiDAR permite o mapeamento 3D e a medição precisa de distância a obstáculos num cenário de interesse. O número crescente de aplicações que requerem estas funcionalidades e a capacidade do LiDAR em fornecer detecção confiável abrangendo curtas e longas distâncias, mesmo em condições desfavoráveis, torna este sensor numa tecnologia cativante a explorar com fortes oportunidades de mercado. O LiDAR ilumina um cenário recorrendo a luz laser, seguido pela medição do intervalo de tempo até que o pulso de luz refletido seja detectado. Este intervalo de tempo, conhecido como Time-of-Flight, pode ser medido usando Time-to-Digital Converters. O cálculo do ToF é fundamental para a viabilidade do sensor e, por isso, o TDC usado deve ser o mais eficiente possível. Atualmente, o estado da arte em TDCs não apresenta interfaces capazes de simples integração numa aplicação. O foco da maioria dos trabalhos está na arquitetura do TDC, não fornecendo soluções de acesso nem visualização dos dados. Esta dissertação apresenta um TDC baseado num oscilador de código de gray que apresenta um duplo estágio de amostragem para melhorar a resolução e uma interface ROS para aprimorar a portabilidade e a capacidade de reutilização. Além disso, o Robotic Operating System permite ainda a visualização dos dados do sensor LiDAR. A implementação foi efetuada num MPSoC contendo uma FPGA e um processador. O TDC foi implementado na FPGA, e a interface ROS foi, numa fase inicial, desenvolvida no processador. Posteriormente, é realizada uma prova de conceito da migração do ROS para hardware. O TDC apresenta 59 ps de precisão e 69 ps RMS de resolução, permitindo ao sistema distinguir 1 cm em profundidade requerendo apenas 7 LUTs, 20 Flip-flops e 1 mW de potência por canal. O DNL e INL atingem 1.76 LSB e 1.50 LSB pico a pico, respectivamente. A interface ROS em software permitiu, no pior caso, uma nuvem de 36000 pontos ser atualizada a 10.32 FPS. A sua migração para hardware revocou a necessidade do processador permitindo a redução da área em silício e diminuindo o consumo em mais de 84%. A execução do ROS na FPGA resultou ainda num desempenho estável de 3.45 FPS. palavras-chave: Field-programmable Gate Array (FPGA) , Light Detection and Ranging (LiDAR) , Medição de Intervalo de Tempo, Robotic Operating System (ROS) , Time-to-Digital Converter (TDC) v
Abstract Development of an Integrated ROS Interface for a Time-of-Flight Measurement System of a LiDAR Sensor With the evolution of autonomous driving and the development of automation and data collection technologies, the need for accurate real world digital mapping arises. A LiDAR sensor allows 3D mapping and precise measurement of distances to obstacles in a scene of interest. The increasing number of applications requiring accurate real-world mapping solutions, and the ability of LiDAR to provide reliable detection and ranging over short to long distances, even in challenging conditions, makes it a truly compelling technology to explore with strong market opportunities. LiDAR operates by laser lighting the scene, followed by the time interval measurement until the backscattered light is detected. This time interval, known as Time-of-Flight, can be measured using highresolution Time-to-Digital Converters. The Time-of-Flight calculation is critical for the viability of the sensor, and, consequently, the TDC used should be as efficient as possible. Currently, the state-of-the-art on TDCs does not present interfaces capable of simple integration with an application. The focus of most works is on the TDC architecture, failing to provide accessibility and visualization solutions to the data. This dissertation presents a TDC architecture based on a gray code oscillator that introduces a doublesampling stage to improve resolution and an integrated ROS interface to enhance portability and reusability. In addition, the Robotic Operating System allows the visualization of data from the LiDAR sensor. The proposed system was implemented using an MPSoC containing an FPGA and a processor. The TDC architecture was implemented in the FPGA, and the ROS interface is first developed in the processor. Subsequently, a Proof of Concept of the ROS interface migration into hardware is developed. The TDC presents 59 ps single-shot precision and 69 ps RMS resolution enabling the system to distinguish 1 cm in depth while only requiring 7 LUTs, 20 Flip-flops, and 1 mW of power per channel. The peak-to-peak DNL and INL reach 1.76 LSB and 1.50 LSB, respectively. In the worst-case scenario, the software ROS interface allowed a point cloud frame of 36000 points to perform at 10.32 FPS. Its migration to hardware revoked the need for the processor, thus reducing silicon area and decreasing consumption by over 84%. Moreover, executing ROS on the FPGA resulted in a stable performance of 3.45 FPS. keywords: Field-programmable Gate Array (FPGA), Light Detection and Ranging (LiDAR), Robotic Operating System (ROS), Time Interval Measurement, Time-to-Digital Converter (TDC) vi
Contents Resumo v Abstract vi 1 Introduction 18 1.1 Motivation ...................................... 19 1.2 Objectives ...................................... 20 1.3 Methodology ..................................... 21 1.4 DissertationStructure................................. 22 2 State-of-the-Art 23 2.1 Autonomous Vehicles Sensing Systems . . . . . . . . . . . . . . . . . . . . . . . . 23 2.1.1 Light Detection and Ranging – LiDAR . . . . . . . . . . . . . . . . . . . . . 24 2.2 Time-to-Digital Converter - TDC . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.2.1 TDCinFPGA................................. 27 2.3 OperatingSystem-OS ................................ 35 2.3.1 Meta-operating System - Meta-OS . . . . . . . . . . . . . . . . . . . . . . . 36 2.4 Robotic Operation System - ROS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.4.1 ROS2.................................... 38 2.4.2 ROSAlternatives............................... 39 2.4.3 Manipulate and Visualize Information with ROS . . . . . . . . . . . . . . . . 39 2.4.4 ROSinFPGA................................. 41 3 Double-sampling Gray TDC 47 3.1 Design........................................ 47 3.2 Implementation.................................... 52 3.3 TestsandResults................................... 53 3.3.1 Discussion.................................. 58 vii
4 Software ROS Interface 60 4.1 Design........................................ 60 4.2 Implementation.................................... 61 4.2.1 LinuxOSImage ............................... 62 4.2.2 LinuxApplication............................... 66 4.2.3 PublisherROSnode ............................. 72 4.3 TestsandResults................................... 73 4.3.1 Discussion.................................. 76 5 Hardware ROS Interface 77 5.1 Design........................................ 77 5.1.1 ROS Network Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.2 Implementation.................................... 93 5.2.1 ROS Network Adjustments . . . . . . . . . . . . . . . . . . . . . . . . . . 93 5.2.2 WIZ850io Network Module . . . . . . . . . . . . . . . . . . . . . . . . . . 95 5.2.3 ROS PointCloud2 Hardware Publisher . . . . . . . . . . . . . . . . . . . . . 105 5.3 TestsandResults...................................106 5.3.1 Discussion..................................108 6 Conclusion 110 6.1 FutureWork .....................................112 References 114 A Linux Image Configuration 127 B ROS PointCloud2 Message 129 viii
List of Abbreviations AMBA Advanced Microcontroller Bus Architecture. ARP Address Resolution Protocol. ASIC Application-Specific Integrated Circuit. AXI Advanced eXtensible Interface. BRAM Block RAM. BSP Board Support Package. CAGR Compound Annual Growth Rate. CLB Configurable Logic Block. CPU Central Processing Unit. DNL Differential Non-Linearity. DNS Domain Name System. DSL Domain-specific Language. DSP Digital Signal Processing. FIFO First In First Out. FIN Finish. FOV Field of View. FPGA Field-programmable Gate Array. FPS Frames Per Second. FSM Finite State Machine. GPU Graphics Processing Unit. HDL Hardware Description Language. HLS High-level Synthesis. HTTP Hypertext Transfer Protocol. I/O Input/Output. xv
IC Integrated Circuit. ICMP Internet Control Message Protocol. IGMP Internet Group Management Protocol. INL Integral Non-Linearity. IP Internet Protocol. IP Intellectual Property. LiDAR Light Detection and Ranging. LSB Least Significant Bit. LTS Long-term Support. LUT Look-up Table. MAC Media Access Control. MEMS Microelectromechanical Systems. Meta-OS Meta-operating System. MISO Master In Slave Out. MOSI Master Out Slave In. MPSoC Multi-Processor System on Chip. MSB Most Significant Bit. OS Operating System. OTP One-time Programmable. PC Personal Computer. PCL Point Cloud Library. PL Programmable Logic. PLL Phase Lock Loop. PoC Proof of Concept. PPPoE Point-to-Point Protocol over Ethernet. PS Processing System. PVT Process, Voltage and Temperature. Radar Radio Detection and Ranging. RAM Random Access Memory. RBC Reflected Binary Code. xvi
RMS Root Mean Square. ROS Robotic Operating System. RTL Register Transfer Level. RTOS Real-time Operating System. SLAM Self Localization and Mapping. SoC System on Chip. SPI Serial Peripheral Interface. SSH Secure Shell. TCP Transmission Control Protocol. TCP/IP Transmission Control Protocol/Internet Protocol. TDC Time-to-Digital Converter. TDL Tapped Delay Line. ToF Time-of-Flight. UDP User Datagram Protocol. UIO Userspace Input/Output. URI Uniform Resource Identifier. USD United States Dollar. VHDL VHSIC Hardware Description Language. Wi-Fi Wireless Fidelity. WOL Wake-on-LAN. XML eXtensible Markup Language. XML-RPC eXtensible Markup Language-Remote Procedure Call. xvii
Chapter 1: Introduction Autonomous driving solutions are currently being intensively explored largely due to the evolution and development of several crucial technologies. One of the key technologies is the LiDAR sensor, which allows 3D mapping and precise measurement of distances to obstacles in a scene of interest. A LiDAR emits laser light into the surrounding environment and measures the time for the reflected light to return to the sensor. The distance to objects is then calculated using this time interval, known as Time-of-Flight (ToF), and the velocity of light. The Time-of-Flight calculation is critical for the viability of the sensor, and, consequently, high-resolution and efficient Time-to-Digital Converters (TDCs) should be used. Even though different types of LiDAR sensors are being developed, the requirements tend to be similar. According to Druml et al. [1], a LiDAR sensor must have a minimum depth resolution of 20 cm and a measurement range up to 200 m. This demands a TDC capable of measuring time intervals as short as 1.33 ns, with a dynamic range of at least 1.34 µs (this conversion can be calculated with equation 2.1). Furthermore, several types of LiDAR sensors such as FLASH, fixed multi-beam, and MEMS require multiple receivers [1]. Additionally, multiple ToF measurement units per receiver may be used to increase the point cloud refresh rate by using the different measurement units sequentially, thus not having to wait for a pulse in a measurement unit to be measured. Therefore, low resource and power consumption TDC architectures with scalable capabilities are very important for LiDAR sensors. Application-Specific Integrated Circuits (ASICs) are commonly used to implement TDCs since they provide high performance, and no architecture limitations are imposed. However, since LiDAR is still under exhaustive research, frequent design upgrades are part of its development cycle, making programable hardware solutions, such as FPGAs, a valuable prototyping platform. Although ASIC platforms offer better performance than FPGA, the technology gap between these two technologies has been decreasing over the last few years [2]. Moreover, FPGA offers lower development time and faster prototyping, making it a good solution [3]. To improve the usability of the LiDAR system and simplify access to the data, a standard way of interfacing the ToF measurement unit must be given. The Robotic Operating System (ROS) [4] is an opensource framework that offers plug and play capabilities, even between different platforms. Moreover, data can be easily envisioned by using the integrated visualization tool (i.e., RVIZ). Since this tool is used in several systems, including in LiDAR sensors, it will be used in this dissertation as interface for the ToF 18
Chapter 1. Introduction measurement unit. This work is part of a research project exploring a 2D MEMS LiDAR sensor for automotive systems. In this dissertation, the gray code oscillator TDC architecture is optimized, implemented and explored as a solution for implementing the ToF measuring unit. In order to access the data, a ROS interface was developed as a modular accessibility solution to the LiDAR point cloud. 1.1 Motivation The increasing number of industries and applications requiring accurate real-world mapping solutions, and the ability of LiDAR to provide reliable detection and ranging over short to long distances, even in challenging conditions, makes it a truly compelling technology to explore [5]. For example, its use in autonomous driving as one of the key enabler sensors provides strong market opportunities and is the focus of several research works [6]. Due to the fact that a variety of LiDAR sensor types need multiple Time-of-Flight measurement units, Time-to-Digital Converter scalable solutions requiring low resources and low power must be developed. Additionally, since they are required to measure nanosecond or even picosecond time intervals, the precision and resolution of the TDC architecture are also important factors. As a result, and due to the recent emergence of FPGA-based gray code oscillator TDCs, this architecture becomes an interesting research path. Currently, the literature on TDCs lacks an easy to mount interface capable of providing a seamless integration with a visualization application. The focus of most works is on the TDC architecture, failing to provide accessibility solutions. ROS gathers a collection of tools, libraries, and conventions that simplify the development of software components and increase their reusability. This Meta-operating System (Meta-OS) builts on top of an Operating System (OS) and allows different processes (i.e., nodes) to communicate with each other at runtime [7]. It is designed to operate as component-oriented to ease the integration of modules even in different platforms while also providing a data visualization tool. As the TDC will be implemented in an FPGA and since a processor running an Embedded Linux OS is required to execute ROS, System on Chip (SoC) platforms are an ideal solution. These SoC platforms provide Programmable Logic (PL) and Processing System (PS) in the same Integrated Circuit (IC). However, because of the ROS requirement of an Operating System, performance may be inferior when compared to an FPGA-only implementation. Some research works have partially migrated ROS into hardware to avoid this performance degradation. Thus being able to simplify access to data through a hardwired ROS interface 19
1.2. Objectives while maintaining the TDC overall ToF measurement unit performance. Finally, from a technical skill perspective, the proposed research was extremely rewarding due to the large scope of the technologies involved, from sensor-level to application-level development. It also allows development using System on Chips (SoCs) that require knowledge in Embedded Linux and logic description at Register Transfer Level (RTL) with Hardware Description Languages (HDLs). Furthermore, it is an excellent opportunity to work with emerging technologies that are a part of increasingly important applications in a growing market sector. 1.2 Objectives In this dissertation, it is intended to develop an integrated ROS interface for a Time-of-Flight measurement system allowing the visualization of the data collected from a LiDAR sensor. For that, an FPGA-based TDC will be developed to implement the ToF measurement unit. Different ROS interface architectures will be implemented, accessed and compared. Thus, the proposed objectives for this dissertation are: • Study of the literature focusing on TDC architectures to calculate the Time-of-Flight and interfaces with a visualization tool capable of displaying the LiDAR data; • Integration of an Operating System into the Processing System of the Zynq Ultrascale+ MPSoC device; • Embed most of the ROS functionalities into the MPSoC Operating System; • Development of the ROS interface for the TDC peripheral in the MPSoC; • Publish the data acquired by the TDC peripheral, via the ROS interface, into a ROS topic accessible by a Host machine (i.e., PC); • Display LiDAR data in the PC by reading the ROS topic and using the ROS visualization tool (i.e., RVIZ); • Analysis and evaluation of the system performance with the Host and Zynq Ultrascale+ MPSoC board; • Development of a Proof of Concept (PoC) of the ROS interface migration from the Processing System to the Programmable Logic; 20
Chapter 1. Introduction • Publish the data acquired by the TDC peripheral via the hardwired ROS interface, and display it using the ROS visualization tool (Host machine); • Analysis and evaluation of the hardwired ROS interface PoC performance on the Zynq Ultrascale+ MPSoC platform. 1.3 Methodology Although the TDC design was based on the previously published gray code oscillator TDC architectures research, an analysis of the state-of-the-art of the related topics was an essential factor for the implementation of this dissertation since it provides improvements to previously published topics. This work introduces a double-sampling stage to improve the TDC resolution and an integrated ROS interface to enhance portability and reusability. The developed TDC architecture aimed to have portability and scalability so that multiple TDC channels could be implemented by replicating a channel’s placement and routing. At the same time, the performance improvements were managed to be maintained across the different channels, avoiding the need for calibration, further reducing the architecture resource utilization and power consumption. Moreover, the development board was selected, taking into account the improvement expected when using superior FPGA technology (i.e., 16 nm technology available in the Zynq UltraScale+ MPSoC) and considering the requirement of having at least one processor core. Once the board was selected and the TDC was implemented, the hardware file required for the Operating System generation was available. Thus, the Embedded Linux image generation tool was studied and used to implement an Operating System containing ROS and other packages required by the system. After having ROS running on the Operating System of the PS, the software ROS interface for the TDC was developed. In the FPGA, an interface was developed to obtain the data from the TDC peripheral IP, convert the gray code into binary and send the values through AXI to the processor. The ROS interface accessed the AXI memory, converted the values into depth and published the data to any ROS platform. A Host system (i.e., PC) with ROS was used to receive the information and display it with the RVIZ visualization tool. Finally, an in-depth analysis of the ROS asynchronous communications was made in order to design and implement the hardware node. Based on the knowledge gathered and the intended functionalities, the hardware ROS node was implemented with some adjustments. This system required a TCP/IP stack, and the implementation method was chosen based on the central objective of building a hardwired ROS 21
1.4. Dissertation Structure interface, consequently simplifying less essential parts of the system. Similarly to the software ROS interface, a PC with ROS was used to display the LiDAR point cloud using RVIZ. Lastly, a comparison between both ROS implementations was done, highlighting advantages and disadvantages. The operating frequency of the FPGA was adjusted according to the needs of each module. For instance, in the TDC, the 5-bit gray code oscillator was required to cover the period of one clock cycle. However, this clock frequency was not supported by the AXI interface, which led to the use of a different clock source. Moreover, an extra clock was required because of the frequency limitation of the component implementing the TCP/IP stack. As a result of different clock sources being used between the several modules and due to the exchange of data between them, a method to prevent metastability was also developed. 1.4 Dissertation Structure This dissertation is divided into a total of 6 chapters where the development is presented according to the described methodology. The current Chapter presents an introduction and contextualization of the proposed theme, as well as motivation, objectives to be accomplished, and the methodology used. Chapter 2 provides an overview of the topics related to this dissertation and presents a brief state-of- the-art review on Time-to-Digital Converters and FPGA accelerators integrated with ROS interfaces. The developed Time-to-Digital Converter peripheral is explored in Chapter 3. Its design is thoroughly presented, the implementation steps are described, and the tests and results are discussed. In Chapter 4, its is presented the ROS interface design when coupled with the TDC. The process of generating a Linux image and application with ROS is described. Then, the Publisher ROS node flow and interconnection with the TDC are depicted, and the tests and results of the architecture are presented. The Proof of Concept of the ROS interface migration into hardware is presented in Chapter 5. After the design is presented, the ROS network is analyzed in depth so that it can be replicated into the FPGA. Subsequently, some adjustments made to the ROS network are explained, and the steps to implement the Publisher are depicted. Lastly, the tests and results are shown and compared to the software ROS interface. In the last Chapter, conclusions are drawn and future work steps are described with the goal of enhancing the proposed solution. 22
Chapter 2: State-of-the-Art This chapter presents a review and analysis of the current works and technologies related to the dissertation’s topic. Firstly, autonomous vehicle sensing systems are introduced. The LiDAR sensor is analyzed along with the Time-of-Flight (ToF) principle. Time-to-Digital Converters are presented as a method to measure ToF when using FPGAs as a development platform. A brief comparison between FPGA-based TDC architectures is given, along with concepts and tools to design and program FPGAs. Then, a summary of Operating Systems is presented, preceding the review of the ROS Meta-OS. The two ROS versions are compared [8], [9], and a few alternatives are discussed. Additionally, a mechanism to manipulate and visualize information is described alongside suitable data types for LiDAR data. Finally, implementations of ROS in an FPGA are described, from Processing System to Programmable Logic solutions. 2.1 Autonomous Vehicles Sensing Systems Similar to humans, autonomous vehicles need to sense the surrounding environment in order to navigate safely. Humans use senses such as sight, hearing, and touch to move from point A to B. In the same way, vehicles must use a variety of sensors to provide them with reliable information in different weather and light conditions [10]. Proprioceptive sensors, or internal state sensors, measure the internal dynamic state of a system. For instance, gyroscopes are used to measure acceleration and angular velocity. On the contrary, exteroceptive sensors, or external state sensors, gather information from the system’s surroundings. For example, Radar sensors are used to determine the distance and velocity of objects. In addition, sensors can be classified as passive or active depending on their operational principle. Passive sensors, such as cameras, capture physical inputs (e.g., light) from the surroundings to produce information. Whereas active sensors, such as LiDAR, emit energy to the surroundings and measure the environmental response to that energy to produce information [11]. An example of an autonomous vehicle external sensing system is given in Figure 2.1. Each sensor is strategically placed according to its functionality to obtain a 360◦view of the car’s surroundings. Typically, as there are sensors with overlapping functionality, part of the resulting information is redundant. This allows the system to have backup information in case of a sensor failure. Moreover, the system benefits 23
2.1. Autonomous Vehicles Sensing Systems from the strengths of different sensor types and, consequently, attenuates the system’s weaknesses [12]. Figure 2.1: Example autonomous vehicle external sensing system [11] 2.1.1 Light Detection and Ranging – LiDAR Light Detection and Ranging (LiDAR) is an active remote sensing system that detects objects and maps their distances [13]. It works by illuminating a target with an optical pulse and measuring the characteristics of the reflected return signal. The optical pulse width ranges from a few nanoseconds to several microseconds. The measured time between laser beam emission and return, known as Time-of- Flight (ToF), is used to calculate the distance from the source. A LiDAR system can be applied to different platforms. The more suitable type of LiDAR will differ according to the application and its needs. For instance, an airborne LiDAR system may be used to scan vast areas and retain valuable information to be applied in agriculture, military, or civil engineering. On the other hand, a ground-based LiDAR system is more suitable for robotics and autonomous vehicle applications. The two main types of laser beam steering systems are mechanical and solid-state [13]. The mechanical LiDAR has a rotating mechanism in order to provide a wide Field of View but tends to have a prominent structure as a result. The solid-state LiDAR has a fixed structure compromising the system FOV but maintaining a more affordable price. Nevertheless, a 360◦view can be obtained by placing multiple channels and merging their data. Solid-state LiDARs have multiple implementation methods, for instance, Microelectromechanical Systems (MEMS) and Flash LiDAR. 24
Chapter 2. State-of-the-Art Figure 2.7: Gray code oscillator TDC scheme [26] Table 2.1 compares ASIC TDCs with some implementations of the described FPGA TDC architectures. Although ASICs and FPGAs usually serve different purposes because of their distinct assets, this comparison allows for an understanding of the performance achievable with each platform. Generally, TDCs implemented in the superior technology FPGAs are able to meet the performance of TDC ASICs with average technology. While the best resolution achieved in FPGAs is around a picosecond, ASICs have already surpassed this mark, for example, the work by Hussein et al. in a 65 nm ASIC presents a 450 femtosecond resolution [42]. Table 2.1: Comparisson of TDC architectures Parameter ASIC TDC FPGA TDC Architecture [43] [44] Phased Clocks [29] TDL [34] Differential [35] Pulse Shrinking [40] Gray Code Oscillator [41] Resources/ LUTs & FFs 0.08 mm2 0.195 mm2 4361 2433 319 - 7 5939 6258 104 - 10 Power (mW) 18 45 20 821 - - - Dynamic Range (us) 0.13 1.28 37 118 - 0.0115 >524 LSB (ps) 2 15 280 2.45 31 42 380.9 Precision RMS/SSP (ps) 1.44 20 80 3.9 35 56 290 290 DNL (LSB) [−1, 1] [-0.31:0.31] [0.13:0.31] [-1:5.5] [-0.08:0.073] [-0.98:0.5] [-0.38:0.38] INL (LSB) [−1, 1.3] [-0.67:0.67] - 18.8 [-0.09:0.09] [-4.17:3.5] [0.01:0.7] Technology 180 nm 180 nm 28 nm 28 nm 65 nm 90 nm 28 nm 31
2.2. Time-to-Digital Converter - TDC Field Programmable Gate Array - FPGA A Field-programmable Gate Array (FPGA) [45], also referred to as Programmable Logic (PL), is a semiconductor device composed of an array of programmable logic blocks. It is an integrated circuit designed to be configured by a user after manufacturing, hence the term “field-programmable”. FPGAs are truly parallel by nature, as each processing task can be assigned to a dedicated section of the chip and can function autonomously without any influence from other logic blocks. This is a different reality when compared to processors, as they execute one instruction at a time [46]. There are three types of FPGAs based on three different technologies: antifuse, flash, and SRAM. The antifuse technology provides One-time Programmable (OTP) cells, resulting in a limited number of applications like space and security applications. The advantage is that the routing delays and power consumption tend to be lower. On the contrary, flash technology cells can be reprogrammed as required. Moreover, they are tolerant to radiation, making them suitable for space application, and as antifuse cells, they are nonvolatile, with small routing delays and lower power consumption. Finally, SRAM cells are also reprogrammable but, of the three, it is the only volatile technology, meaning that the configuration is stored in external memory and loaded during the power-up process. The routing delays are more significant, as well as less power efficient. However, SRAM is the most commonly used technology since it uses a standard fabrication process. As a result, the performance and efficiency have been improving over the years. Every FPGA has a limited number of resources available. The base package includes Configurable Logic Blocks (CLBs), programmable interconnects, and I/O blocks. Later, to improve routing resources, switch matrices were introduced [47]. Figure 2.8 presents the FPGA base structure. Figure 2.8: FPGA base structure [48] 32
Chapter 2. State-of-the-Art Through time, different types of resources have been introduced. Nowadays, they also include Block RAMs (BRAMs), Digital Signal Processing (DSP) blocks, Phase Lock Loops (PLLs), clock managers, and multiple peripherals. Configurable Logic Blocks (CLBs), also known as slices or logic cells, are the base element of an FPGA [49]. They are composed of two fundamental components: Look-up Tables (LUTs) and Flip-flops. Moreover, they may also contain function logic blocks such as multiplexers (see Figure 2.9). A 4-input LUT can be configured to implement any 4-input logic function. Some FPGAs can have up to 8-input LUTs, like the Stratix II family introduced by Altera in 2004 [50]. A register can operate either as a latch, which is not recommended as it causes instability, or as a flip-flop. Figure 2.9: Logic block base composition [49] The interconnection resources are responsible for connecting the several CLBs, and the I/O cells are used to bring signals into the chip or export signals from the device. Nowadays, some devices combine processors and FPGAs into a single platform. These devices are divided into Processing System (PS) and Programmable Logic (PL), forming a System on Chip (SoC). Communication between PS and PL is typically realized through high-speed buses like AMBA and AXI. Designing and Programming with FPGAs In order to design systems to be implemented in FPGAs, engineers typically follow the design flow presented in Figure 2.10. An abstraction level named Register Transfer Level (RTL) is used to define the design logic, and it is usually captured using a Hardware Description Language (HDL) such as Verilog or VHDL. After the design definition has been made, its behavioral functionality can be tested in simulation to ensure its correctness. Next, the designs are translated into a gate-level abstraction by synthesis tools, forming a netlist containing the required logic elements and their interconnections. The circuit will constitute elements such 33
2.2. Time-to-Digital Converter - TDC as gates, flip-flops, and multiplexers. However, before converting the HDL, most synthesizers perform a syntax check, followed by an optimization step where the logic is reduced or eliminated when redundant. This process reduces the FPGA resources needed and accelerates the design implementation by having simpler architectures. After synthesis, the functional simulation helps the user verify if the design incorporates the intended features and capabilities. The constraints inserted by the user together with the netlist files are processed into a physical level, where the logic is placed and routed. Despite being the slowest to process, the timing simulation available after implementation is the most complete, providing detailed information such as the routing delay between circuit elements. Finally, the generated configuration file (i.e., bitstream) is used to program the FPGA. Figure 2.10: FPGA design flow [49] Each FPGA vendor has its own set of tools used to design and program FPGAs. Smaller vendors may only offer a customized version of a tool from a specialist vendor. Some of the FPGA vendors also offer High-level Synthesis (HLS) tools. These tools can interpret a higher level of abstraction in C, C++, or OpenCL and convert them into RTL. The two leading manufacturers are Xilinx [51], recently acquired by AMD [52] and Lattice Semiconductor [53]. Xilinx offers a set of advanced tools for each level of abstraction. Vivado Design Suite provides a suitable environment for hardware developers programming at the Register Transfer Level [54]. The Vitis Unified Software Platform is ideal for developers at a higher level of abstraction with HLS tools [55]. Also, it can be used to program the Processing System of a SoC. Vitis AI allows the development of FPGA solutions 34
Chapter 2. State-of-the-Art for artificial intelligence [56]. Furthermore, Xilinx provides PetaLinux Tools to customize, build and deploy Embedded Linux on the Processing System [57]. 2.3 Operating System - OS As previously mentioned, SoC devices integrate FPGAs and processors on the same platform. Combining the high-level management of processors with the real-time data processing of FPGAs forms a powerful embedded computing device. Often, processors are running an Operating System (OS), which is software that interfaces a user with the hardware. It manages the computer hardware and software to provide an environment ready to execute applications [58]. Most of the time, it is running several different computer applications simultaneously, each of them requiring access to the computer Central Processing Unit (CPU), memory, and storage. It is the Operating System’s responsibility to coordinate all available resources, ensuring the correct functionality of each application [59]. Figure 2.11 illustrates an overview of an operating system. Hardware CPU RAM I/O Software Operating System Application Software System Software User 1 User 2 User 3 Figure 2.11: Operating System overview (adapted from [60]) Some of the most important tasks of an Operating System are memory management, application management, device management, file management, and security. The most common general-purpose Operating Systems are Microsoft Windows , macOS , and Linux . For dedicated devices, it is common to use embedded Operating Systems such as Embedded Linux and Real-time Operating System (RTOS). 35
2.4. Robotic Operation System - ROS 2.3.1 Meta-operating System - Meta-OS A Meta-operating System essentially is a middleware software framework that performs many of the functionalities of an Operating System and requires a host OS to run [61]. It can provide an independent layer of communication between threads and processes, hardware abstraction, low-level device control, tools, and libraries to be executed in single or multiple platforms [4]. 2.4 Robotic Operation System - ROS The Robotic Operating System (ROS) [8] is an open-source framework gathering a collection of tools, libraries, and conventions that aims to simplify the development of software components and increase their reusability. This Meta-OS allows for different processes (nodes) to communicate with each other at runtime and includes functionalities such as package management, hardware abstraction, and low-level device control. In runtime, ROS operates as a peer-to-peer loosely coupled network of nodes that can interact through different communication protocols, including synchronous RPC-style communication over services, asynchronous streaming of data over topics, and storage of data on a Parameter Server. These nodes can be grouped into packages, which can be easily shared and distributed over different platforms. The asynchronous communication model of ROS is based on Publish/Subscribe messaging [62], where nodes interact through a topic [63] with other nodes (see Figure 2.12). The operation starts with each node registering to the master and continues with data transmission through a communication channel called topic. A publisher node publishes a message to a topic, and any Subscriber node, previously subscribed to the topic, can receive the message. Thus, the publisher/subscribe model is appropriate to one-way, many-to-many data transport. Since the ROS nodes are bound loosely, a node can be simply added or removed at any time. Figure 2.12: ROS nodes asynchronous communication [64] 36
Chapter 2. State-of-the-Art A ROS message [65] is a data structure containing type fields, for instance, the primitive types: integer, floating-point, boolean, and string. Also, arrays and structures of primitive types are supported. On the other hand, the synchronous communication model of ROS is useful for request/reply interactions. This transaction is done via services, defined by a pair of message structures: one for the request and one for the reply. A node firstly provides a named service, and a client uses the service by sending the request message and awaiting the reply, as depicted in Figure 2.13. Figure 2.13: ROS nodes synchronous communication [66] ROS metrics [67], [68] provides a periodic analysis of the resource utilization by the community. The different evaluated parameters expose the progressive usage by the users, as shown in Figure 2.14. As it can be observed, the usage of the different ROS resources have been steadily increasing over the last decade. Figure 2.14: Number of ROS users over time [69] 37
2.4. Robotic Operation System - ROS 2.4.1 ROS 2 When ROS was initially created some of the most important requirements, such as real-time, safety, certification, and security, were not considered. Moreover, these requirements are some of the most important in the industry, extending potential applications. Applying these features to the existing ROS system would significantly improve it but would probably make it unstable. Thus, to address these concerns, ROS 2 was proposed [9]. With ROS 2, a single executable is now able to have more than one node with intra-process communication. This is useful to reduce resource utilization and to improve communication performance. This functionality was initially called Nodelet but is now named Component. Lifecycled nodes are also introduced. They provide different states: unconfigured, inactive, active, and finalized. A node is initially unconfigured, and when a transition is requested, a predefined callback is triggered inside the node. In the previous version of ROS, before a node was executed, a ROS master was required. This existed, among other purposes, to inform what current nodes and topics were available. In ROS 2, there is no ROS master, being each node capable of discovering other nodes. As described in 2.4, services in ROS 1 were only synchronous. When a client requested information from a server, the execution was interrupted until the response arrived. With ROS 2, there is the possibility of asynchronous services. A trigger is now generated to a callback function instead of a client being interrupted until the server response arrives. A new feature is Quality of Service (QoS). By default, ROS 2 communications work as in ROS 1, that is, a Subscriber node will only receive messages published after subscribing, messages are guaranteed to be delivered, and a queue size for delivered messages waiting to be processed can be configured. With the new version, one can handle communications to improve performance over the loss or queuing of data, and vice versa. The extension of the supported Operating Systems is a significant improvement in the ROS 2 usability, as proven by Figure 2.15. Regardless of the ROS 2 release, a substantial number of downloads can be observed in Windows OS compared to Linux and macOS. Thereby, considering that ROS 1 is only compatible with Linux and OS X, substantial growth can be expected in the number of users of ROS 2 in the upcoming years. 38
Chapter 2. State-of-the-Art Figure 2.15: Number of binary downloads per ROS 2 release, broken down by OS [70] 2.4.2 ROS Alternatives There are several alternatives to ROS such as LCM [10], ZeroMQ [11], YARP [12], and OROCOS [13]. They all belong to the middleware layer and have a similar purpose, that is, to streamline development through libraries or by simplifying inter-process and in-process communication. One of the upsides of ROS is that it has developed an extensive community. Over the years, many libraries and functionalities have been introduced to ROS due to contributors. Even some of the mentioned alternatives support ROS interaction and are designed to be compatible with it. For instance, YARP enables the user to interoperate with ROS topics, services, and parameter servers. As ROS was not initially designed to operate as a real-time system, some lightweight alternatives might be used instead, such as LCM and OROCOS. However, with ROS 2, this problem is mitigated. Furthermore, ZeroMQ might be a good alternative for applications requiring languages such as Java, Ruby, NodeJS, and Perl. 2.4.3 Manipulate and Visualize Information with ROS ROS has a graphical interface named RVIZ that, through plugins, allows the visualization of the data in a ROS topic. Moreover, ROS provides several packages defining messages commonly used with sensors [71]. For instance, the point cloud from a LiDAR sensor can be assembled with the PointCloud2 message type [72]. Figure 2.16 presents an example of a LiDAR point cloud. 39
2.4. Robotic Operation System - ROS Figure 2.16: Example LiDAR point cloud [73] The Point Cloud Library (PCL) [74] is a library included in ROS as a package [75]. Thus, it can be used in nodes for point cloud processing. It offers several state-of-the-art algorithms such as filtering, feature estimation, and segmentation. Combining these tools simplifies the development of applications with ROS, for example, Willbev [76] creates a robot model that is integrated with a LiDAR sensor to always face the selected object, even when the object is moving in the environment. The author uses Gazebo [77] to create the robot model and the simulation environment (Figure 2.17). The simulation environment is integrated with ROS and the Velodyne simulation package is used to include a LiDAR sensor. The point cloud information is saved as a PointCloud2 ROS data type, and it is manipulated with the PCL library in a ROS node. Lastly, RVIZ displays the LiDAR point cloud information. In conclusion, the Robotic Operating System not only enabled the author to easily integrate a simulation environment but also enabled all the processing required and visualization of the system. Figure 2.17: Example Gazebo simulation environment integrated with ROS and displayed with RVIZ [78] 40
Chapter 3: Double-sampling Gray TDC The previously implemented gray code oscillator TDC architectures described in 2.2.1, inspired the double-sampling gray TDC architecture described in this section and also presented in [91]. The gray code oscillator architecture on [26] was based on a Xilinx Kintex-7 board, whereas the work in [41] used a Xilinx Zynq-7000 SoC . This work explores a Xilinx Ultrascale+ MPSoC and improves the gray code oscillator architecture presented in [41]. The following subsections present the TDC design, implementation and results. 3.1 Design A typical binary counter combines a combinational stage where the value is incremented and a sequential stage where the value is stored until the next clock cycle. The sequential stage guarantees a stable value for the next combinational stage calculation. This step is vital in a binary counter as multiple bits may change from one iteration to another, resulting in multiple combinational path changes. As each combinational path is likely to have a different routing delay, the counter might not have the expected incremented value without the sequential stage. On the other hand, in the case of a gray code counter, only a single bit may change from one iteration to another. Thus, it can operate without the sequential stage of a binary counter (although it must be verified that the iteration delay of each single bit is always inferior of the delay of two bits). Therefore, when adopting a gray code schema, the resolution is no longer limited by the clock frequency but by the datapath delay between values. According to Xilinx documentation [92], the Ultrascale architecture has 6-input LUTs. Therefore, in order to implement a combinational function in a single LUT, a maximum 6-bit gray code counter could be used. However, in order to reduce the gray code counter power consumption, an enable signal is introduced to start or stop the counting. Thus, a 5-bit gray code counter, using a Reflected Binary Code (RBC) scheme [93] and 1-bit enable signal was designed, resulting in a maximum of 32 interpolation steps. The block diagram in Figure 3.1 presents the designed TDC architecture. A binary counter with 12 bits, named coarse counter, is used to increase the TDC dynamic range, resulting in a maximum of 4096 steps. The gray code counter is used to implement the start and stop TDC channels, enabling the system 47
3.1. Design to measure time intervals smaller than one clock cycle. The start and stop input stages ensure that the gray counters are not enabled for more than one clock cycle, reducing power consumption. The coarse counter value and both TDC channels are concatenated in the merge block resulting in a 32-bit value saved into a FIFO memory. In the interface block, the different counter values are retrieved from the FIFO and converted into their time representation in picoseconds. An AXI peripheral is then used to send this value into the processor side. New values are only requested if the FIFO is not empty and whenever the AXI-lite interface is ready. Firstly, a start signal has to be sent by the PS along with the conversion factors for calculating the time in picoseconds (i.e., Tand LSB from equation 3.1). With the start signal, a value is drawn from the FIFO, and the time in picoseconds is calculated. The time values are calculated in a pipeline stage designed with 5 clock cycles of latency. When the calculation is finished, a valid signal is enabled, implementing a logic AND gate with the AXI read-ready signal. This mechanism delays an AXI read transaction until the time value is ready and valid. By having a value ready 5 clock cycles after the start signal, the following AXI read transaction will not be delayed as each AXI transaction could take around 50 clock cycles to be completed. VDD SET CLR DQ Q SET CLR DQ Q VDD SET CLR DQ Q hithit Start Input Stage Start Input Stage Stop Input Stage Stop Input Stage nrstnrst Start TDC Channel Start TDC Channel Stop TDC Channel Stop TDC Channel Coarse Counter Coarse Counter clkclk store start store stop InterfaceInterface FPGA 10 bits 10 bits 12 bits FIFOFIFO 32 bits32 bits 32 bits32 bits 32 bits32 bits MergeMerge Figure 3.1: TDC IP block diagram Compared to the one in [26], the main difference of this architecture is the double-sampling stage instead of a single-sampling stage (see Figure 3.2). Moreover, to increase the maximum dynamic range, a coarse counter instead of a bit extension circuit is used. The double-sampling method takes advantage of the routing delay between the combinational and the sequential stage. The second sampling stage is routed with at least double the first sampling stage’s delay, causing a value from the LUTs to take double 48
Chapter 3. Double-sampling Gray TDC the time to arrive at the second stage. Therefore, when a new value ( G ) arrives at the first sampling stage, the second sampling stage will contain the previous gray code value ( G-1 ). Then, after the delay difference, the new value ( G ) arrives at the second sampling stage, meaning that both stages are now with the same value. By adding both stages (after the gray to binary conversion), the first value is 2G-1 and the second value is 2G , resulting in an incremental sequence. This results in a resolution approximately twice as better. D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT I0 I1 I2 I3 I4 I5 O6 LUT bit4bit4 bit3bit3 bit2bit2 bit1bit1 hithit bit0bit0 bit4bit4 bit3bit3 bit2bit2 bit1bit1 hithit bit0bit0 bit4bit4 bit3bit3 bit2bit2 bit1bit1 hithit bit0bit0 bit4bit4 bit3bit3 bit2bit2 bit1bit1 hithit bit0bit0 bit4bit4 bit3bit3 bit2bit2 bit1bit1 hithit bit0bit0 bit4 bit3 bit2 bit1 bit0 clkclk storestore SLICE_XnYm SLICE_X(n+1)Ym SLICE_X(n+2)Ym gray4 stored 1 gray4 stored 2 gray3 stored 1 gray3 stored 2 gray2 stored 1 gray2 stored 2 gray1 stored 1 gray1 stored 2 gray0 stored 1 gray0 stored 2 D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE D SR CE Q FDCE 1st sampling stage 2nd sampling stage Store 1st sampling stage Store 2nd sampling stage Figure 3.2: Double-sampling gray TDC channel schematic 49
3.1. Design The TDC state machine is presented in Figure 3.3. When a rising edge of the hit signal arrives, the Start Input Stage enables the Start TDC Channel to sequence through the gray code counter until the next clock rise edge. In the clock rise edge, the gray code counter is sampled, and if the value is different from zero, the start_store signal is enabled. This signal is used to store the gray code value, store the coarse counter, and reset the Start Input Stage , synchronizing both counting stages and avoiding the risk of metastability. After converting the gray code values to binary, the final measurement value is calculated according to 3.1: fine_time = (start1+start2)−(stop1+stop2) time =coarse ∗T+fine_time ∗LSB 2 (3.1) where start1,start2,stop1,stop2are gray counter values converted to binary (depending on the TDC channel and the sample stage). The fine measurement is given by fine_time multiplied by the TDC resolution (LSB). The coarse value (coarse) is multiplied by the TDC clock period (T) and added with the fine measurement to produce the total time measurement. Idle Measure Merge FIFO Store Count Reset !hit_start hit_start !stop_store stop_store !end_of_conversion end_of_conversion 1 hit !hit && count_reset Idle Gray Code Measure Sample StoreWait hit_start 1 start_store 1 !count_reset count_reset Measure !start_store !hit_start Idle Measure Merge FIFO Store Count Reset !hit_start hit_start !stop_store stop_store !end_of_conversion end_of_conversion 1 hit !hit && count_reset Idle Gray Code Measure Sample Store hit_start 1 start_store 1 Measure !start_store !hit_start Idle Measure Merge FIFO Store Count Reset !hit_start hit_start !stop_store stop_store !end_of_conversion end_of_conversion 1 hit !hit && count_reset Idle Gray Code Measure Sample Store hit_start 1 start_store 1 Measure !start_store !hit_start Figure 3.3: TDC state machine (top) and gray code start channel state machine (bottom) When a falling edge of the hit signal occurs, the operation principle is the same but applied to the stop channel (see Figure 3.4). In this case, the stop_store signal is enabled instead of the start_store , indicating the end of measurement. Next, the values are merged and written to the FIFO memory, and a reset is made to the coarse counter. Additionally, a count reset signal is generated, indicating that the TDC is available for a new measurement. Since the designed architecture is targeting LiDAR applications, to obtain the depth, the measured time interval needs to be divided by 2. The division is done in the FPGA 50
Chapter 3. Double-sampling Gray TDC as it only requires a shift right. The TDC operation principle is described in Figure 3.4. The TDC measures the time the hit signal is in a high state (i.e. active). From the hit signal, two signals are originated: the hit start and the hit stop . The first becomes active at the same time as the hit and is disabled at the next positive edge of the clock. The second becomes active when the hit is disabled and is disabled at the next positive edge of the clock. While either of these two signals is active, the gray code oscillator is counting. The first sampling stage samples the gray code with a smaller routing delay, in this case it samples the value 5 (i.e. 6 in decimal). Because of the bigger routing delay of the second sampling stage, the sampled value can either be the same as the first sampling stage or the previous gray code value, which is the case in this example as the value sampled is 7 (i.e. 5 in decimal). The decimal representation of these values are added, and the same process is used for the stop channel. Then by subtracting the start and stop TDC channels, the gray counter result is 6 , and this value gets multiplied by the TDC resolution. Finally, the coarse counter value is sampled in the first clock cycle that the hit signal is active and stored in the next clock cycle, resulting in the value 2 . Another value is sampled in the first clock cycle that the hit signal becomes inactive and stored in the next clock cycle, resulting in the value 4 . Note that once the coarse counter is started by the hit signal, the counter is incremented in the positive edge of the free running clock and the two sampled values work as timestamp. Therefore, to obtain the time difference, these two values are subtracted originating the value 2 , that is multiplied by the clock period and added to the gray code result to build the final time representation. clk Start sample 1 Start sample 2 Start sample Total 0 Gray counter 1 3 2 6 7 50 hit 4 (5'd7) clk Start 1 Start 2 Start T 1 0 1 1 1 2 1 3 4 5 6 2 2 3 3 2 2 3 0 0 0 Gray counter 1 3 2 6 7 50 hit 6 0 06'd14 clk **start sample 1 **start sample 2 start sample total 0 *start gray counter 1 3 2 6 7 50 hit 0 011 4 5 (6) 7 (5) 4 (5'd7) 4 (5'd7) hit start hit stop 0 0 0 0 **stop sample 1 **stop sample 2 stop sample total 0 *stop gray counter 0 0 05 2 (3) 3 (2) 0 0 0 01 2 63 coarse counter 2 430 1 coarse counter result 02 06gray counter result * - all values in gray code ** - value in gray code (equivalent decimal value) clk **start sample 1 **start sample 2 start sample total 0 *start gray counter 1 3 2 6 7 50 hit 0 011 4 5 (6) 7 (5) hit start hit stop 0 0 0 0 **stop sample 1 **stop sample 2 stop sample total 0 *stop gray counter 0 0 05 2 (3) 3 (2) 0 0 0 01 2 63 coarse counter 2 430 1 coarse counter result 03 06gray counter result * - all values in gray code ** - value in gray code (equivalent decimal value) 5 clk **start sample 1 **start sample 2 start sample total 0 *start gray counter 1 3 2 6 7 50 hit 0 011 4 5 (6) 7 (5) hit start hit stop 0 0 0 0 **stop sample 1 **stop sample 2 stop sample total 0 *stop gray counter 0 0 05 2 (3) 3 (2) 0 0 0 01 2 63 coarse counter 2 430 1 coarse counter result 02 (4-2) 06 (11-5) gray counter result * - all values in gray code ** - value in gray code (equivalent decimal value) Figure 3.4: Double-sampling gray TDC operation principle 51
3.2. Implementation 3.2 Implementation Preliminary tests on the Xilinx Ultrascale+ FPGA platform presented in research work [41] indicated an average datapath step delay between 105-118 ps. An improvement of up to 50% is expected as a result of the double-sampling stage. However, since the architecture requires the double of the flip-flops for a single channel, it is also expected that fewer routing resources will be available, resulting in lower routing uniformity, as less efficient paths need to be used. A system clock of 500 MHz was selected for this implementation. Thus, considering the average 105 ps resolution, the 5-bit gray counter can fully cover one clock cycle. To implement the TDC architecture, the first step, after developing the HDL and synthesizing the design, is to fix the placement of the LUTs and flip-flops of the gray code oscillator previously presented in Figure 3.2. The placement and part of the routing of the gray code oscillator start channel in Vivado is depicted in Figure 3.5. The first slice contains both the LUTs that implement the gray code counter and a sample stage. The second sample stage is located in the second slice, providing the required path delay. Lastly, the store registers are placed in the third slice. The stop channel is equally placed, two rows below, to avoid restringing the other channel’s routing resources. As demonstrated in [41], only 8 of the 24 paths affect the TDC resolution. These nets are used to build the gray code counter sequence, and they will be explored to improve linearity. The design is implemented in Vivado with the Performance_NetDelay_low strategy. Afterward, the gray code counter’s routing delays for both start and stop channels are noted, and the routing paths are saved, together with the Name and BEL Pin of each LUT input. ... Figure 3.5: Double-sampling gray TDC start channel placement and partial routing. Note that the LUTs and Flip-flops from the TDC channel are highlighted in pink, and the routing between them is highlighted in orange. Moreover, as the slice on the right side is originally placed further to the right, and the routing is continuous, the image was concatenated, and the suspension points were introduced, allowing a bigger scaled image. A preliminary performance evaluation was performed for both start and stop channels. The results 52
Chapter 3. Double-sampling Gray TDC showcased a better TDC performance in the start channel. Therefore, the start channel’s routing path was replicated into the stop channel with the set_property FIXED_ROUTE command. Similarly, the Name and BEL Pin of the LUT’s input from the start channel was fixed and replicated into the stop channel with the set_property LOCK_PINS command, preventing implementation variations in consecutive runs. Figure 3.6 presents an excerpt of the commands used in the implementation constraints. Figure 3.6: Double-sampling gray TDC start channel implementation constraints excerpt The manual routing approach proposed in [41] was also explored. Although the Xilinx Ultrascale+ architecture provides more routing options, it is also a more complex architecture. Alongside that, the double-sampling stage proposed in this work, together with the lack of information regarding the FPGA’s routing resources, further increased the complexity of the manual routing process. These turned manual routing into a less viable solution. Therefore, this method was not implemented. Nevertheless, this could be thoroughly explored in a future implementation. The clock frequency for the interface is half the TDC clock frequency (250 MHz), complying with the maximum AXI operating frequency of 333.333 MHz (a critical warning is displayed by Vivado whenever the AXI operating frequency is set to a higher value). Finally, the HDL for the AXI-lite interface is based on the implementation presented in [94]. 3.3 Tests and Results To characterize the implemented TDC, a code density test was performed, being the start and stop signals generated using the Keysight 33600A Series waveform generator. According to the Keysight datasheet 53
3.3. Tests and Results [38], it has a maximum edge jitter of 1 ps corresponding to less than 1.45% of the TDC resolution. Therefore, the test results will not be influenced by the waveform generator. A total of 100 thousand measurements were performed to reduce probabilistic errors. The tests were performed with the board at ambient temperature. A pulse waveform was used with a 30% duty cycle and 0º phase at a frequency of 999173 Hz. This frequency is unrelated to the 500 MHz TDC clock, originating a sliding window effect on the TDC interpolation steps. Figure 3.7 shows the tests setup using the Tektronix AFG1022 waveform generator. Figure 3.7: TDC tests setup Although the routing constraints from the TDC start channel were replicated into the TDC stop channel, the results between channels are not expected to be similar as they are not measuring the same signal. As previously presented in Figure 3.4, the start channel measures the hit start signal and the stop channel the hit stop signal. Even if the two channels were measuring the same signal, the results could be slightly different due to Process, Voltage and Temperature (PVT) variations. Similarly, the first and second sampling stages (indicated as 1 and 2, respectively, in Figures 3.8, 3.9, and 3.10) may capture different values, thus, obtaining different results (like explained in 3.1). The start and stop channel’s code density test performed to extract the delay of each gray code interpolation step is displayed in Figure 3.8 and obtained according to equation 3.2. τi=Ni∗ T NT otal (3.2) where τiis the ith gray code oscillator step delay, Niis the number of times the step i was sampled, T is the TDC clock period, and NT otal is the total number of samples. The start total channel presents a minimum bin size of 3.32 ps and a maximum of 124.78 ps. For the stop total channel, the minimum bin 54
Chapter 3. Double-sampling Gray TDC size is 7.1 ps, while the maximum reaches 175.04 ps. As the system clock period is 2000 ps (i.e. clock frequency of 500 MHz) and there are 29 different bin cells, the TDC mean resolution is around 69 ps RMS. 121.46 ps 1.76 LSB 1.50 LSB 121.46 ps 1.76 LSB 1.50 LSB 167.94 ps 2.44 LSB 1.67 LSB 167.94 ps 2.44 LSB 1.67 LSB 121.46 ps 167.94 ps 1.76 LSB 2.44 LSB 1.76 LSB 2.44 LSB 1.50 LSB 1.67 LSB 1.76 LSB 2.44 LSB 1.50 LSB 1.67 LSB 121.46 ps 167.94 ps Figure 3.8: TDC start and stop channel’s code density test. The 1 , 2 , and Total correspond to the first sampling stage, second sampling stage, and both sampling stages combined, respectively. The code density test results were used to calculate the non-linearities depicted in Figures 3.9 and 3.10. The Differential Non-Linearity (DNL) and the Integral Non-Linearity (INL) are calculated according to 3.3 and 3.4, respectively (normalized to one LSB). DNLi=τi−τ(3.3) INLi= n ∑ i=0 DNLi(3.4) 55
3.3. Tests and Results where DNLiis the DNL of step i and τis the average step size. INLnis the addition of the DNL values until step n. The start channel presents a DNL ranging from -0.95 to 0.81 and an INL ranging from -1.01 to 0.49. For the stop channel, the DNL ranges from -0.90 to 1.54, and the INL ranges from -0.45 to 1.22. 121.46 ps 1.76 LSB 1.50 LSB 121.46 ps 1.76 LSB 1.50 LSB 167.94 ps 2.44 LSB 1.67 LSB 167.94 ps 2.44 LSB 1.67 LSB 121.46 ps 167.94 ps 1.76 LSB 2.44 LSB 1.76 LSB 2.44 LSB 1.50 LSB 1.67 LSB 1.76 LSB 2.44 LSB 1.50 LSB 1.67 LSB 121.46 ps 167.94 ps 1.76 LSB 2.44 LSB 1.50 LSB 1.67 LSB Figure 3.9: TDC start and stop channel’s Differential Non-Linearity (DNL). The 1 , 2 , and Total correspond to the first sampling stage, second sampling stage, and both sampling stages combined, respectively. 56
Chapter 4. Software ROS Interface 3$cd .. 4$ petalinux -config 5→ Yocto Settings → User Layers 6→ ${proot}/project -spec/meta -ros/meta -ros-common 7→ ${proot}/project -spec/meta -ros/meta -ros-backports -dunfell 8→ ${proot}/project -spec/meta -ros/meta -ros1 9→ ${proot}/project -spec/meta -ros/meta -ros1 -melodic 10 → Save and exit Code 4.2: Configure the PetaLinux project with the ROS melodic layer In order to add ROS to the Linux OS image root filesystem, the user-rootfsconfig file needs to be edited by inserting, in individual lines, the packages names preceded by “CONFIG_” as depicted in Code 4.3. The complete list of packages added to the user-rootfsconfig file are listed in Appendix A, Code A.1. These packages will then be added into the root filesystem menu entry and accessed with the command petalinux-config -c rootfs . In the “user packages” section of the menu, the packages to be included can be selected. For this image, all packages are selected. Moreover, other packages with network functionalities were added, such as iproute2 and net-tools , in order to establish Ethernet connections with other platforms. For instance, net-tools will be used to assign an IP address to the board. After that, the project is prebuilt so that the Linux Kernel can be configured. Note that the swap memory should be enabled in the Linux build environment, so that the build process does not fail due to insufficient Random Access Memory. Depending on the included packages, the necessary memory size can vary. For example, when including the PCL library package, 10 GB of swap memory was not enough, but the project was built successfully with 20 GB of space. 1$ sudo nano ./project -spec/meta -user/conf/user -rootfsconfig 2# ------------------------- user -rootfsconfig file ------------------------ 3CONFIG_nano 4... 5CONFIG_rosboost -cfg 6# ------------------------------------------------------------------------- 7→ Save and exit 8$ petalinux -config -c rootfs 9→ user packages 10 → [*] nano 11 ... 12 → [*] rosboost -cfg 13 → Filesystem Packages 63
4.2. Implementation 14 → base 15 → iproute2 → [*] iproute2 16 → netbase → [*] netbase 17 → console 18 → network 19 → ethtool 20 → [*] ethtool 21 → libs 22 → libmali -xlnx 23 → [*] libmali -xlnx 24 → [*] libmali -xlnx -dev 25 → misc 26 → net -tools 27 → [*] net-tools 28 → Save and exit 29 $ petalinux -build Code 4.3: Configure the Linux image root filesystem with ROS In the kernel configuration, the Userspace Input/Output drivers need to be activated with the options depicted in Code 4.4. This will interconnect the AXI-lite registers to the UIO drivers on Linux OS, thus enabling access to the AXI-lite registers from the ROS node into the PS. By using the [*] option instead of the [y] option, the UIO module will automatically be loaded into the kernel on the board boot process. When opting for the [y] option, the UIO module must be manually loaded into the kernel (before using any of the UIO driver functionalities) using the modprobe command. The image boot arguments need to be edited to include the UIO drivers, and the TDC module needs to be declared compatible with them (so that the UIO drivers can be used to access the AXI-lite registers of the TDC interface module). In order for the image to be properly configured, it is essential that the boot arguments predefined by the BSP are maintained and that only the “uio_pdrv_genirq.of_id=generic-uio” is appended. The petalinux-config command can be used to verify them in the Kernel Bootargs setting. The UIO drivers are included by adding the “chosen{...}” item, and the the TDC module becomes compatible with them by adding the “&SAXIL_grayTDC_0{...}” item. The second item should contain the exact FPGA module ID that contains the AXI-lite, in this case, the TDC interface ID is SAXIL_grayTDC_0 . Finally, the project is rebuilt, securing the latest configurations, and assembling the required boot and root filesystem files. 1$ petalinux -config -c kernel 2→ Device Drivers 64
Chapter 4. Software ROS Interface 3→ Userspace I/O drivers 4→ [*] Userspace I/O platform driver with generic IRQ handing 5→ [*] Userspace platform driver with generic irq and dynamic memory 6→ Save and exit 7$ petalinux -config 8→ DTG Settings → Kernel Bootargs 9→ earlycon console=ttyPS0 ,115200 clk_ignore_unused root=/dev/mmcblk1p2 rw rootwait uio_pdrv_genirq.of_id=generic -uio 10 → Save and exit 11 $ sudo nano ./project -spec/meta -user/recipes -bsp/device -tree/files/system - user.dtsi 12 # -------------------------- system -user.dtsi file ------------------------ 13 /include/ "system -conf.dtsi" 14 / { 15 model = "Enclustra MA-XU3 -3EG-2I-D11 SOM"; 16 chosen { 17 bootargs = "earlycon console=ttyPS0 ,115200 clk_ignore_unused root=/dev/ mmcblk1p2 rw rootwait uio_pdrv_genirq.of_id=generic -uio"; 18 stdout -path = "serial0:115200n8"; 19 }; 20 }; 21 22 &SAXIL_grayTDC_0 { 23 compatible = "generic -uio"; 24 }; 25 26 #include "zynqmp_enclustra_common.dtsi" 27 #include "zynqmp_enclustra_mars_eb1.dtsi" 28 #include "zynqmp_enclustra_mars_xu3.dtsi" 29 # ------------------------------------------------------------------------- 30 → Save and exit 31 $ petalinux -build Code 4.4: Configure the Linux image kernel with UIO drivers For deploying the Linux OS image, the petalinux-package command is used so that the BOOT.BIN file is assembled with some of the generated files (i.e., fsbl , u-boot , pmufw , and the FPGA bitstream). The - -force option guarantees that if this file was previously created, it is replaced with an updated version. The commands from lines 3 and 4 of Code 4.5 are only required if a Linux application is going to be assembled 65
4.2. Implementation with Vitis and are used to extract the generated root filesystem. 1$cd images/linux 2$ petalinux -package --boot --fsbl ./zynqmp_fsbl.elf --u-boot ./u-boot.elf --pmufw ./pmufw.elf --fpga ./system.bit --force 3$ petalinux -build --sdk 4$ petalinux -package --sysroot Code 4.5: Assemble the BOOT.BIN file and extract the root filesystem Finally, two partitions were created in a SD card, a BOOT partition in the FAT32 format and a ROOT partition in the EXT4 format. The boot.scr , BOOT.BIN , and image.ub files need to be copied to the BOOT partition, and the rootfs.tar.gz file needs to be extracted into the ROOT partition. 4.2.2 Linux Application The process of creating an application compatible with the developed hardware and Linux image is based on [102] and [103]. Before creating a new application in Vitis , a platform is created to simulate the board environment and allow Vitis to cross-compile the application. The required files generated by PetaLinux are organized into a folder structure, as depicted in Code 4.6. 1$cd <linux -platform -directory > 2$ mkdir -p src/a53/xrt/image 3$ mkdir src/boot 4→ Copy the image.ub, boot.scr and rootfs.tar.gz files from the PetaLinux image/linux project folder to src/a53/xrt/image 5→ Copy the system.bit, bl31.elf, u-boot.elf, zynqmp_fsbl and pmufw.elf files from the Petalinux image/linux project folder to src/boot 6→ Create the linux.bif file and save it to src/boot with the following content: 7# ----------------------------- linux.bif file ---------------------------- 8the_ROM_image: 9{ 10 [fsbl_config] a53_x64 11 [bootloader] <linux -platform -directory >/src/boot/zynqmp_fsbl.elf > 12 [pmufw_image] <linux -platform -directory >/src/boot/pmufw.elf > 13 [destination_device=pl] <linux -platform -directory >/src/boot/system.bit 14 [destination_cpu=a53 -0, exception_level=el -3, trustzone] <linux -platform - directory >/src/boot/bl31.elf 15 [destination_cpu=a53-0, exception_level=el-2] <linux -platform -directory >/ src/boot/u-boot.elf 66
Chapter 4. Software ROS Interface 16 } 17 # ------------------------------------------------------------------------- Code 4.6: Preparing the required platform files generated by PetaLinux With the folder structure completed, Vitis can be launched to create the platform project as demonstrated in Figure 4.3. The required xsa file is the same previously used in the PetaLinux project configuration (i.e., TDC hardware file generated by Vivado , mentioned in Code 4.1 line 4). Next, linux needs to be selected as the Operating System and Generate boot components is deselect as the boot components were already generated with PetaLinux . Figure 4.3: Create a Vitis platform To complete the configuration of the platform project, the remaining details are fulfilled with the PetaLinux files previously prepared in the folder, along with the extracted root filesystem stored in the images/linux directory of the PetaLinux project. The platform configuration is depicted in Figure 4.4. 67
4.2. Implementation Figure 4.4: Configure the Vitis platform Finally, the Vitis platform is built as presented in Figure 4.5. After the build, the platform is stored in <platform-project-name>/export (in this case, the platform project name is platLinux_grayTDC_ROSnode ). Figure 4.5: Build the Vitis platform project After these steps, the application project can be created as indicated in Figure 4.6. The platform created is selected and the application settings such as Sysroot path , Root FS , and Kernel Image are automatically imported from the selected platform. In Figure 4.7, the Empty Application (C++) template is selected as a custom ROS node will be designed. Next, a new C++ file is added, and the application code 68
Chapter 4. Software ROS Interface is inserted (the ROS node implementation is explored in section 4.2.3). Figure 4.6: Create the Vitis application Figure 4.7: Add a file to the Vitis application 69
4.2. Implementation The developed application requires some functionalities that are provided by packages included in the generated Linux image. Thus, the include paths field needs to be edited to incorporate them. Code 4.7 presents the include paths required, and Figure 4.8 shows how to add them. 1"${workspace_loc:/platLinux_DoubleSamplingGrayTDC_ROS_UIO/export/ platLinux_DoubleSamplingGrayTDC_ROS_UIO/sw/ platLinux_DoubleSamplingGrayTDC_ROS_UIO/linux_domain/sysroot/aarch64 - xilinx -linux/opt/ros/melodic/include}" 2"${workspace_loc:/platLinux_DoubleSamplingGrayTDC_ROS_UIO/export/ platLinux_DoubleSamplingGrayTDC_ROS_UIO/sw/ platLinux_DoubleSamplingGrayTDC_ROS_UIO/linux_domain/sysroot/aarch64 - xilinx -linux/usr/include/eigen3}" 3"${workspace_loc:/platLinux_DoubleSamplingGrayTDC_ROS_UIO/export/ platLinux_DoubleSamplingGrayTDC_ROS_UIO/sw/ platLinux_DoubleSamplingGrayTDC_ROS_UIO/linux_domain/sysroot/aarch64 - xilinx -linux/usr/include/pcl -1.8}" 4"${workspace_loc:/platLinux_DoubleSamplingGrayTDC_ROS_UIO/export/ platLinux_DoubleSamplingGrayTDC_ROS_UIO/sw/ platLinux_DoubleSamplingGrayTDC_ROS_UIO/linux_domain/sysroot/aarch64 - xilinx -linux/opt/ros/melodic/lib}" Code 4.7: Include paths required by the developed application Figure 4.8: Configure the Vitis application include paths Similarly, the required application libraries need to be included along with their paths. Code 4.8 displays the libraries added and their path, and Figure 4.9 demonstrates the procedure to include them. Finally, the application project can be built. 70
Chapter 4. Software ROS Interface 1→ Libraries: 2pthread 3actionlib 4bondcpp 5class_loader 6cpp_common 7cv_bridge 8dynamic_reconfigure_config_init_mutex 9eigen_conversions 10 message_filters 11 nodeletlib 12 pcl_ros_features 13 pcl_ros_filter 14 pcl_ros_filters 15 pcl_ros_io 16 pcl_ros_segmentation 17 pcl_ros_surface 18 pcl_ros_tf 19 rosbag_default_encryption_plugins 20 rosbag 21 rosbag_storage 22 rosconsole_backend_interface 23 rosconsole_bridge 24 rosconsole_log4cxx 25 rosconsole 26 roscpp_serialization 27 roscpp 28 roslib 29 roslz4 30 rospack 31 rostime 32 tf2_ros 33 tf2 34 tf 35 topic_tools 36 xmlrpcpp 37 38 → Library search path: 39 "${workspace_loc:/platLinux_DoubleSamplingGrayTDC_ROS_UIO/export/ 71
4.2. Implementation platLinux_DoubleSamplingGrayTDC_ROS_UIO/sw/ platLinux_DoubleSamplingGrayTDC_ROS_UIO/linux_domain/sysroot/aarch64 - xilinx -linux/opt/ros/melodic/lib}" Code 4.8: Libraries required by the developed application and their path Figure 4.9: Configure the Vitis application libraries and their paths 4.2.3 Publisher ROS node The ROS node is responsible for creating a ROS publisher that publishes a PointCloud2 to a topic. For manipulating the ROS PointCloud2 message type, the Point Cloud Library (PCL) [104] is used. The node starts by configuring the PointCloud2 with X, Y, and Z coordinates for a frame with 360 columns by 100 rows. In a thread, a UIO device file is opened to allow access to the AXI-lite registers in the Linux User Space. The start signal, T, and LSB are simultaneously sent through an AXI write transaction to the TDC interface. Lastly, the thread enters an infinite loop where an AXI read transaction obtains the time value in picoseconds and converts it to distance according to equation 4.1. The calculation result is assigned to the Z coordinate of the point cloud. The frame rows and columns are assigned to the X and Y coordinates. The complete PointCloud2 frame is published to a ROS topic, and the process is repeated. Figure 4.10 presents the publisher flowchart. distance =time ∗speed_of_light (4.1) 72
Chapter 5. Hardware ROS Interface “soc” and port number “1234”, and the Subscriber indicates that it is subscribing to a topic named “soc”. At this point, the Master notices that a “soc” topic has already been advertised. Thus it responds to the Subscriber with the topic hostname “soc” and port number “1234”. Now, the Subscriber sends a connection request to the Publisher (using the hostname and port number received) and negotiates the data transport protocol (i.e., TCPROS or UDPROS). The Publisher responds with the information for the selected transport protocol (i.e., TCP server with hostname “soc” and port number “5678”). Finally, the Subscriber connects to the Publisher using the selected TCP protocol, a connection header is exchanged between them, and then data is continuously sent by the Publisher node and received by the Subscriber node. ROS Master Subscriber Node connect(“lidar_pcl2”, TCP) TCP server: soc:5678 connect(soc:5678) PointCloud2 data messages Publisher Node XML/RPC - soc:1234 TCP data - soc:5678 Figure 5.2: Establishing a topic connection between ROS nodes (adapted from [107]) XmlRpc++ XmlRpc++ is an implementation of the XML-RPC protocol using the C++ programming language, which is heavily modified from the package on SourceForge [108] so that it can support roscpp’s threading model [87]. Therefore, ROS has its own source code (available in [109]). According to [107], this protocol was primarily chosen because it is relatively lightweight, does not require a stateful connection1, and has wide availability in a variety of programming languages. The XML-RPC protocol is a remote procedure call protocol that uses XML to encode its calls and HTTP as a transport mechanism [111]. When a client wants to communicate with a server through XML-RPC, it uses the HTTP request POST method. On the server side, after the request has been received, the XML content is analyzed, and an XML response is generated and sent as an HTTP response. XML-RPC 1Keeping state or being stateful means that some device is keeping track of another device or a connection, either temporarily or over a long period of time [110]. 79
5.1. Design supports several data types for the transfer of its parameters, such as int or i4, string, array, double, and boolean. A simple client-server communication example is given in Code 5.1 and 5.2. 1<?xml version="1.0"?> 2<methodCall> 3<methodName>statustest</methodName> 4<params> 5<param> 6<value><i4>10</i4></value> 7</param> 8</params> 9</methodCall> Code 5.1: Client HTTP request [112] 1<?xml version="1.0"?> 2<methodResponse> 3<params> 4<param> 5<value><string>Status: OK</string></value> 6</param> 7</params> 8</methodResponse> Code 5.2: Server HTTP response [112] TCPROS In order to transmit data (i.e., ROS messages or services) between nodes, ROS uses a transport layer named TCPROS [88]. Essentially, it consists of standard TCP/IP packets in which the data part contains metadata (i.e., information about the data being transmitted) and the ROS message or service content. When a connection is being established between two nodes, a ROS connection header containing metadata is sent at the beginning of the transaction [113]. After that, each TCPROS packet contains data and a header. The header generally contains information about the size of the transfer, however, depending on the ROS message type, it can also have other relevant information. For instance, the PointCloud2 header contains information such as height, width, and endianness. Code 5.3 provides an example connection header of the string message type, and Code 5.4 the header and the message content. 1 b0 00 00 00 ( message h e a d e r l e n g t h i s 176 b y t e s ) 2 20 00 00 00 ( m e s s a g e _ d e f i n i t i o n f i e l d l e n g t h i s 32 b y t e s ) 80
Chapter 5. Hardware ROS Interface 3 6d 65 73 73 61 67 65 5 f 64 65 66 69 6e 69 74 69 6 f 6e 3d 73 74 72 4 m e s s a g e _ d e f i n i t i o n = s t r 5 69 6e 67 20 64 61 74 61 0a 0a 6 i n g d a t a \n \ n 7 25 00 00 00 ( c a l l e r i d f i e l d l e n g t h i s 37 b y t e s ) 8 63 61 6c 6 c 65 72 69 64 3d 2 f 72 6 f 73 74 6 f 70 69 63 5 f 34 37 36 9 c a l l e r i d = / r o s t o p i c _ 4 7 6 10 37 5 f 31 33 31 36 39 31 32 37 34 31 35 35 37 11 7 _ 1 3 1 6 9 1 2 7 4 1 5 5 7 12 0a 00 00 00 ( l a t c h i n g f i e l d l e n g t h i s 10 b y t e s ) 13 6 c 61 74 63 68 69 6e 67 3d 31 14 l a t c h i n g = 1 15 27 00 00 00 ( md5sum f i e l d l e n g t h i s 39 b y t e s ) 16 6d 64 35 73 75 6d 3d 39 39 32 63 65 38 61 31 36 38 37 63 65 63 38 17 m d 5 s u m = 9 9 2 c e 8 a 1 6 8 7 c e c 8 18 63 38 62 64 38 38 33 65 63 37 33 63 61 34 31 64 31 19 c 8 b d 8 8 3 e c 7 3 c a 4 1 d 1 20 0e 00 00 00 ( t o p i c f i e l d l e n g t h i s 14 b y t e s ) 21 74 6 f 70 69 63 3d 2 f 63 68 61 74 74 65 72 22 t o p i c = / c h a t t e r 23 14 00 00 00 ( message t y p e l e n g t h i s 20 b y t e s ) 24 74 79 70 65 3d 73 74 64 5 f 6d 73 67 73 2 f 53 74 72 69 6e 67 25 t y p e = s t d _ m s g s / S t r i n g Code 5.3: Example string connection header [113] 1 09 00 00 00 ( message body l e n g t h i s 9 b y t e s ) 2 05 00 00 00 ( f i r s t f i e l d o f t h e std _msg s / S t r i n g message i s 5 b y t e s ) 3 68 65 6 c 6c 6 f ( S t r i n g message ) 4 h e l l o Code 5.4: Example string header and message [113] String Publisher/Subscriber Packet Analysis To fully understand the ROS asynchronous communication, a simple Publisher/Subscriber messaging system was constructed (similar to the one presented in [114], but using the NoRosout option to further minimize the system complexity - nodes will not broadcast the rosconsole output to the /rosout topic [115]). The topic message type chosen is the std_msgs::String , as it has a simple implementation and is briefly interpreted in [113]. Wireshark [116] was utilized to analyze the network packets. 81
5.1. Design The first step was to execute the roscore command that initializes the Master along with other essential components and then start the Publisher node. Figure 5.3 shows the packets sent by the Publisher node to the ROS Master in the registration process. A total of 5 HTTP POSTs are transmitted to the Master. The final POST is the one registering the node as a Publisher to the Master (calling the registerPublisher method), whereas the initial 4 POSTs give extra functionalities to the node such as a logger Service [117] and checking Parameter Server existence [118] (with methods such as registerService , and hasParam ). Figure 5.3: Packets from the ROS Publisher registration to the Master The registerPublisher HTTP POST and response are presented in more detail in Figure 5.4. The method parameters are: caller_id , topic , topic_type , and caller_api [117]. Thus, the Publisher ID is “talker” publishing to a “chatter” topic of type “std_msgs/String”, and socket “http://simon-ubuntu:35097”. The Master responds with code “1”, statusMessage “Registered [/talker] as publisher of [/chatter]”, and a list of current subscribers to the “chatter” topic (i.e., empty list as there are no current subscribers). Hence, the Publisher completed a successful registration to the Master. 82
Chapter 5. Hardware ROS Interface Figure 5.4: ROS registerPublisher HTTP POST and response The Subscriber node was subsequently started, as demonstrated by the registration process packets sent to the Master in Figure 5.5. Comparably to the Publisher registration, the last HTTP POST registers the node as a Subscriber (calling the registerSubscriber method), while the remaining 9 POSTs provide extra functionalities with methods such as registerService and hasParam . Figure 5.5: Packets from the ROS Subscriber registration to the Master 83
5.1. Design The registerSubscriber HTTP POST and response are presented in more detail in Figure 5.6. The Subscriber ID is “listener” subscribing to a “chatter” topic of type “std_msgs/String”, and the server socket is “http://simon-ubuntu:39357/”. The Master responds with code “1”, statusMessage “Subscribed to [/chatter]”, and a list of Publishers currently publishing to the “chatter” topic (i.e., the socket from the “talker” Publisher is returned “http://simon-ubuntu:35097/”). Thus, the Subscriber successfully registers to the Master and triggers the subscription process to the “chatter” topic. Figure 5.6: ROS registerSusbcriber HTTP POST and response Soon after, the Subscriber sends an HTTP POST requesting the “chatter” topic and suggesting the TCPROS transport protocol (see Figure 5.7). The Publisher responds with “1” as the operation succeeded and returns the transport protocol to be used along with the IP address and port number (i.e., TCPROS , simon-ubuntu , and 47623 , respectively). Notice that the Subscriber request was sent to the socket previously provided in the HTTP POST response to the registerSubscriber method (i.e., “http://simonubuntu:35097/”, where simon-ubuntu translates to the localhost IP address 127.0.0.1 ). The packets 82 , 84 , and 85 , marked in black in Figure 5.8, correspond to the end of the connection (i.e., Finish (FIN)) between the sockets that negotiated the TCPROS data transmission transport layer. 84
Chapter 5. Hardware ROS Interface Figure 5.7: ROS requestTopic HTTP POST and response Figure 5.8 presents the initial TCPROS packets exchanged between Publisher and Subscriber. Once again, the Subscriber sent a connection request to the socket provided in the transport layer negotiation previously showcased. A connection header, similar to the one depicted in Code 5.3, is forwarded by the Subscriber. The caller id is the Subscriber name “listener”, then follows the message type md5sum , the tcp_nodelay setting as “0”, the topic name “chatter”, and the message type std_msgs/String . Later, the Publisher replies with a response connection header, where the caller id is “talker”, with a latching value “0”, the same md5sum of the message type, a message definition defined as “string data” for the “chatter” topic , and finally, the same std_msgs/String message type . 85
5.1. Design Figure 5.8: TCPROS Connection Header exchange At last, data transmission starts at packet 88, continues in packet 90, and stops when a shutdown event occurs [119] (see Figure 5.9). The time between packets is approximately 1 second as the Publisher was configured to send messages with a frequency of 1 Hz. The data content is identical to Code 5.4, but in this case, there is a value being incremented at every new message. Figure 5.9: TCPROS data transmission Figure 5.10 presents the packets from the termination of both the Subscriber and the Publisher nodes (starting at packet 126 and 144, respectively). Contrary to the registering process, the first HTTP POST captured is responsible for unregistering the nodes from the Master (using the unregisterSubscriber and unregisterPublisher methods). Then, for each node, both Services are unregistered, using the unregisterService method. 86
Chapter 5. Hardware ROS Interface Figure 5.10: Packets from the termination of the Subscriber and Publisher nodes In the registerSubscriber method call presented in Figure 5.6, there was a socket provided that was never used. This is because the Publisher node was published beforehand, and no other Publisher with the same topic emerged after the Subscriber registration. However, this could have happened, and in such cases, that server socket would have been used. Moreover, the Publisher would have needed another client socket to execute the publisherUpdate method call. An example is given in Figure 5.11, note that the server socket port number is not the one provided before, as a different one was generated after the Subscriber was terminated and relaunched. In the HTTP POST, the values sent are “/master” (this value is fixed according to the source code [120]), then the topic name “chatter”, and the Publisher transport layer negotiation socket “http://simon-ubuntu:35943/”. The packets 72 to 74 (marked in black) correspond to the initialization and establishment of a connection between the Subscriber client socket and the Publisher server socket, which will be used to negotiate the transport protocol. 87
5.1. Design Figure 5.11: ROS publisherUpdate method call The analysis uncovered different TCP/IP port types for XmlRpc++ and TCPROS. Table 5.1 describes the required sockets for establishing Publisher/Subscriber communication. A Publisher or Subscriber requires a server and two client TCP/IP sockets of type XmlRpc++. Moreover, a Publisher requires a server TCPROS socket and a Subscriber a TCPROS TCP/IP client socket. As a result, at least four TCP sockets are needed for a ROS Publisher or Subscriber. For a single Publisher, the number of sockets required is given by 3+ S ( S being the number of Subscribers to the Publisher’s topic). The same principle applies to the number of sockets required by a single Subscriber (i.e., 3+ P sockets, where P is the number of Publishers to the Subscriber’s topic). Nonetheless, it is possible to reduce the number of sockets requirement by removing the publisherUpdate method functionality, thus reaching a minimum requirement of 2+ S or 2+ P sockets. 88
Chapter 5. Hardware ROS Interface Identical changes were applied to the hardware Publisher response to the requestTopic method, presented in Figure 5.17. The HTTP Host IP was changed from “localhost” to “192.168.1.10” (i.e., IP from the board running the hardware Publisher). The “simon-ubuntu” name was replaced by the board IP “192.168.1.10”, and an arbitrary port number was selected. Figure 5.17: Hardware Publisher requestTopic response The final required adaptations were made in the PointCloud2 messages. The message header is the same as the one presented in 5.5, but the PointCloud2 z coordinate is now obtained from converting the TDC values into the depth in meters (see section 5.2.3 for more details). 5.2.2 WIZ850io Network Module The WIZ850io module [122] is a compact network module that includes a W5500 chip, a transformer, and an RJ45 Ethernet connector (see Figure 5.18). It is compatible with the previous WIZ820io version since they use the same hardware, only the firmware is different, and it can be updated in the older version. 95
5.2. Implementation The W5500 chip [123] is a hardwired TCP/IP embedded Ethernet controller that can be programmed through Serial Peripheral Interface (SPI), and it can be used to implement the TCP/IP stack, 10/100 Ethernet MAC, and PHY. The TCP/IP stack supports TCP, UDP, IPv4, ICMP, ARP, IGMP, and PPPoE. It is capable of implementing up to 8 distinct sockets simultaneously, and it has power-saving features like Wake-on-LAN and a power-down mode. The module operates as an SPI Slave that must be controlled by a Host SPI Master using the bus interface presented in Figure 5.18. The SPI protocol is a synchronous, full-duplex serial communication bus interface specification [124]. A clock signal is provided by the Master (i.e., SCLK ) to synchronize one or more slaves, and data is serialized bit-by-bit through two data wires (i.e., MOSI to serialize data from the Master to the Slave, and MISO to serialize data from the Slave to the Master). The Master controls the chip select signal (i.e., SCSn ) to inform which Slave device is going to be used. Although this standard is widely adopted in many applications, it is also true that each device usually has particular adaptations that need to be considered. In this case, there is also a reset signal (i.e., RSTn ) and an INTn signal to communicate interruptions from the Slave to the Master. Theoretically, the SPI in the W5500 chip could reach 80 MHz of speed, however, the device only guarantees a stable connection with a maximum frequency of 33.3 MHz. Figure 5.18: WIZ850io network module [122] Two operation modes are available, the Variable Length Data and the Fixed Lenght Data . The former enables more than one SPI Slave device connected to the bus interface. The latter enables only a single SPI device, in which case, the SCSn signal is connected to the ground. Moreover, only 1, 2, or 4 bytes can be transmitted in this mode, and for other data lengths, the Variable Length Data mode needs to be used. In the Variable Length Data mode, the assertion of the SCSn signal indicates the beginning of an N-byte transaction, and the de-assertion indicates its end. The SPI modes 0 and 3 are supported by the W5500 chip, and they only differ in the polarity of SCLK . In either mode, data is latched on the rising edge of the clock (i.e., SCLK signal) and output on the falling 96
Chapter 5. Hardware ROS Interface edge of the clock. Figure 5.19 presents the differences between the SPI modes 0 and 3. Both data signals (i.e., MOSI and MISO ) start transmitting bytes from the Most Significant Bit (MSB) to the Least Significant Bit (LSB). Figure 5.19: SPI mode 0 and 3 operation [125] The W5500 chip can be controlled with SPI Frames transmitted by the Host (Figure 5.20 presents the SPI Frame format). An SPI Frame consists of 3 phases: Address , Control , and Data . In the Address Phase , a 16-bit offset address to access the configuration register or the TX/RX memory needs to be selected. The 8-bit Control Phase specifies the offset block addressed in the Address Phase , the access mode (i.e., read or write operation), and the SPI operation mode (i.e., Variable Length Data or Fixed Length Data ). The blocks available are a common configuration register, a socket configuration register for each socket, and a TX/RX buffer for each socket. Lastly, in the Data Phase , the data is specified with a length of 1, 2, 4, or N bytes, depending on the configuration provided in the SPI operation mode of the Control Phase (“00” selects the Variable Length Data mode; “01”, “10”, “11” select the Fixed Length Data mode with length 1, 2, and 4 bytes, respectively). In the Variable Length Data mode, data length is controlled by the SCSn signal. Whenever the data has more than a byte, the offset address is automatically incremented by 1 every 1 byte of data, allowing a sequential transmission or reception of data. Figure 5.20: SPI Frame format [125] The common register block configures the general properties of the W5500 chip, such as IP and MAC 97
5.2. Implementation address, and the modes (e.g., Wake-on-LAN). Then, each socket has its own register block that defines, among other things, the socket modes (e.g., TCP, UDP), port number, and destination IP and MAC address. The module also has one 16 Kbyte TX memory and one 16 Kbyte RX memory shared among the sockets. Each of the 8 sockets is initially configured with 2 KB of TX memory and 2 KB of RX memory. To change the memory allocation, all the Sn_TXBUF_SIZE and Sn_RXBUF_SIZE registers need to be reconfigured, and their total should not exceed the available 16 Kbyte for each memory. The TX memory is used to store the data that will be transmitted, and the RX memory is used to store all the data received. An example of data transmission and reception is given in the SPI Frame of Figure 5.21. Before sending the address, the SCSn signal is activated and only deactivated after the last byte has been sent or received. In the top example, a write operation to the socket 1 TX buffer ( BSB is 00110) at address 0x0040 is made. The operation mode used is Variable Length Data , and 5 data bytes are sent (0x11, 0x22, 0x33, 0x44, 0x55). In the bottom example, a read operation from the socket 3 RX buffer (BSB is 01111) at address 0x0100 is made. The operation mode used is the same, and 5 data bytes are received (0xAA, 0xBB, 0xCC, 0xDD, 0xEE). 5-Byte Data Write: 5-Byte Data Read: Figure 5.21: Example SPI Frame of a 5-byte data transmission (top), and reception (bottom) (adapted from [125]) 98
Chapter 5. Hardware ROS Interface SPI Master An SPI Master was developed in the FPGA to configure and control the W5500 SPI Slave. The principle of operation of an SPI Master is generally the same, and only a few parameters related to the SPI mode and clock frequency are required. However, the W5500 SPI adaptations introduced two extra signals (i.e., RSTn and INTn ) that need to be considered. For example, according to the W5500 datasheet [125], a 1.5 ms reset should be generated before executing the first transaction (see Figure 5.22). Idle Measure Merge FIFO Store Count Reset !hit_start hit_start !stop_store stop_store !end_of_conversion end_of_conversion 1 hit !hit && count_reset Idle Gray Code Measure Sample Store hit_start 1 start_store 1 Measure !start_store !hit_start Idle RESET PLOCK RESET !rst_start || !resetn rst_start && resetn rst_counter << rst_thresh rst_counter == rst_thresh prst_counter << prst_thresh prst_counter == prst_thresh Idle Address Phase Control Phase Data Phase Inactive !start || !resetn start && resetn !TX_done TX_done !TX_done TX_done inactive_counter > 0 inactive_counter == 0 !TX_done && !RX_done TX_done || RX_done Figure 5.22: SPI Master reset Finite State Machine Figure 5.23 presents the SPI Master Finite State Machine (FSM) implemented in the FPGA to communicate with the WIZ850io module. When a start signal is received and the reset FSM has already been executed, the system moves from the Idle state into the Address Phase , where the SCSn signal is activated, and the address starts to be transmitted. At the last bit of the 16-bit address, the system changes to the Control Phase state where the block select, access mode, and operation mode bits are sent. When the LSB from the operation mode is transmitted, the system changes to the Data Phase where data bytes are received by the MISO signal or transmitted to the MOSI signal. After the data transaction, in the Inactive state, the SCSn signal is deactivated by a minimum of 30 ns (with the help of a counter being decremented), respecting the timing characteristics presented in the datasheet. Then, the system returns to the Idle state until a new start is received. The SPI Master operates in mode 0, and the clock generated by the Master and used to synchronize the Slave runs at a frequency of approximately 30 MHz, slightly under the 33.3 MHz, that according to the module datasheet, ensured a stable connection. 99
5.2. Implementation Idle Measure Merge FIFO Store Count Reset !hit_start hit_start !stop_store stop_store !end_of_conversion end_of_conversion 1 hit !hit && count_reset Idle Gray Code Measure Sample Store hit_start 1 start_store 1 Measure !start_store !hit_start Idle RESET PLOCK RESET !rst_start || !resetn rst_start && resetn rst_counter << rst_thresh rst_counter == rst_thresh prst_counter << prst_thresh prst_counter == prst_thresh Idle Address Phase Control Phase Data Phase Inactive !start || !resetn start && resetn !TX_done TX_done !TX_done TX_done inactive_counter > 0 inactive_counter == 0 !TX_done && !RX_done TX_done || RX_done Figure 5.23: SPI Master Finite State Machine Building the ROS Publisher In order to build the ROS Publisher, a series of configurations need to be made to the WIZ850io module so that it emulates the ROS network previously explored. To execute those configurations, a series of modules that control the SPI Master presented in Figure 5.23 will be used, and after that, only data is transmitted until a stop request arrives. Figure 5.24 presents the WIZ850io controller Finite State Machine. A start signal (when the reset is not active) initiates the common register configurations (in the CR_Config state) of the W5500 chip. Then, as presented in Table 5.1, a minimum of 3 sockets are required when implementing a Publisher without the publisherUpdate feature (one client and two server sockets). The first socket required is a client, which is responsible for starting connections with servers, and that is why a write transaction is executed ( S0_Write state) before they can read the response ( S0_Read state). Conversely, the two server sockets stay in a read state ( S1_Read , and S2_Read states) until a client socket sends a connection request. Afterwards, they reply to the request by writing back to the client socket (in the S1_Write , and S2_Write states). Lastly, the system stays in the S2_Data state, where ROS messages are continuously transmitted until a stop request is received. This system was implemented using 5 modules on top of the SPI Master module. The FSM of Figure 5.24 represents the general WIZ850io controller. Then, there is the module responsible for setting the general configurations of the WIZ850io device (Figure 5.25 presents its Finite State Machine). The remaining 3 modules implement all the socket’s configurations and execute write and read transactions (their FSMs are shown in Figures 5.26, 5.27, and 5.28, respectively). Thus, each socket uses the same module for its configuration, as well as a single module to perform write transactions and another one to perform read transactions. The finished signal becomes active whenever all the states of the running module FSM have been executed (e.g., when the controller is in the CR_Config state, the finished signal will become active 100
Chapter 5. Hardware ROS Interface when all the states on Figure 5.25 have been executed). Idle CR_Config S0_Config S0_Write S0_Read S1_Config S1_Read S1_WriteS2_ConfigS2_ReadS2_Write S2_Data start && resetn finished finished finished finished finished finished finishedfinishedfinished finished finished && stop !finished !finished !finished !finished !finished !finished !finished || !stop !start || !resetn !finished!finished!finished !finished SUBR_WriteGAR_Read GAR_Write SUBR_Read SHAR_Write SHAR_Read SUBR SIPR_Write SIPR_Read start && resetn !start || !resetn !done !done !done !done !done !done !done done done done done && RX == TX done && RX == TX done && RX == TX done && RX == TX SnMR_Write SnMR_Read SnTXBUF_SIZE _Write SnTXBUF_SIZE _Read SnPORT _Write SnPORT _Read SnDIPR0 _Write SnDPORT0 _Write SnCR_Write SnSR_Read start && resetn !start || !resetn done && RX == TX && config_TXSIZE done done && RX == TX done done && RX == TX && socket_client done done done done && RX == INIT done && RX != TX done && RX != TX done && RX != TX done && RX != INIT done && RX != TX done && RX != TX done && RX != TX done && RX != TX done && RX == TX && !config_TXSIZE done && RX == TX && !socket_client Idle SnDIPR0 _Write SnDPORT0 _Write SnCR_Write SnSR_Read SnTXFSR _Read SnTXRD _Read SnTXBUF _Write Wait_PCL2 _Valid SnTXWR _Write SnCRSend _Write SnTXRDSend _Read Idle SnCRListen _Write SnSRListen _Read SnRXRSR _Read SnRXRD _Read SnRXBUF _Read SnRXRD _Write SnCR_Write start && resetn && socket_client !start || !resetn start && resetn && !socket_client done done done !done || (done && RX == INIT) done && RX == ESTABLISHED done && RX != ESTABLISHED && RX != INIT done && RX == prev2_RX !done || (done && RX != prev2_RX) done && pcl2_data && !fifo_valid fifo_valid done && ((pcl2_data && fifo_valid) || !pcl2_data) donedone done done && !sending && pcl2_last_packet done && !sending && !pcl2_last_packet !done !done !done !done !fifo_valid !done!done!done !done || (done && sending) !done !done !done !done !done !done!done!done !done start && resetn && !socket_client !start || !resetn !done start && resetn && socket_client done !done !done || (done && RX != prev2_RX) done && RX == LISTEN done && RX != LISTEN done && RX == prev2_RX done !done !done done !done!done done done Figure 5.24: WIZ850io controller Finite State Machine Figure 5.25 presents the FSM for the general configurations made to the WIZ850io module, which are the gateway address, subnet mask address, MAC address, and IP address. For each configuration, the configured address is then confirmed by reading from the value on that register. When they do not match, the registers are reconfigured (this comparison is represented in Figure 5.25 as “RX == TX”). The done signal becomes active when the data on the SPI Master has been transmitted/received (“TX_done || RX_done” in Figure 5.23). Idle CR_Config S0_Config S0_Write S0_Read S1_Config S1_Read S1_WriteS2_ConfigS2_ReadS2_Write S2_Data start && resetn finished finished finished finished finished finished finishedfinishedfinished finished finished !finished !finished !finished !finished !finished !finished!finished !start || !resetn !finished!finished!finished !finished SUBR_WriteGAR_Read GAR_Write SUBR_Read SHAR_Write SHAR_Read SUBR SIPR_Write SIPR_Read start && resetn !start || !resetn !done !done !done !done !done !done !done done done done done && RX == TX done && RX == TX done && RX == TX done && RX == TX SnMR_Write SnMR_Read SnTXBUF_SIZE _Write SnTXBUF_SIZE _Read SnPORT _Write SnPORT _Read SnDIPR0 _Write SnDPORT0 _Write SnCR_Write SnSR_Read start && resetn !start || !resetn done && RX == TX && config_TXSIZE done done && RX == TX done done && RX == TX && socket_client done done done done && RX == INIT done && RX != TX done && RX != TX done && RX != TX done && RX != INIT done && RX != TX done && RX != TX done && RX != TX done && RX != TX done && RX == TX && !config_TXSIZE done && RX == TX && !socket_client Idle SnDIPR0 _Write SnDPORT0 _Write SnCR_Write SnSR_Read SnTXFSR _Read SnTXRD _Read SnTXBUF _Write Wait_PCL2 _Valid SnTXWR _Write SnCRSend _Write SnTXRDSend _Read Idle SnCRListen _Write SnSRListen _Read SnRXRSR _Read SnRXRD _Read SnRXBUF _Read SnRXRD _Write SnCR_Write start && resetn && socket_client !start || !resetn start && resetn && !socket_client done done done !done || (done && RX == INIT) done && RX == ESTABLISHED done && RX != ESTABLISHED && RX != INIT done && RX == prev2_RX !done || (done && RX != prev2_RX) done && pcl2_data && !fifo_valid fifo_valid done && ((pcl2_data && fifo_valid) || !pcl2_data) donedone done done && !sending && pcl2_last_packet done && !sending && !pcl2_last_packet !done !done !done !done !fifo_valid !done!done!done !done || (done && sending) !done !done !done !done !done !done!done!done !done start && resetn && !socket_client !start || !resetn !done start && resetn && socket_client done !done !done || (done && RX != prev2_RX) done && RX == LISTEN done && RX != LISTEN done && RX == prev2_RX done !done !done done !done!done done done Figure 5.25: WIZ850io general configuration Finite State Machine 101
5.2. Implementation The initial configuration made to each socket is their mode, in this case, all of them will be using TCP/IP. Then, the TX memory size of the 8 available sockets is defined in the S0_Config state. Consequently, this is no longer executed when running the same module for states S1_Config , and S2_Config . The socket port is assigned next, and the destination IP and port are only defined when the socket type is a client (i.e., socket 0). With the socket setup complete, the OPEN command is sent, and the socket status is verified (after the OPEN command has been issued, the socket status must be INIT ). Idle CR_Config S0_Config S0_Write S0_Read S1_Config S1_Read S1_WriteS2_ConfigS2_ReadS2_Write S2_Data start && resetn finished finished finished finished finished finished finishedfinishedfinished finished finished !finished !finished !finished !finished !finished !finished!finished !start || !resetn !finished!finished!finished !finished SUBR_WriteGAR_Read GAR_Write SUBR_Read SHAR_Write SHAR_Read SUBR SIPR_Write SIPR_Read start && resetn !start || !resetn !done !done !done !done !done !done !done done done done done && RX == TX done && RX == TX done && RX == TX done && RX == TX SnMR_Write SnMR_Read SnTXBUF_SIZE _Write SnTXBUF_SIZE _Read SnPORT _Write SnPORT _Read SnDIPR0 _Write SnDPORT0 _Write SnCR_Write SnSR_Read start && resetn !start || !resetn done && RX == TX && config_TXSIZE done done && RX == TX done done && RX == TX && socket_client done done done done && RX == INIT done && RX != TX done && RX != TX done && RX != TX done && RX != INIT done && RX != TX done && RX != TX done && RX != TX done && RX != TX done && RX == TX && !config_TXSIZE done && RX == TX && !socket_client Idle SnDIPR0 _Write SnDPORT0 _Write SnCR_Write SnSR_Read SnTXFSR _Read SnTXRD _Read SnTXBUF _Write Wait_PCL2 _Valid SnTXWR _Write SnCRSend _Write SnTXRDSend _Read Idle SnCRListen _Write SnSRListen _Read SnRXRSR _Read SnRXRD _Read SnRXBUF _Read SnRXRD _Write SnCR_Write start && resetn && socket_client !start || !resetn start && resetn && !socket_client done done done !done || (done && RX == INIT) done && RX == ESTABLISHED done && RX != ESTABLISHED && RX != INIT done && RX == prev2_RX !done || (done && RX != prev2_RX) done && pcl2_data && !fifo_valid fifo_valid done && ((pcl2_data && fifo_valid) || !pcl2_data) donedone done done && !sending && pcl2_last_packet done && !sending && !pcl2_last_packet !done !done !done !done !fifo_valid !done!done!done !done || (done && sending) !done !done !done !done !done !done!done!done !done start && resetn && !socket_client !start || !resetn !done start && resetn && socket_client done !done !done || (done && RX != prev2_RX) done && RX == LISTEN done && RX != LISTEN done && RX == prev2_RX done !done !done done !done!done done done Figure 5.26: WIZ850io socket configuration Finite State Machine Whenever the socket is a client, a destination server needs to be defined by configuring the destination IP and port registers. Then a connection request is made to that server, and when successful, the socket status changes to ESTABLISHED (if not, the process is repeated). The next step (first step if the socket is a server) is to verify the TX buffer free size, and as this value is 16-bit long when the second byte is read, the previous one may have already changed. Therefore, it is recommended that this register is read at least twice with the same value (meaning that the value has stabilized). After that, the initial TX memory pointer address is obtained, and in the SnTXBUF_Write state, the memory starts to be written starting in that initial address and incremented by 1 after each byte. However, when sending PointCloud2 message data, if the source FIFO is not yet ready, an intermediate state is used to wait for a valid signal from the FIFO. With the data already stored in the TX memory, the final TX memory pointer is configured with the addition of the written data length with the initial TX memory 102
Chapter 5. Hardware ROS Interface pointer. Then, the SEND command is issued to transmit the saved data, starting in the initial pointer and ending in the final pointer address. To understand if all the data has been sent, the initial pointer is read, and when the value matches the previous configured final value, the transmission has been completed. As the transmission length is limited to the size of the TX memory, data may need to be divided into packets that need to be sent sequentially. When this is the case, the process starts again in the TX memory free size verification, but when the packet sent is the last one (or the only one required to be sent), the system returns to the initial Idle state. The bytes that should be transmitted are the ones previously presented in the ROS network analysis (section 5.1.1), with some adjustments due to the changes explained in section 5.2.1. Thus, the module transmits the bytes corresponding to the registerPublisher (sent in the S0_Write state), requestTopic response (sent in the S1_Write state), PointCloud2 connection header response (sent in the S2_Write state), header (sent in the S2_Data state), and data (sent in the S2_Data state). Idle CR_Config S0_Config S0_Write S0_Read S1_Config S1_Read S1_WriteS2_ConfigS2_ReadS2_Write S2_Data start && resetn finished finished finished finished finished finished finishedfinishedfinished finished finished !finished !finished !finished !finished !finished !finished!finished !start || !resetn !finished!finished!finished !finished SUBR_WriteGAR_Read GAR_Write SUBR_Read SHAR_Write SHAR_Read SUBR SIPR_Write SIPR_Read start && resetn !start || !resetn !done !done !done !done !done !done !done done done done done && RX == TX done && RX == TX done && RX == TX done && RX == TX SnMR_Write SnMR_Read SnTXBUF_SIZE _Write SnTXBUF_SIZE _Read SnPORT _Write SnPORT _Read SnDIPR0 _Write SnDPORT0 _Write SnCR_Write SnSR_Read start && resetn !start || !resetn done && RX == TX && config_TXSIZE done done && RX == TX done done && RX == TX && socket_client done done done done && RX == INIT done && RX != TX done && RX != TX done && RX != TX done && RX != INIT done && RX != TX done && RX != TX done && RX != TX done && RX != TX done && RX == TX && !config_TXSIZE done && RX == TX && !socket_client Idle SnDIPR0 _Write SnDPORT0 _Write SnCR_Write SnSR_Read SnTXFSR _Read SnTXRD _Read SnTXBUF _Write Wait_PCL2 _Valid SnTXWR _Write SnCRSend _Write SnTXRDSend _Read Idle SnCRListen _Write SnSRListen _Read SnRXRSR _Read SnRXRD _Read SnRXBUF _Read SnRXRD _Write SnCR_Write start && resetn && socket_client !start || !resetn start && resetn && !socket_client done done done !done || (done && RX == INIT) done && RX == ESTABLISHED done && RX != ESTABLISHED && RX != INIT done && RX == prev2_RX !done || (done && RX != prev2_RX) done && pcl2_data && !fifo_valid fifo_valid done && ((pcl2_data && fifo_valid) || !pcl2_data) donedone done done && !sending && pcl2_last_packet done && !sending && !pcl2_last_packet !done !done !done !done !fifo_valid !done!done!done !done || (done && sending) !done !done !done !done !done !done!done!done !done start && resetn && !socket_client !start || !resetn !done start && resetn && socket_client done !done !done || (done && RX != prev2_RX) done && RX == LISTEN done && RX != LISTEN done && RX == prev2_RX done !done !done done !done!done done done Figure 5.27: WIZ850io socket data transmission Finite State Machine If the socket is a server, it needs to wait for the client connection request and to place the socket in that 103
5.2. Implementation state, the LISTEN command needs to be performed. Then, independently of the socket type, the received data size saved on the RX memory is obtained (as this is a 16-bit address, the same principle of reading at least twice the same value is applied here). Next, the initial read pointer is read and starting on that address, the data received from the client socket is gathered. After all the data has been read, the initial read pointer must be updated with an addition of the previous value with the reading size value. Lastly, the RECV command is performed to indicate that the data has been received and to update the W5500 registers accordingly. Similar to the data transmitted, the bytes that should be received are the ones previously presented in the ROS network analysis (section 5.1.1), with some adjustments due to the changes explained in section 5.2.1. Thus, the module should receive bytes corresponding to the registerPublisher response (received in the S0_Read state), the requestTopic method (received in the S1_Read state), and the PointCloud2 connection header (received in the S2_Read state). Idle CR_Config S0_Config S0_Write S0_Read S1_Config S1_Read S1_WriteS2_ConfigS2_ReadS2_Write S2_Data start && resetn finished finished finished finished finished finished finishedfinishedfinished finished finished !finished !finished !finished !finished !finished !finished!finished !start || !resetn !finished!finished!finished !finished SUBR_WriteGAR_Read GAR_Write SUBR_Read SHAR_Write SHAR_Read SUBR SIPR_Write SIPR_Read start && resetn !start || !resetn !done !done !done !done !done !done !done done done done done && RX == TX done && RX == TX done && RX == TX done && RX == TX SnMR_Write SnMR_Read SnTXBUF_SIZE _Write SnTXBUF_SIZE _Read SnPORT _Write SnPORT _Read SnDIPR0 _Write SnDPORT0 _Write SnCR_Write SnSR_Read start && resetn !start || !resetn done && RX == TX && config_TXSIZE done done && RX == TX done done && RX == TX && socket_client done done done done && RX == INIT done && RX != TX done && RX != TX done && RX != TX done && RX != INIT done && RX != TX done && RX != TX done && RX != TX done && RX != TX done && RX == TX && !config_TXSIZE done && RX == TX && !socket_client Idle SnDIPR0 _Write SnDPORT0 _Write SnCR_Write SnSR_Read SnTXFSR _Read SnTXRD _Read SnTXBUF _Write Wait_PCL2 _Valid SnTXWR _Write SnCRSend _Write SnTXRDSend _Read Idle SnCRListen _Write SnSRListen _Read SnRXRSR _Read SnRXRD _Read SnRXBUF _Read SnRXRD _Write SnCR_Write start && resetn && socket_client !start || !resetn start && resetn && !socket_client done done done !done || (done && RX == INIT) done && RX == ESTABLISHED done && RX != ESTABLISHED && RX != INIT done && RX == prev2_RX !done || (done && RX != prev2_RX) done && pcl2_data && !fifo_valid fifo_valid done && ((pcl2_data && fifo_valid) || !pcl2_data) donedone done done && !sending && pcl2_last_packet done && !sending && !pcl2_last_packet !done !done !done !done !fifo_valid !done!done!done !done || (done && sending) !done !done !done !done !done !done!done!done !done start && resetn && !socket_client !start || !resetn !done start && resetn && socket_client done !done !done || (done && RX != prev2_RX) done && RX == LISTEN done && RX != LISTEN done && RX == prev2_RX done !done !done done !done!done done done Figure 5.28: WIZ850io socket data reception Finite State Machine Table 5.2 presents the configuration of the WIZ850io module. The configured addresses have been selected to be in the same subnet of the Host machine so that they can detect each other, and more importantly, communicate. The port numbers have arbitrary values previously captured in the ROS network analysis. The destination IP address corresponds to the Host machine IP, and the destination port number, to the ROS Master port number. As the TX memory size of socket 2 has been configured with 8 KB, the 5 remaining omitted sockets have been configured with 1 KB, except for socket 7 that has 0 KB because there is only 16 Kbyte of TX memory available for all sockets. On the other hand, the RX memory size has 104
Chapter 6. Conclusion either the PC or the Zynq board. To visualize the LiDAR point cloud data, the data is first obtained by the TDC peripheral in the FPGA and converted into binary. Then the values are sent to the PS, converted into depth in the ROS node and published to the PointCloud2 topic. Next, the topic is accessed by a ROS subscriber on the PC and displayed using the ROS visualization tool (i.e., RVIZ). Any other ROS platform could be easily added to access or visualize the point cloud frames. For the worst-case scenario of a full point cloud frame at 200 m, the 10 FPS requirements are met with an average of 10.32 FPS. Nonetheless, the system refresh rate could be easily increased with a second TDC channel. It was previously proven in literature works that the partial ROS migration into hardware could improve ROS performance, but it would require the TCP/IP stack implementation in hardware. However, most of the open-source implementations only implement a single port, and as explained in this dissertation, a fully hardwired Publisher would require a minimum of 3 sockets. Therefore, as the main objective was to analyze and understand how the ROS asynchronous communication works, a more straightforward way of implementing the TCP/IP protocol was chosen (via the WIZ850io network module). As a consequence, the hardware version of the ROS interface was developed as a Proof of Concept, proving the system feasibility. A downside of using the WIZ850io module is the requirement of using the SPI protocol to communicate with the network module. This is because SPI works at relatively low frequencies compared to the FPGA capabilities, and the data is exchanged one bit at a time. Due to the bottleneck introduced in the SPI communication, a full point cloud frame with 36000 points has a 3.45 refresh rate, independently of the depth. On the other hand, the system becomes significantly more stable in terms of frame refresh rate. Moreover, the Processing System of the MPSoC is no longer required as well as no Operating System image needs to be generated. Consequently, power consumption in the MPSoC is reduced by over 84% as only the FPGA is used. As for the required FPGA resources, the difference between the software and hardware ROS interfaces is not significant despite the ROS implementation in the FPGA because the latter does not require an AXI interface to communicate with the PS. Also, some extra functionality IPs used in the software version were unnecessary (e.g., interconnects and system management wizard). Thus, the hardware ROS interface is a valuable alternative, considering the low power consumption, frame rate stability, and reduction of the silicon area required, along with the potential of improvement once the TCP/IP stack does not introduce a bottleneck in the system performance. The TCP/IP can also be implemented in the FPGA, or a network module with a faster interface could be used instead of the WIZ850io chip, which used the SPI protocol. The work done on this dissertation has contributed to a research project exploring a 2D MEMS LiDAR sensor for automotive systems, which is being explored in a partnership between Bosch Car Multimédia 111
6.1. Future Work Portugal, S.A [127] and the University of Minho [128]. Moreover, the experience earned by the development of this dissertation has not only improved the knowledge of the authors as also contributed to the scientific community with the published conference article in [91], being a second one under preparation. 6.1 Future Work In terms of the TDC architecture, one of the improvements that could be made is the introduction of more channels to prove the TDC scalability. Several channels could be used in different ways to achieve distinct purposes. For example, if they were scattered across the FPGA, they could provide valuable information about the effect of the TDC location on the performance. Another use case would be using several channels to calibrate the TDC by executing the mean between the different TDC channel values. Finally, as previously mentioned, several channels could be used to improve the worst-case scenario performance of the software ROS interface. This is because the system would be capable of processing a new pulse without waiting for the previous Time-of-Flight to be calculated by a channel of the TDC peripheral. Moreover, despite the lack of information and the increased difficulty resulting from a more complex FPGA architecture, and the introduction of a double-sampling stage in the TDC, manual routing could be thoroughly explored in a future implementation. Similarly to other works, this could mainly improve the linearity and overall performance of the TDC architecture. The ROS Publisher node implemented on software is responsible for converting the time value into depth. This step could have been implemented in the FPGA as it was done for the hardwired ROS Publisher, and it would probably slightly increase the point cloud refresh rate and stability. In the current implementation, a PC is required to visualize the data because the generated Linux image does not include RVIZ. This is due to the fact that the ROS package for Embedded Linux is only experimental, and some problems occur when including RVIZ and some other ROS packages into the Linux image. However, if this problem was solved in the future, a display could be directly connected to the Zynq board. The most significant improvement to the hardware ROS interface would be the TCP/IP protocol implementation on the FPGA with a minimum of 3 sockets. Based on the results presented by previous works, a good frame refresh rate improvement would be expected compared to the software ROS interface. Thanks to the work done in this dissertation, the steps to implement a ROS Publisher are now very clear. Thus, there would not be the same need for simplifying the remaining of the system in a future implementation, as it was done here by using the WIZ850io network module to implement the TCP/IP stack. Other improvements would be related to the addition of sockets that would allow for more features 112
Chapter 6. Conclusion to be directly provided by the hardware Publisher. They would remove the need for a node working as a message relay on the PC side. Lastly, some of the configuration fields could be made dynamic, allowing the user to change the node according to his needs. Now that the authors have a much better understanding of how ROS works, and due to the described advantages provided by ROS 2, it would be interesting to apply a similar development approach to ROS 2. This would also allow for an in-depth comparison of both ROS versions. 113
References [1] N. Druml, I. Maksymova, T. Thurner, D. van Lierop, M. Hennecke, and A. Foroutan, “1D MEMS micro-scanning LiDAR,” in Conference on Sensor Device Technologies and Applications (SENSORDEVICES) , vol. 9, 2018. Accessed on 29-11-2021. [2] E. Nurvitadhi, J. Sim, D. Sheffield, A. Mishra, S. Krishnan, and D. Marr, “Accelerating recurrent neural networks in analytics servers: Comparison of FPGA, CPU, GPU, and ASIC,” in FPL 2016 - 26th International Conference on Field-Programmable Logic and Applications , 2016. Accessed on 23-11-2020. [3] S. Tancock, E. Arabul, and N. Dahnoun, “A Review of New Time-To-Digital Conversion Techniques,” oct 2019. Accessed on 23-11-2020. [4] M. Quigley, K. Conley, B. Gerkey, J. Faust, T. Foote, J. Leibs, R. Wheeler, A. Y. Ng, et al. , “Ros: an open-source robot operating system,” in ICRA workshop on open source software , vol. 3, p. 5, Kobe, Japan, 2009. Accessed on 25-11-2020. [5] LeddarTech, “What is LiDAR and Why LiDAR.” https://leddartech.com/why-lidar/. [Online]. Accessed on 27-11-2021. [6] Y. Li and J. Ibanez-Guzman, “Lidar for autonomous driving: The principles, challenges, and trends for automotive lidar and perception systems,” IEEE Signal Processing Magazine , vol. 37, no. 4, pp. 50–61, 2020. Accessed on 27-10-2021. [7] HabibOladepo, “ROS Nodes.” http://wiki.ros.org/Nodes, 2018. [Online]. Accessed on 29-11-2021. [8] O. Robotics, “ROS.” https://www.ros.org, 2021. [Online]. Accessed on 23-11-2020. [9] O. Robotics, “ROS 2.” https://index.ros.org/doc/ros2/, 2021. [Online]. Accessed on 23-11-2020. [10] Udacity, “How Self-driving Cars Work: Sensor Systems.” https://www.udacity.com/blog/ 2021/03/how-self-driving-cars-work-sensor-systems.html, 2021. [Online]. Accessed on 27-07-2021. 114
References [11] D. J. Yeong, G. Velasco-Hernandez, J. Barry, J. Walsh, et al. , “Sensor and sensor fusion technology in autonomous vehicles: A review,” Sensors , vol. 21, no. 6, p. 2140, 2021. Accessed on 27-07-2021. [12] F. Petit and Blickfeld, “How sensors enable autonomous driving.” https://www.blickfeld. com/blog/sensor-fusion-for-autonomous-driving/, 2020. [Online]. Accessed on 27-07-2021. [13] M. Khader and Samir Cherian, “An Introduction to Automotive LIDAR.” https: //www.ti.com/lit/wp/slyy150a/slyy150a.pdf?ts=1608521114466&ref_url= https%253A%252F%252Fwww.google.com%252F, 2020. [Online]. Accessed on 23-11-2020. [14] L. A. Wasser, “The Basics of LiDAR - Light Detection and Ranging - Remote Sensing.” https: //www.neonscience.org/resources/learning-hub/tutorials/lidar-basics, 2020. [Online]. Accessed on 23-11-2020. [15] Automation.com, “LiDAR Adoption: Technology Choices and Supply Chain Management are Key Enablers.” https://www.automation.com/en-us/articles/september-2021/ lidar-adoption-technology-choices-supply-chain. [Online]. Accessed on 24-09- 2021. [16] Grand View Research, “LiDAR Market Size, Share & Trends Analysis Report By Product Type (Airborne, Terrestrial), By Component (GPS, Navigation, Laser Scanners), By Application, By Region, And Segment Forecasts, 2020 - 2027.” https://www.grandviewresearch.com/ industry-analysis/lidar-light-detection-and-ranging-market, 2020. [Online]. Accessed on 23-11-2020. [17] B. Schweber, “LIDAR and Time of Flight, Part 2: Operation.” https://www. microcontrollertips.com/lidar-and-time-of-flight-part-2-operation/, 2019. [Online]. Accessed on 23-11-2020. [18] O. Wing, “Understanding Indirect ToF Depth Sensing - Azure Depth Platform.” https://devblogs.microsoft.com/azure-depth-platform/ understanding-indirect-tof-depth-sensing/?ranMID=46131&ranEAID= a1LgFw09t88&ranSiteID=a1LgFw09t88-_.LJ8ThbW33A2YJ4wMZzaA&epi= a1LgFw09t88-_.LJ8ThbW33A2YJ4wMZzaA&irgwc=1&OCID=AID2200057_aff_7806_ 1243925&tduid=%28ir__xbo3koct19kf6nkp133xftfux32xox6mpxizc2t100%29% 115
References 287806%29%281243925%29%28a1LgFw09t88-_.LJ8ThbW33A2YJ4wMZzaA%29%28% 29&irclickid=_xbo3koct19kf6nkp133xftfux32xox6mpxizc2t100, 2021. [Online]. Accessed on 02-11-2021. [19] Terabee, “Time-of-Flight principle: Technologies and advantages | Terabee.” https://www. terabee.com/time-of-flight-principle/. [Online]. Accessed on 02-11-2021. [20] P. Palojärvi, K. Määttä, and J. Kostamovaara, “Pulsed time-of-flight laser radar module with millimeter-level accuracy using full custom receiver and TDC ASICs,” IEEE Transactions on Instrumentation and Measurement , vol. 51, no. 5, 2002. Accessed on 23-11-2020. [21] R. Szplet, P. Kwiatkowski, K. Rózyc, Z. Jachna, and T. Sondej, “Picosecond-precision multichannel autonomous time and frequency counter,” Review of Scientific Instruments , vol. 88, no. 12, 2017. Accessed on 23-11-2020. [22] Q. Shen, S. Liu, B. Qi, Q. An, S. Liao, P. Shang, C. Peng, and W. Liu, “A 1.7 ps equivalent bin size and 4.2 ps RMS FPGA TDC based on multichain measurements averaging method,” IEEE Transactions on Nuclear Science , vol. 62, no. 3, 2015. Accessed on 23-11-2020. [23] R. Szplet, D. Sondej, and G. Grz�da, “Subpicosecond-resolution time-to-digital converter with multiedge coding in independent coding lines,” in Conference Record - IEEE Instrumentation and Measurement Technology Conference , 2014. Accessed on 23-11-2020. [24] A. El-Hadbi, O. Elissati, and L. Fesquet, “Time-to-Digital Converters: A Literature Review and New Perspectives,” in Proceedings - 5th International Conference on Event-Based Control, Communication and Signal Processing, EBCCSP 2019 , 2019. Accessed on 24-11-2020. [25] R. Machado, J. Cabral, and F. S. Alves, “Recent Developments and Challenges in FPGA-Based Time- To-Digital Converters,” IEEE Transactions on Instrumentation and Measurement , vol. 68, pp. 4205– 4221, nov 2019. Accessed on 23-11-2020. [26] J. Wu and J. Xu, “A Novel TDC Scheme: Combinatorial Gray Code Oscillator Based TDC for Low Power and Low Resource Usage Applications,” in 2019 5th International Conference on Event-Based Control, Communication, and Signal Processing (EBCCSP) , pp. 1–7, IEEE, may 2019. Accessed on 24-11-2020. 116
References [27] Z. Soni, A. Patel, D. K. Panda, and A. B. Sarbadhikari, “Comparative study of delay line based time to digital converter using fpga,” International research Journal of Engineering and Technology (IRJET) , vol. 4, no. 9, pp. 1169–1175, 2017. Accessed on 06-08-2021. [28] HardwareBee, “The Ultimate Guide to FPGA Clock - HardwareBee.” https://hardwarebee. com/ultimate-guide-fpga-clock/. [Online]. Accessed on 05-08-2021. [29] Y. Sano, Y. Horii, M. Ikeno, O. Sasaki, M. Tomoto, and T. Uchida, “Subnanosecond time-to-digital converter implemented in a kintex-7 fpga,” Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment , vol. 874, pp. 50–56, 2017. Accessed on 06-08-2021. [30] A. Balla, M. M. Beretta, P. Ciambrone, M. Gatta, F. Gonnella, L. Iafolla, M. Mascolo, R. Messi, D. Moricciani, and D. Riondino, “The characterization and application of a low resource fpga-based time to digital converter,” Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment , vol. 739, pp. 75–82, 2014. Accessed on 06-08-2021. [31] Wikipedia, “Clock skew - Wikipedia.” https://en.wikipedia.org/wiki/Clock_skew, 2021. [Online]. Accessed on 06-08-2021. [32] Wikipedia, “Jitter - Wikipedia.” https://en.wikipedia.org/wiki/Jitter, 2021. [Online]. Accessed on 06-08-2021. [33] NandLand, “Metastability in an FPGA.” https://www.nandland.com/articles/ metastability-in-an-fpga.html. [Online]. Accessed on 06-08-2021. [34] Y. Wang, J. Kuang, C. Liu, and Q. Cao, “A 3.9-ps RMS Precision Time-to-Digital Converter Using Ones-Counter Encoding Scheme in a Kintex-7 FPGA,” IEEE Transactions on Nuclear Science , vol. 64, pp. 2713–2718, oct 2017. Accessed on 25-11-2020. [35] K. Cui, Z. Ren, X. Li, Z. Liu, and R. Zhu, “A high-linearity, ring-oscillator-based, vernier time-to-digital converter utilizing carry chains in fpgas,” IEEE Transactions on Nuclear Science , vol. 64, no. 1, pp. 697–704, 2016. Accessed on 13-08-2021. [36] K. Cui, X. Li, Z. Liu, and R. Zhu, “Toward implementing multichannels, ring-oscillator-based, vernier time-to-digital converter in fpgas: Key design points and construction method,” IEEE Transactions 117
References on Radiation and Plasma Medical Sciences , vol. 1, no. 5, pp. 391–399, 2017. Accessed on 13-08- 2021. [37] M. Maamoun, I. Arami, R. Beguenane, A. Benbelkacem, and A. Meraghni, “A 3 ps resolution time-to- digital converter in low-cost fpga for laser rangefinder,” in Proc. World Congr. Eng. , vol. 1, pp. 7–11, 2017. Accessed on 13-08-2021. [38] K. Cui, Z. Liu, R. Zhu, and X. Li, “Fpga-based high-performance time-to-digital converters by utilizing multi-channels looped carry chains,” in 2017 International Conference on Field Programmable Technology (ICFPT) , pp. 223–226, IEEE, 2017. Accessed on 13-08-2021. [39] C.-C. Chen, C.-S. Hwang, Y. Lin, and G.-H. Chen, “Note: All-digital pulse-shrinking time-to-digital converter with improved dynamic range,” Review of Scientific Instruments , vol. 87, no. 4, p. 046104, 2016. Accessed on 13-08-2021. [40] R. Szplet and K. Klepacki, “An fpga-integrated time-to-digital converter based on two-stage pulse shrinking,” IEEE Transactions on instrumentation and measurement , vol. 59, no. 6, pp. 1663– 1670, 2009. [Online]. Accessed on 03-11-2021. [41] R. Machado, F. S. Alves, and J. Cabral, “Gray-code TDC with improved linearity and scalability for LiDAR applications,” in Proceedings - 6th International Conference on Event-Based Control, Communication and Signal Processing, EBCCSP 2020 , 2020. Accessed on 23-11-2020. [42] A. I. Hussein, S. Vasadi, and J. Paramesh, “A 450 fs 65-nm cmos millimeter-wave time-to-digital converter using statistical element selection for all-digital plls,” IEEE Journal of Solid-State Circuits , vol. 53, no. 2, pp. 357–374, 2017. Accessed on 03-11-2021. [43] R. Enomoto, T. Iizuka, T. Koga, T. Nakura, and K. Asada, “A 16-bit 2.0-ps resolution two-step tdc in 0.18- � m cmos utilizing pulse-shrinking fine stage with built-in coarse gain calibration,” IEEE Transactions on Very Large Scale Integration (VLSI) Systems , vol. 27, no. 1, pp. 11–19, 2018. Accessed on 03-11-2021. [44] J. Mauricio, D. Gascon, D. Ciaglia, S. Gómez, G. Fernández, and A. Sanuy, “Matrix: A novel twodimensional resistive interpolation 15 ps time-to-digital converter asic,” in 2016 IEEE Nuclear Science Symposium, Medical Imaging Conference and Room-Temperature Semiconductor Detector Workshop (NSS/MIC/RTSD) , pp. 1–3, IEEE, 2016. Accessed on 03-11-2021. 118
References [45] Clive ”Max” Maxfield, “Fundamentals of FPGAs: What Are FPGAs and Why Are They Needed?.” https://www.digikey.com/en/articles/ fundamentals-of-fpgas-what-are-fpgas-and-why-are-they-needed, 2019. [Online]. Accessed on 02-08-2021. [46] HardwareBee, “FPGA vs. CPU – What is the difference - HardwareBee.” https:// hardwarebee.com/fpga-vs-cpu-difference/. [Online]. Accessed on 29-07-2021. [47] A. Ejnioui and N. Ranganathan, “Routing on switch matrix multi-fpga systems,” in VLSI Design 2000. Wireless and Digital Imaging in the Millennium. Proceedings of 13th International Conference on VLSI Design , pp. 248–253, IEEE, 2000. Accessed on 02-08-2021. [48] P. Babu and E. Parthasarathy, “Reconfigurable fpga architectures: A survey and applications,” Journal of The Institution of Engineers (India): Series B , pp. 1–14, 2020. Accessed on 02-08-2021. [49] A. Ruede, “A Scientist’s Guide to FPGAs Content,” 2019. [Online]. Accessed on 02-08-2021. [50] Altera, “White Paper FPGA Architecture ver. 1.0 1,” 2006. [Online]. Accessed on 24-09-2021. [51] Xilinx, “Xilinx - Adaptable. Intelligent..” https://www.xilinx.com/, 2021. [Online]. Accessed on 02-08-2021. [52] A. M. Devices, “Welcome to AMD � High-Performance Processors and Graphics.” https://www. amd.com/en, 2021. [Online]. Accessed on 02-08-2021. [53] L. Semiconductor, “Home - Lattice Semiconductor.” https://www.latticesemi.com/, 2021. [Online]. Accessed on 02-08-2021. [54] Xilinx, “Vivado Design Suite.” https://www.xilinx.com/products/design-tools/ vivado.html, 2021. [Online]. Accessed on 02-08-2021. [55] Xilinx, “Vitis.” https://www.xilinx.com/products/design-tools/vitis.html, 2021. [Online]. Accessed on 04-08-2021. [56] Xilinx, “Vitis AI.” https://www.xilinx.com/products/design-tools/vitis/ vitis-ai.html, 2021. [Online]. Accessed on 04-08-2021. [57] Xilinx, “PetaLinux Tools.” https://www.xilinx.com/products/design-tools/ embedded-software/petalinux-sdk.html, 2021. [Online]. Accessed on 05-08-2021. 119
References [58] GCFGlobal, “Computer Basics: Understanding Operating Systems.” https://edu. gcfglobal.org/en/computerbasics/understanding-operating-systems/1/. [Online]. Accessed on 29-07-2021. [59] S. J. Bigelow, “What is an Operating System (OS)? Definition, Types and Examples - WhatIs.com.” https://whatis.techtarget.com/definition/operating-system-OS, 2021. [Online]. Accessed on 29-07-2021. [60] U. o. W. Australia, “Understanding operating systems - University of Wollongong – UOW.” https: //www.uow.edu.au/student/learning-co-op/technology-and-software/ operating-systems/. [Online]. Accessed on 29-07-2021. [61] “Introduction | Robot Operating System Cookbook.” https://subscription.packtpub. com/book/hardware_and_creative/9781783987443/1/ch01lvl1sec10/ introduction. [Online]. Accessed on 25-11-2020. [62] O. Robotics, “ROS Publishers and Subscribers.” http://wiki.ros.org/ROS/Tutorials/ WritingPublisherSubscriber%28c%2B%2B%29, 2019. [Online]. Accessed on 29-07-2021. [63] O. Robotics, “ROS Topics.” http://wiki.ros.org/Topics, 2019. [Online]. Accessed on 30-07-2021. [64] J. Robert, “Hands-On Introduction to Robot Operating System(ROS) | trojrobert.” https://trojrobert.github.io/ hands-on-introdution-to-robot-operating-system(ros)/, 2020. [Online]. Accessed on 29-07-2021. [65] O. Robotics, “ROS Messages.” http://wiki.ros.org/msg, 2019. [Online]. Accessed on 30- 07-2021. [66] R. Chen, “ROS Services.” https://medium.com/@raymonduchen/ ros-����-4-�c-��service�client-1f5fa3184c60, 2018. [Online]. Accessed on 29- 07-2021. [67] O. Robotics, “ROS Metrics.” https://metrics.ros.org/index.html, 2021. [Online]. Accessed on 30-07-2021. 120
Appendix A: Linux Image Configuration 1# ------------------------- user -rootfsconfig file ------------------------ 2CONFIG_nano 3CONFIG_python -pycryptodomex 4CONFIG_catkin 5CONFIG_cmake -modules 6CONFIG_gencpp 7CONFIG_ros 8CONFIG_rosparam 9CONFIG_rosbuild 10 CONFIG_rospack 11 CONFIG_rosgraph 12 CONFIG_rosgraph -msgs 13 CONFIG_ros -environment 14 CONFIG_rosbash 15 CONFIG_rosmake 16 CONFIG_rosboost -cfg 17 CONFIG_roslib 18 CONFIG_roscreate 19 CONFIG_rosclean 20 CONFIG_rosunit 21 CONFIG_roslang 22 CONFIG_roscpp 23 CONFIG_rosout 24 CONFIG_roscpp -serialization 25 CONFIG_roscpp -traits 26 CONFIG_rostest 27 CONFIG_rosservice 28 CONFIG_rostopic 29 CONFIG_rospy 30 CONFIG_ros -comm 31 CONFIG_rosconsole 32 CONFIG_rosconsole-bridge 33 CONFIG_rosgraph -msgs 34 CONFIG_rosnode 35 CONFIG_roslaunch 36 CONFIG_rosmaster 37 CONFIG_roswtf 38 CONFIG_rosbag -storage 39 CONFIG_rosbag 40 CONFIG_rosmsg 41 CONFIG_rostime 42 CONFIG_roslz4 43 CONFIG_genmsg 127
44 CONFIG_message -runtime 45 CONFIG_std -msgs 46 CONFIG_xmlrpcpp 47 CONFIG_std -srvs 48 CONFIG_message -filters 49 CONFIG_gennodejs 50 CONFIG_cpp -common 51 CONFIG_message -generation 52 CONFIG_topic -tools 53 CONFIG_mk 54 CONFIG_genpy 55 CONFIG_roscpp -core 56 CONFIG_sensor -msgs 57 CONFIG_geometry -msgs 58 CONFIG_common -msgs 59 CONFIG_dynamic -reconfigure 60 CONFIG_cv -bridge 61 CONFIG_pcl 62 CONFIG_pcl -ros 63 CONFIG_pcl -msgs 64 CONFIG_pcl -conversions 65 CONFIG_perception-pcl 66 CONFIG_eigenpy 67 CONFIG_eigen -stl-containers 68 CONFIG_eigen -conversions 69 CONFIG_tf2 -eigen 70 CONFIG_ecl -eigen 71 CONFIG_boost 72 CONFIG_rosboost -cfg 73 # ------------------------------------------------------------------------- Code A.1: Complete list of packages added to the user-rootfsconfig file 128
Appendix B: ROS PointCloud2 Message 10000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E. 20010 09 8a 0d 43 40 00 40 06 25 29 7f 00 01 01 7f 00 ...C@.@.%)...... 30020 00 01 eb c9 87 20 ff 5f f8 c8 0f fa 08 5f 80 18 ..... ._....._.. 40030 02 00 08 7f 00 00 01 01 08 0a c6 5f 64 7c 51 ca ..........._d|Q. 50040 e3 db 52 09 00 00 14 00 00 00 63 61 6c 6c 65 72 ..R.......caller 60050 69 64 3d 2f 70 63 6c 5f 74 61 6c 6b 65 72 0a 00 id=/pcl_talker.. 70060 00 00 6c 61 74 63 68 69 6e 67 3d 30 27 00 00 00 ..latching=0'... 80070 6d 64 35 73 75 6d 3d 31 31 35 38 64 34 38 36 64 md5sum=1158d486d 90080 64 35 31 64 36 38 33 63 65 32 66 31 62 65 36 35 d51d683ce2f1be65 10 0090 35 63 33 63 31 38 31 c7 08 00 00 6d 65 73 73 61 5c3c181....messa 11 00a0 67 65 5f 64 65 66 69 6e 69 74 69 6f 6e 3d 23 20 ge_definition=# 12 00b0 54 68 69 73 20 6d 65 73 73 61 67 65 20 68 6f 6c This message hol 13 00c0 64 73 20 61 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 ds a collection 14 00d0 6f 66 20 4e 2d 64 69 6d 65 6e 73 69 6f 6e 61 6c of N-dimensional 15 00e0 20 70 6f 69 6e 74 73 2c 20 77 68 69 63 68 20 6d points , which m 16 00f0 61 79 0a 23 20 63 6f 6e 74 61 69 6e 20 61 64 64 ay.# contain add 17 0100 69 74 69 6f 6e 61 6c 20 69 6e 66 6f 72 6d 61 74 itional informat 18 0110 69 6f 6e 20 73 75 63 68 20 61 73 20 6e 6f 72 6d ion such as norm 19 0120 61 6c 73 2c 20 69 6e 74 65 6e 73 69 74 79 2c 20 als, intensity , 20 0130 65 74 63 2e 20 54 68 65 0a 23 20 70 6f 69 6e 74 etc. The.# point 21 0140 20 64 61 74 61 20 69 73 20 73 74 6f 72 65 64 20 data is stored 22 0150 61 73 20 61 20 62 69 6e 61 72 79 20 62 6c 6f 62 as a binary blob 23 0160 2c 20 69 74 73 20 6c 61 79 6f 75 74 20 64 65 73 , its layout des 24 0170 63 72 69 62 65 64 20 62 79 20 74 68 65 0a 23 20 cribed by the.# 25 0180 63 6f 6e 74 65 6e 74 73 20 6f 66 20 74 68 65 20 contents of the 26 0190 22 66 69 65 6c 64 73 22 20 61 72 72 61 79 2e 0a "fields" array.. 27 01a0 0a 23 20 54 68 65 20 70 6f 69 6e 74 20 63 6c 6f .# The point clo 28 01b0 75 64 20 64 61 74 61 20 6d 61 79 20 62 65 20 6f ud data may be o 29 01c0 72 67 61 6e 69 7a 65 64 20 32 64 20 28 69 6d 61 rganized 2d (ima 30 01d0 67 65 2d 6c 69 6b 65 29 20 6f 72 20 31 64 0a 23 ge-like) or 1d.# 31 01e0 20 28 75 6e 6f 72 64 65 72 65 64 29 2e 20 50 6f (unordered). Po 32 01f0 69 6e 74 20 63 6c 6f 75 64 73 20 6f 72 67 61 6e int clouds organ 33 0200 69 7a 65 64 20 61 73 20 32 64 20 69 6d 61 67 65 ized as 2d image 34 0210 73 20 6d 61 79 20 62 65 20 70 72 6f 64 75 63 65 s may be produce 35 0220 64 20 62 79 0a 23 20 63 61 6d 65 72 61 20 64 65 d by.# camera de 36 0230 70 74 68 20 73 65 6e 73 6f 72 73 20 73 75 63 68 pth sensors such 37 0240 20 61 73 20 73 74 65 72 65 6f 20 6f 72 20 74 69 as stereo or ti 38 0250 6d 65 2d 6f 66 2d 66 6c 69 67 68 74 2e 0a 0a 23 me-of-flight...# 39 0260 20 54 69 6d 65 20 6f 66 20 73 65 6e 73 6f 72 20 Time of sensor 40 0270 64 61 74 61 20 61 63 71 75 69 73 69 74 69 6f 6e data acquisition 41 0280 2c 20 61 6e 64 20 74 68 65 20 63 6f 6f 72 64 69 , and the coordi 42 0290 6e 61 74 65 20 66 72 61 6d 65 20 49 44 20 28 66 nate frame ID (f 43 02a0 6f 72 20 33 64 0a 23 20 70 6f 69 6e 74 73 29 2e or 3d.# points). 129
44 02b0 0a 48 65 61 64 65 72 20 68 65 61 64 65 72 0a 0a .Header header.. 45 02c0 23 20 32 44 20 73 74 72 75 63 74 75 72 65 20 6f # 2D structure o 46 02d0 66 20 74 68 65 20 70 6f 69 6e 74 20 63 6c 6f 75 f the point clou 47 02e0 64 2e 20 49 66 20 74 68 65 20 63 6c 6f 75 64 20 d. If the cloud 48 02f0 69 73 20 75 6e 6f 72 64 65 72 65 64 2c 20 68 65 is unordered , he 49 0300 69 67 68 74 20 69 73 0a 23 20 31 20 61 6e 64 20 ight is.# 1 and 50 0310 77 69 64 74 68 20 69 73 20 74 68 65 20 6c 65 6e width is the len 51 0320 67 74 68 20 6f 66 20 74 68 65 20 70 6f 69 6e 74 gth of the point 52 0330 20 63 6c 6f 75 64 2e 0a 75 69 6e 74 33 32 20 68 cloud..uint32 h 53 0340 65 69 67 68 74 0a 75 69 6e 74 33 32 20 77 69 64 eight.uint32 wid 54 0350 74 68 0a 0a 23 20 44 65 73 63 72 69 62 65 73 20 th..# Describes 55 0360 74 68 65 20 63 68 61 6e 6e 65 6c 73 20 61 6e 64 the channels and 56 0370 20 74 68 65 69 72 20 6c 61 79 6f 75 74 20 69 6e their layout in 57 0380 20 74 68 65 20 62 69 6e 61 72 79 20 64 61 74 61 the binary data 58 0390 20 62 6c 6f 62 2e 0a 50 6f 69 6e 74 46 69 65 6c blob..PointFiel 59 03a0 64 5b 5d 20 66 69 65 6c 64 73 0a 0a 62 6f 6f 6c d[] fields..bool 60 03b0 20 20 20 20 69 73 5f 62 69 67 65 6e 64 69 61 6e is_bigendian 61 03c0 20 23 20 49 73 20 74 68 69 73 20 64 61 74 61 20 # Is this data 62 03d0 62 69 67 65 6e 64 69 61 6e 3f 0a 75 69 6e 74 33 bigendian?.uint3 63 03e0 32 20 20 70 6f 69 6e 74 5f 73 74 65 70 20 20 20 2 point_step 64 03f0 23 20 4c 65 6e 67 74 68 20 6f 66 20 61 20 70 6f # Length of a po 65 0400 69 6e 74 20 69 6e 20 62 79 74 65 73 0a 75 69 6e int in bytes.uin 66 0410 74 33 32 20 20 72 6f 77 5f 73 74 65 70 20 20 20 t32 row_step 67 0420 20 20 23 20 4c 65 6e 67 74 68 20 6f 66 20 61 20 # Length of a 68 0430 72 6f 77 20 69 6e 20 62 79 74 65 73 0a 75 69 6e row in bytes.uin 69 0440 74 38 5b 5d 20 64 61 74 61 20 20 20 20 20 20 20 t8[] data 70 0450 20 20 23 20 41 63 74 75 61 6c 20 70 6f 69 6e 74 # Actual point 71 0460 20 64 61 74 61 2c 20 73 69 7a 65 20 69 73 20 28 data, size is ( 72 0470 72 6f 77 5f 73 74 65 70 2a 68 65 69 67 68 74 29 row_step*height) 73 0480 0a 0a 62 6f 6f 6c 20 69 73 5f 64 65 6e 73 65 20 ..bool is_dense 74 0490 20 20 20 20 20 20 20 23 20 54 72 75 65 20 69 66 # True if 75 04a0 20 74 68 65 72 65 20 61 72 65 20 6e 6f 20 69 6e there are no in 76 04b0 76 61 6c 69 64 20 70 6f 69 6e 74 73 0a 0a 3d 3d valid points..== 77 04c0 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ 78 04d0 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ 79 04e0 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ 80 04f0 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ 81 0500 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 4d ==============.M 82 0510 53 47 3a 20 73 74 64 5f 6d 73 67 73 2f 48 65 61 SG: std_msgs/Hea 83 0520 64 65 72 0a 23 20 53 74 61 6e 64 61 72 64 20 6d der.# Standard m 84 0530 65 74 61 64 61 74 61 20 66 6f 72 20 68 69 67 68 etadata for high 85 0540 65 72 2d 6c 65 76 65 6c 20 73 74 61 6d 70 65 64 er-level stamped 86 0550 20 64 61 74 61 20 74 79 70 65 73 2e 0a 23 20 54 data types..# T 87 0560 68 69 73 20 69 73 20 67 65 6e 65 72 61 6c 6c 79 his is generally 88 0570 20 75 73 65 64 20 74 6f 20 63 6f 6d 6d 75 6e 69 used to communi 89 0580 63 61 74 65 20 74 69 6d 65 73 74 61 6d 70 65 64 cate timestamped 90 0590 20 64 61 74 61 20 0a 23 20 69 6e 20 61 20 70 61 data .# in a pa 91 05a0 72 74 69 63 75 6c 61 72 20 63 6f 6f 72 64 69 6e rticular coordin 130
Appendix B. ROS PointCloud2 Message 92 05b0 61 74 65 20 66 72 61 6d 65 2e 0a 23 20 0a 23 20 ate frame..# .# 93 05c0 73 65 71 75 65 6e 63 65 20 49 44 3a 20 63 6f 6e sequence ID: con 94 05d0 73 65 63 75 74 69 76 65 6c 79 20 69 6e 63 72 65 secutively incre 95 05e0 61 73 69 6e 67 20 49 44 20 0a 75 69 6e 74 33 32 asing ID .uint32 96 05f0 20 73 65 71 0a 23 54 77 6f 2d 69 6e 74 65 67 65 seq.#Two-intege 97 0600 72 20 74 69 6d 65 73 74 61 6d 70 20 74 68 61 74 r timestamp that 98 0610 20 69 73 20 65 78 70 72 65 73 73 65 64 20 61 73 is expressed as 99 0620 3a 0a 23 20 2a 20 73 74 61 6d 70 2e 73 65 63 3a :.# * stamp.sec: 100 0630 20 73 65 63 6f 6e 64 73 20 28 73 74 61 6d 70 5f seconds (stamp_ 101 0640 73 65 63 73 29 20 73 69 6e 63 65 20 65 70 6f 63 secs) since epoc 102 0650 68 20 28 69 6e 20 50 79 74 68 6f 6e 20 74 68 65 h (in Python the 103 0660 20 76 61 72 69 61 62 6c 65 20 69 73 20 63 61 6c variable is cal 104 0670 6c 65 64 20 27 73 65 63 73 27 29 0a 23 20 2a 20 led 'secs ').# * 105 0680 73 74 61 6d 70 2e 6e 73 65 63 3a 20 6e 61 6e 6f stamp.nsec: nano 106 0690 73 65 63 6f 6e 64 73 20 73 69 6e 63 65 20 73 74 seconds since st 107 06a0 61 6d 70 5f 73 65 63 73 20 28 69 6e 20 50 79 74 amp_secs (in Pyt 108 06b0 68 6f 6e 20 74 68 65 20 76 61 72 69 61 62 6c 65 hon the variable 109 06c0 20 69 73 20 63 61 6c 6c 65 64 20 27 6e 73 65 63 is called 'nsec 110 06d0 73 27 29 0a 23 20 74 69 6d 65 2d 68 61 6e 64 6c s').# time -handl 111 06e0 69 6e 67 20 73 75 67 61 72 20 69 73 20 70 72 6f ing sugar is pro 112 06f0 76 69 64 65 64 20 62 79 20 74 68 65 20 63 6c 69 vided by the cli 113 0700 65 6e 74 20 6c 69 62 72 61 72 79 0a 74 69 6d 65 ent library.time 114 0710 20 73 74 61 6d 70 0a 23 46 72 61 6d 65 20 74 68 stamp.#Frame th 115 0720 69 73 20 64 61 74 61 20 69 73 20 61 73 73 6f 63 is data is assoc 116 0730 69 61 74 65 64 20 77 69 74 68 0a 73 74 72 69 6e iated with.strin 117 0740 67 20 66 72 61 6d 65 5f 69 64 0a 0a 3d 3d 3d 3d g frame_id..==== 118 0750 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ 119 0760 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ 120 0770 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ 121 0780 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ 122 0790 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 4d 53 47 ============.MSG 123 07a0 3a 20 73 65 6e 73 6f 72 5f 6d 73 67 73 2f 50 6f : sensor_msgs/Po 124 07b0 69 6e 74 46 69 65 6c 64 0a 23 20 54 68 69 73 20 intField.# This 125 07c0 6d 65 73 73 61 67 65 20 68 6f 6c 64 73 20 74 68 message holds th 126 07d0 65 20 64 65 73 63 72 69 70 74 69 6f 6e 20 6f 66 e description of 127 07e0 20 6f 6e 65 20 70 6f 69 6e 74 20 65 6e 74 72 79 one point entry 128 07f0 20 69 6e 20 74 68 65 0a 23 20 50 6f 69 6e 74 43 in the.# PointC 129 0800 6c 6f 75 64 32 20 6d 65 73 73 61 67 65 20 66 6f loud2 message fo 130 0810 72 6d 61 74 2e 0a 75 69 6e 74 38 20 49 4e 54 38 rmat..uint8 INT8 131 0820 20 20 20 20 3d 20 31 0a 75 69 6e 74 38 20 55 49 = 1.uint8 UI 132 0830 4e 54 38 20 20 20 3d 20 32 0a 75 69 6e 74 38 20 NT8 = 2.uint8 133 0840 49 4e 54 31 36 20 20 20 3d 20 33 0a 75 69 6e 74 INT16 = 3.uint 134 0850 38 20 55 49 4e 54 31 36 20 20 3d 20 34 0a 75 69 8 UINT16 = 4.ui 135 0860 6e 74 38 20 49 4e 54 33 32 20 20 20 3d 20 35 0a nt8 INT32 = 5. 136 0870 75 69 6e 74 38 20 55 49 4e 54 33 32 20 20 3d 20 uint8 UINT32 = 137 0880 36 0a 75 69 6e 74 38 20 46 4c 4f 41 54 33 32 20 6.uint8 FLOAT32 138 0890 3d 20 37 0a 75 69 6e 74 38 20 46 4c 4f 41 54 36 = 7.uint8 FLOAT6 139 08a0 34 20 3d 20 38 0a 0a 73 74 72 69 6e 67 20 6e 61 4 = 8..string na 131
140 08b0 6d 65 20 20 20 20 20 20 23 20 4e 61 6d 65 20 6f me # Name o 141 08c0 66 20 66 69 65 6c 64 0a 75 69 6e 74 33 32 20 6f f field.uint32 o 142 08d0 66 66 73 65 74 20 20 20 20 23 20 4f 66 66 73 65 ffset # Offse 143 08e0 74 20 66 72 6f 6d 20 73 74 61 72 74 20 6f 66 20 t from start of 144 08f0 70 6f 69 6e 74 20 73 74 72 75 63 74 0a 75 69 6e point struct.uin 145 0900 74 38 20 20 64 61 74 61 74 79 70 65 20 20 23 20 t8 datatype # 146 0910 44 61 74 61 74 79 70 65 20 65 6e 75 6d 65 72 61 Datatype enumera 147 0920 74 69 6f 6e 2c 20 73 65 65 20 61 62 6f 76 65 0a tion , see above. 148 0930 75 69 6e 74 33 32 20 63 6f 75 6e 74 20 20 20 20 uint32 count 149 0940 20 23 20 48 6f 77 20 6d 61 6e 79 20 65 6c 65 6d # How many elem 150 0950 65 6e 74 73 20 69 6e 20 74 68 65 20 66 69 65 6c ents in the fiel 151 0960 64 0a 12 00 00 00 74 6f 70 69 63 3d 2f 70 63 6c d..... topic=/pcl 152 0970 5f 63 68 61 74 74 65 72 1c 00 00 00 74 79 70 65 _chatter....type 153 0980 3d 73 65 6e 73 6f 72 5f 6d 73 67 73 2f 50 6f 69 =sensor_msgs/Poi 154 0990 6e 74 43 6c 6f 75 64 32 ntCloud2 Code B.1: Complete PointCloud2 response connection header sent by the Publisher 1message_definition=# This message holds a collection of N-dimensional points , which may 2# contain additional information such as normals , intensity , etc. The 3# point data is stored as a binary blob , its layout described by the 4# contents of the "fields" array. 5 6# The point cloud data may be organized 2d (image -like) or 1d 7# (unordered). Point clouds organized as 2d images may be produced by 8# camera depth sensors such as stereo or time-of-flight. 9 10 # Time of sensor data acquisition , and the coordinate frame ID (for 3d 11 # points). 12 Header header 13 14 # 2D structure of the point cloud. If the cloud is unordered , height is 15 # 1 and width is the length of the point cloud. 16 uint32 height 17 uint32 width 18 19 # Describes the channels and their layout in the binary data blob. 20 PointField[] fields 21 22 bool is_bigendian # Is this data bigendian? 23 uint32 point_step # Length of a point in bytes 24 uint32 row_step # Length of a row in bytes 25 uint8[] data # Actual point data , size is (row_step*height) 26 27 bool is_dense # True if there are no invalid points 28 29 ============================================================================ 132
Appendix B. ROS PointCloud2 Message 30 MSG: std_msgs/Header 31 # Standard metadata for higher -level stamped data types. 32 # This is generally used to communicate timestamped data 33 # in a particular coordinate frame. 34 # 35 # sequence ID: consecutively increasing ID 36 uint32 seq 37 #Two-integer timestamp that is expressed as: 38 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs ') 39 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs ') 40 # time -handling sugar is provided by the client library 41 time stamp 42 #Frame this data is associated with 43 string frame_id 44 45 ============================================================================ 46 MSG: sensor_msgs/PointField 47 # This message holds the description of one point entry in the 48 # PointCloud2 message format. 49 uint8 INT8 = 1 50 uint8 UINT8 = 2 51 uint8 INT16 = 3 52 uint8 UINT16 = 4 53 uint8 INT32 = 5 54 uint8 UINT32 = 6 55 uint8 FLOAT32 = 7 56 uint8 FLOAT64 = 8 57 58 string name # Name of field 59 uint32 offset # Offset from start of point struct 60 uint8 datatype # Datatype enumeration , see above 61 uint32 count # How many elements in the field Code B.2: PointCloud2 connection header message_definition . Lines 29 and 45 where slightly adjusted to fit the page (4 “=” characters were removed from each line). 133