scieee AI-readable full text Open interactive document viewer

A 3D terrain generator: Enhancing robotics simulations with GANs

Arellano García, Silvia,Otero Calviño, Beatriz,Kucner, Tomasz Piotr,Canal Corretger, Ramon

Abstract

Simulation is essential in robotics to evaluate models and techniques in a controlled setting before conducting experiments on tangible agents. However, developing simulation environments can be a challenging and time-consuming task. To address this issue, a proposed solution involves building a functional pipeline that generates 3D realistic terrains using Generative Adversarial Networks (GANs). By using GANs to create terrain, the pipeline can quickly and efficiently generate detailed surfaces, saving researchers time and effort in developing simulation environments for their experiments. The proposed model utilizes a Deep Convolutional Generative Adversarial Network (DCGAN) to generate heightmaps, which are trained on a custom database consisting of real heightmaps. Furthermore, an Enhanced Super-Resolution Generative Adversarial Network (ESRGAN) is used to improve the resolution of the resulting heightmaps, enhancing their visual quality and realism. To generate a texture according to the topography of the heightmap, chroma keying is used with previously selected textures. The heightmap and texture are then rendered and integrated, resulting in a realistic 3D terrain. Together, these techniques enable the model to generate high-quality, realistic 3D terrains for use in robotic simulators, allowing for more accurate and effective evaluations of robotics models and techniques.

Full text

