NVlabs / sionna

Sionna: An Open-Source Library for Next-Generation Physical Layer Research
https://nvlabs.github.io/sionna
Other
787 stars 224 forks source link

How can I load an integrated scene created in Blender and execute it using Google Colab? #525

Closed alialsahlany closed 2 months ago

alialsahlany commented 3 months ago

I've created a 3D scene using Blender and exported it as an XML file. I want to load this scene and run a simulation or preview a Google Colab environment.

However, I encountered the following error:

Error loading scene with Mitsuba: ​[xml.cpp:1079] Error while loading "/content/mecca.xml" (near line 38, col 3): could not instantiate shape plugin of type "ply": [xml.cpp:1079]   [PLYMesh] Error while loading PLY file "Plane.ply": file not found!
merlinND commented 3 months ago

Hello @alialsahlany,

  1. Did you make sure to copy over the full exported scene, including the .ply files representing the meshes? If you only copy over the XML file to Colab, the meshes will be missing.
  2. Does it work when trying locally?
alialsahlany commented 3 months ago

Hello @merlinND Thank you for your help. I have organized and uploaded the files as shown in the image. However, I still cannot display the scene. Although the scene works fine locally. Capture

merlinND commented 3 months ago

Hello @alialsahlany,

I still cannot display the scene

After organizing and uploading the files as shown in the image, do you still encounter the same error as before? Without knowing precisely what error message or what is being displayed, it is difficult to help.

If you encounter new symptoms, please have a look at this existing discussion about the Preview renderer on Colab: https://github.com/NVlabs/sionna/discussions/452

alialsahlany commented 3 months ago

I have looked at #452 discussion about the Preview renderer on Colab but did not get a new result. I still cannot preview the scene. This is the scene [mecca.rar] used; can you check it?

merlinND commented 3 months ago

Hello @alialsahlany,

As I said before, without knowing precisely what error message or what is being displayed, it is difficult to help. Please give a full description of what you are trying, what you are seeing, what is printed to the dev console, etc.

alialsahlany commented 2 months ago

Steps I followed

################################################### !pip install --upgrade tensorflow #################################################### !pip install --upgrade mitsuba ####################################################### !pip install --upgrade drjit ######################################################### !pip install --upgrade sionna ###############################################################################

Import necessry functions

import os from importlib_resources import files import numpy as np import matplotlib import matplotlib.pyplot as plt import time import drjit as dr import mitsuba as mi mi.set_variant('scalar_rgb') os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' print("Current working directory:", os.getcwd()) import tensorflow as tf import sionna ##########################################################

Import Sionna RT components

from sionna.rt import load_scene, RadioMaterial, Transmitter, Receiver, PlanarArray, Camera from sionna.channel import cir_to_ofdm_channel, subcarrier_frequencies, OFDMChannel, ApplyOFDMChannel, CIRDataset from sionna.nr import PUSCHConfig, PUSCHTransmitter, PUSCHReceiver from sionna.utils import compute_ber, ebnodb2no, PlotBER from sionna.ofdm import KBestDetector, LinearDetector from sionna.mimo import StreamManagement ############################################################################### file_path = "/content/mecca.xml" if os.path.exists(file_path): print("File exists.") else: print(f"File not found: {file_path}") ################################################################################ scene = sionna.rt.load_scene('/content/mecca.xml') scene.preview() ###############################################

After executing the last command, the errors appear in the message below.

errore

alialsahlany commented 2 months ago

Many thanks for your help; I found the solution by using the following code:

scene = sionna.rt.load_scene('/content/mecca.xml')
scene.add(Camera("cam-0", position=[50,0,130], look_at=[10,0,0]))
if colab_compat:
    scene.render(camera="cam-0", num_samples=256);
center = np.array([0.0, 0.0, 10.206510543823242])  # Replace with the actual center coordinates
scene.preview(look_at=center)
#scene.preview()
merlinND commented 2 months ago

Thanks for posting this workaround @alialsahlany. In principle the instructions in https://github.com/NVlabs/sionna/discussions/452#discussioncomment-9616921 should also fix the issue, but your version is certainly simpler.