A 3D Terrain Generator: Enhancing Robotics Simulations with GANs Silvia Arellano1, Beatriz Otero1, Tomasz Piotr Kucner2, and Ramon Canal1 1Universitat Polit`ecnica de Catalunya, Barcelona, Spain {[email protected], [email protected], [email protected]} 2Aalto University, Finland [email protected] Abstract. Simulation is essential in robotics to evaluate models and techniques in a controlled setting before conducting experiments on tangible agents. However, developing simulation environments can be a challenging and time-consuming task. To address this issue, a proposed solution involves building a functional pipeline that generates 3D realistic terrains using Generative Adversarial Networks (GANs). By using GANs to create terrain, the pipeline can quickly and efficiently generate detailed surfaces, saving researchers time and effort in developing simulation environments for their experiments. The proposed model utilizes a Deep Convolutional Generative Adversarial Network (DCGAN) to generate heightmaps, which are trained on a custom database consisting of real heightmaps. Furthermore, an Enhanced Super-Resolution Generative Adversarial Network (ESRGAN) is used to improve the resolution of the resulting heightmaps, enhancing their visual quality and realism. To generate a texture according to the topography of the heightmap, chroma keying is used with previously selected textures. The heightmap and texture are then rendered and integrated, resulting in a realistic 3D terrain. Together, these techniques enable the model to generate high-quality, realistic 3D terrains for use in robotic simulators, allowing for more accurate and effective evaluations of robotics models and techniques. Keywords: GAN ·Terrain rendering ·3D image generation ·Robotics simulators ·Sim2Real 1 Introduction Simulation plays a crucial role in robotics by providing a controlled setting for testing algorithms and prototypes before conducting experiments on physical agents. These tools allow researchers to test robots in unusual, inaccessible, or even impossible scenarios, improving safety and performance. However, developing 3D virtual environments is a demanding and time-consuming task. These environments have become increasingly complex and detailed over the years, making the process even more challenging. To enhance the user’s experience and This version of the contribution has been accepted for publication, after peer review but is not the Version of Record and does not reflect post-acceptance improvements, or any corrections. The Version of Record is available online at: http://dx.doi.org/10.1007/978-3-031-53969-5_17. Use of this Accepted Version is subject to the publisher's Accepted Manuscript terms of use http://www.spingernature.com/gp/open-research/policies/accepted-manuscript-terms 2 S. Arellano et al. generate more realistic environments, researchers have been exploring procedural modeling as an ongoing line of research in recent years. [19] Procedural modeling is a well-established technique in the video game industry, used in popular games like Minecraft [12] to generate diverse, never-ending worlds. Some commercial applications related to animation and video games provide users with the ability to procedurally generate landscapes and scenes for games and driving simulations. However, there is a lack of applications for automatic scenario generation prepared to be applied in robotics or robotics simulators. The requirements for 3D virtual environments in robotics are often different from those in video games or other industries. In robotics, the environments must be physically accurate and realistic to ensure that the results obtained in simulation can be extrapolated to real-world scenarios. This level of fine-tuning requires a high degree of control over the environment and the models used, which is often not possible with traditional terrain modeling techniques. This paper proposes a complete pipeline to generate a realistic terrain, including both mesh and texture. Besides, the output of this pipeline aims to make it easy for the user to apply various surface parameters in each zone of the mesh based on the terrain type. These parameters, such as friction, contact forces, and other critical factors in robotics, are essential for achieving accurate simulations. The pipeline is divided into four primary components, detailed in Figure 1. The first component involves heightmap generation, which is critical for obtaining a realistic mesh. This will be further explained in section 3. Enhancing the quality of the heightmap is essential for rendering a terrain precisely. For that reason, a super resolution algorithm is applied, increasing four times the original resolution of the image. This procedure is explained in section 4. Once the heightmap is generated and improved, the third component of the pipeline focuses on generating a texture that meets the user’s requirements and is consistent with the generated map’s topography. The user is expected to specify how many textures should be combined and how the combination should be done. After that, the system generates the texture. This procedure will be further amplified in section 5. Finally, the output from the previous steps is integrated by rendering the heightmap to obtain a mesh, which is then combined with the texture. The resulting mesh is then exported and can be used in any preferred robotic simulator. The integration step is further explained in Section 6. Fig. 1. workflow pipeline of the 3D terrain generator, showing the various stages involved in generating a terrain from scratch. A 3D Terrain Generator: Enhancing Robotics Simulations with GANs 3 The main contributions of this work are the following: –Creation of an open-source heightmap dataset by extracting data directly from various online sources, as there was no comprehensive publicly available dataset at the time. –Selection of an appropriate combination of neural networks to achieve diverse and high quality resources. –A comparative analysis between the proposed pipeline and other existing techniques for generating 3D terrains for robotics simulations. –Development of a software capable of generating a wide range of combinations of shapes and terrains to provide robots with diverse training scenarios. The remainder of this paper is organized as follows. Section 2 provides a review of related work on procedural terrain generation. Section 3 and 4 illustrate the generation procedure of both meshes and textures, explaining the techniques and the Neural Network used in the process. Then, Sect. 5 presents the integration process, and Sect. 6 describes the potential uses and applications of this software in robotics. We draw the main conclusions in Sect. 7. 2 Background 2.1 Current terrain generation strategies The aim of procedural modeling is, instead of designing content by hand, to design a procedure that creates content automatically [19]. Some of its advantages include the reduction of cost and time needed for scene generation, a high level of detail in the output without human intervention and low memory requirements. However, the main drawbacks are the difficulty in manipulating and controlling the generation process and the significant amount of computational resources required [7,19]. Our proposal focuses on procedural modeling of outdoor terrain, which can be approached using three strategies: noise functions, erosion simulation, and texture synthesis. All of these strategies make use of height maps, which are a representation of a terrain’s surface as a grid of elevation values. The first way to generate new height maps is using bandwidth-limited noise functions like Perlin [16], which can capture the nature of mountainous structures. However, due to the randomness of these functions, manipulating the outcome and customizing it according to the user’s needs becomes a challenging task. Gasch et al. [6] use noise functions to generate arbitrary heights, and combine them with previously given artificial features, like figures or letters, in a way that the final result can be perceived as real. Another strategy for generating terrains is erosion simulation, which involves modifying the terrain using physics-based algorithms that aim to resemble natural phenomena. A renowned study in this field was carried out by Musgrave et al. [13], where they computed the surface erosion caused by water, by considering the quantity of water that would accumulate at each vertex of a fractal height field and the impact of thermal weathering. 4 S. Arellano et al. The last procedure considered is texture synthesis, which aims to generate new surfaces by studying and finding patterns in existing terrains. In this way, it can capture their realism, so that they obtain compelling results. Panagiotou et al. [15] used a combination of GAN and Conditional GAN (cGAN) to create images that resemble satellite images and Digital Elevation Models that can match the output of the first GAN. Our approach can be included in the last type of procedure, as we use a Deep Convolutional Generative Adversarial Network (DCGAN), a type of generative model that has shown great success in generating high-quality images, to create heightmaps of terrain that will be rendered as 3D meshes. We combine this method with an Enhanced Super-Resolution Generative Adversarial Network (ESRGAN) to improve the quality of the generated samples, and a technique that is based on chroma keying to assign different textures to the terrain depending on its height. 2.2 Related existing applications In recent years, we can observe a rapid acceleration in research on data-driven methods across multiple fields. However, they are heavily dependent on the amount of available data. As mentioned before, there is a lack of applications for automatic scenario generation in the context of robotics or robotics simulators. Nevertheless, there are similar approaches in the field of video games and animation. Some remarkable commercial applications in this fields are Procedural Worlds [2], which provides Unity [24] users with the ability to procedurally generate landscapes and scenes for games and driving simulation, and iClone 8 [17], a 3D animation software with a special focus on nature terrain generation. There are also several design programs available, such as Terragen [21], and E-on Vue [20], that allow users to create computer-generated environments. Nevertheless, these programs require expertise in 3D design tools and lack the automatic generation feature that our tool aims to provide. 3 Heightmap generation The first step in the pipeline aims to create a terrain mesh. To create varied surfaces, this approach takes advantage of heightmaps, which are grayscale images that represent the elevation of a terrain and can be transformed into 3D surfaces once they are rendered. Although these images are in grayscale, we chose to represent them in the RGB color space for our dataset. Our objective for this part of the pipeline is to generate diverse and realistic heightmaps while avoiding those that resemble flat planes with little height variation, as they may not be of great interest. For this purpose, we have studied two different methods: unconditional image generation with diffusion models and Generative Adversarial Networks (GANs). On the one hand, Denoising Diffusion Probabilistic Models (DDPM), also known as diffusion models, were introduced by Ho et al. [10]. A DDPM is a A 3D Terrain Generator: Enhancing Robotics Simulations with GANs 5 generative model used to produce samples that match a given dataset within a finite time. The diffusion model consists of two processes: a forward diffusion process that gradually adds Gaussian noise during several timesteps to the input data until the signal has become completely noisy, and a reverse denoising process that learns to generate data by removing the noise added in the forward process. The diffusion process uses small amounts of Gaussian noise, which allows for a simple neural network parameterization. Diffusion models are known for their efficiency in training and their ability to capture the full diversity of the data distribution. However, generating new data samples with a diffusion model requires the model to be forward-passed through the diffusion process several times, which can be computationally expensive and result in a slower process compared to GANs. In contrast, GANs only require one pass through the generator network to generate new data samples, making them faster and less computationally expensive for this particular task. However, it is important to remark that the computational efficiency of both models can vary depending on factors such as dataset size, model complexity, and implementation details. On the other hand, GANs, first proposed by Goodfellow et al. in [8], are a type of neural network architecture that include two models: a generator and a discriminator. The generator creates fake data that is meant to be similar to the real data, while the discriminator tries to differentiate between the real and fake data. The objective of the generator is to create synthetic images so that the discriminator perceives them as real. In this study, we utilized Deep Convolutional GANs (DCGANs) to generate heightmaps. The model used in this study was adapted from the code provided by Tang’s DCGAN256 repository on GitHub [22]. As one of our goals is to make this tool practical and accessible to a wide range of users, we have chosen to prioritize the use of GANs over DDPM for our task. By doing so, we aim to reduce the computational resources required and increase the speed of the generation process, which will make the software more efficient and agile. 3.1 Architecture of the GAN The GAN architecture utilizes a generator that receives a random noise vector of size 4096 as an input and transforms it into a fake heightmap with a size of 256x256x3. It is composed of eight transposed convolutional layers, as detailed in Figure 2. The discriminator in this study takes in images of size 256x256x3 and processes them through six convolutional layers, as shown in Figure 3. The output of the discriminator is a sigmoid activation function that indicates the probability of the input image being real or fake. 3.2 Obtention of the training data To ensure accurate results during neural network training, it is crucial to use a sufficient number of training samples that are diverse enough to avoid overfitting. However, as there were no open-source heightmap datasets available, we had 6 S. Arellano et al. Fig. 2. Structure of the DCGAN generator Fig. 3. Structure of the DCGAN discriminator to create our own. Our dataset consists of 1000 real heightmap images from various terrains worldwide. We obtained the images entirely from the web Cities: Skylines online heightmap generator [1] using web scraping techniques. Each heightmap represents an area of 17.28 km2and has a resolution of 1081 x 1081 px. To enhance efficiency and facilitate experimentation, we preprocess the samples before training. The images are initially represented with 16 bits per pixel, but we represent them with 8 bits in RGB format to achieve a reduced file size and ensure compatibility with a broader range of tools and software. Furthermore, to improve computer speed and efficiency, we reduce the resolution of the samples to 256 x 256 px. To avoid a biased dataset with too many plain terrains, which may be of less interest to users, we filter out images based on their standard deviation. To determine the threshold for plain terrains, we compute the standard deviation of a noise image and keep those images that have a standard deviation of 35% or more of that value. This way, we ensure the presence of plain terrains while maintaining diversity. A 3D Terrain Generator: Enhancing Robotics Simulations with GANs 7 3.3 Training After preprocessing the data, the GAN is trained using a learning rate of 10-4 and a batch size of 16. The GAN is trained for 75,000 steps, resulting in the losses and results displayed in Figure 4. The figure shows the losses from both the generator and the discriminator, differentiating between the cases when the discriminator is presented with real or fake images. In addition, the figure contains an example of each part of the training, which are detailed below. Fig. 4. Evolution of DCGAN losses over training epochs, along with representative images from each stage. From top to bottom, the figure displays the losses of the discriminator when given real data, the losses of the discriminator when given fake data, and the losses of the generator. The graph on Figure 4 illustrates that the discriminator and the generator play a min-max game, where if one of them decreases its loss, the other one will increase it. To explain this further, we can divide the training into three parts, separated by dashed lines on the plot. It’s worth noting that monitoring the loss values is primarily useful for tracking the GAN’s progress over the steps and ensuring that the training is not diverging, rather than measuring the improvement in the quality of the generated images. 8 S. Arellano et al. In the first part of the training (Part A), corresponding to the early steps of the training, the discriminator starts guessing randomly (since it hasn’t received enough training), causing an increase in its loss and a small value in the generator’s loss. In the second part (Part B), the rate of change in the losses becomes smoother, and the generated images start to become more realistic and clear, although there are still some areas with blurry patterns. Finally, in the latter part of the training (Part C), the losses become stable, and the generated images are realistic and visually diverse, which satisfies the requirements for our application. 3.4 Evaluation We aimed to evaluate the quality of the generated images using metrics commonly used in the image generation field, such as Inception Score (IS) and Fr´echet Inception Distance (FID). However, due to the nature of our images, neither of these metrics may be the most appropriate for our evaluation. The Inception Score (IS), defined by Salimans et al. [18] is an algorithm used to assess the quality of images created by a generative image model such as a generative adversarial network (GAN). It uses an Inception v3 Network pretrained on ImageNet and calculates a statistic of the network’s outputs when applied to generated images. As stated by Barratt et al. [3], in order to obtain a good IS, the images should be sharp. Besides, it is expected that the evaluated images belong to a great variety of classes in ImageNet. However, our images don’t belong to any of the ImageNet classes, and our dataset isn’t organized in classes, like the would IS expect. Therefore, the IS may not be the most appropriate metric to use for evaluating image quality. The FID, defined by Heusel et al. [9] is also used to assess the quality of images generated by a GAN. The FID quantifies the similarities between two image datasets by comparing their distributions, specifically by calculating the distance between feature vectors calculated for real and generated images. A lower FID indicates that the generated images are more similar to the real ones and hence indicates better image quality and a better model. We compared a dataset of 1000 real heightmaps with a dataset of 1000 generated heightmaps and obtained an FID score of 274.54, which suggests that the two datasets are not very similar. However, it’s important to note that the images in our datasets have a wide range of standard deviations, which can have an impact on the FID score. This is because FID measures the similarity between two sets of images based on their feature statistics, and the feature statistics used in FID computation are sensitive to variations in pixel intensities. Therefore, this would mean that in our case the FID score may not accurately reflect the visual similarity between the real and generated images. 4 Super resolution To render the result with the appropriate resolution, we studied two different methods of increasing the resolution of the heightmap, including ESRGAN pro- A 3D Terrain Generator: Enhancing Robotics Simulations with GANs 9 posed by Wang et al. [25] and bicubic interpolation. We evaluated the methods considering metrics such as the Peak Signal-to-Noise Ratio (PSNR) and the Structural Similarity Index (SSIM), defined below. PSNR = 20 log10 M AXI √MSE (1) MSE =1 n n X i=1 (xi−ˆxi)2(2) SSIM(x,y) = 2µxµy+C1 µ2 x+µ2 y+C1 +2σxy +C2 σ2 x+σ2 y+C2 (3) PSNR measures the ratio of the maximum possible power of a signal to the power of corrupting noise that affects the fidelity of its representation. In eq. (1), the maximum pixel value of the evaluated image is denoted as MAXI, with the minimum level assumed to be 0. The noise level is modelled as square root of Mean Squared Error (MSE). The Mean Squared Error (MSE) is given by equation 2, where xirepresents the value of a pixel in the original image and ˆxirepresents the corresponding pixel value in the processed image. A higher PSNR value indicates a lower level of noise in the reconstructed image, which in turn indicates a higher image quality. The SSIM compares the luminance, contrast, and structure of the two images by taking into account their mean values (µxand µy) and variances (σ2 xand σ2 y), as well as their covariance (σxy). It consists of two terms: the first term computes the similarity of the luminance and contrast between the two images, while the second term computes the similarity of their structure. The constants C1and C2 are used to avoid division by zero errors and are typically small positive values. A higher SSIM value indicates a higher similarity between the two images. We evaluated the algorithms using a real heightmap database consisting of 1000 1024 x 1024 pixel heightmaps that were previously downsized to 256 pixels. These downsized images represent examples of images that could potentially have been generated by the GAN model. We intentionally downsized the images to evaluate the ability of the enhancing techniques and the quality of the results when working with lower resolution images. Both algorithms were employed to enhance these downsized images and restore them to their original size. The evaluation results indicate that, in 54% of cases, bicubic interpolation outperformed ESRGAN with an average difference of 0.5dB. Even though most images generated by ESRGAN are acceptable, it occasionally produced small unexpected artifacts, such as regions with colored pixels, as it can be seen in the example of Figure 5(a), which resulted in slight lumps or peaks in the final mesh and a decrease of up to 9 dB in the PSNR, like in Figure 5(b). Only a 1.2% of the images had a significant impact. The difference in SSIM values between the two techniques was found to be on the order of 10-3. The time taken to produce results was also considered, with bicubic interpolation taking 2 minutes and ESRGAN taking less than a second.