Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scattering doesnt work for more complex scenarios #207

Closed
AbdolvakilFazli opened this issue Aug 25, 2023 · 18 comments
Closed

Scattering doesnt work for more complex scenarios #207

AbdolvakilFazli opened this issue Aug 25, 2023 · 18 comments

Comments

@AbdolvakilFazli
Copy link

AbdolvakilFazli commented Aug 25, 2023

I was excited to see that you added scattering to Sionna. But it only works with the tutorial example.
But using another scene such as Munich when Scattering =True , it just doesn't work.
I see the following error:

InvalidArgumentError: {{function_node __wrapped__GatherV2_device_/job:localhost/replica:0/task:0/device:CPU:0}} indices[1,0,0,0] = -1 is not in [0, 38938) [Op:GatherV2] name: 
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

Just change the scene to street_canyon , you will see there is a scattering path but with

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
import os # Configure which GPU
gpu_num = 0 # Use "" to use the CPU
os.environ["CUDA_VISIBLE_DEVICES"] = f"{gpu_num}"
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
try: 
    import google.colab
    colab_compat = True # deactivate preview
except:
    colab_compat = False
resolution = [480,320] # increase for higher quality of renderings

class ExitCell(Exception):
    def _render_traceback_(self):
        pass
try:
    import sionna
except ImportError as e:
    # Install Sionna if package is not already installed
    import os
    os.system("pip install sionna")
    import sionna

import tensorflow as tf
gpus = tf.config.list_physical_devices('GPU')
if gpus:
    try:
        tf.config.experimental.set_memory_growth(gpus[0], True)
    except RuntimeError as e:
        print(e)
tf.get_logger().setLevel('ERROR')

tf.random.set_seed(1) # Set global random seed for reproducibility

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import sys

from sionna.channel import cir_to_time_channel
from sionna.rt import load_scene, PlanarArray, Transmitter, Receiver, RadioMaterial, Camera, LambertianPattern, DirectivePattern, BackscatteringPattern
from sionna.rt.utils import r_hat
from sionna.constants import PI, SPEED_OF_LIGHT
from sionna.utils import expand_to_rank


scene = load_scene(sionna.rt.scene.munich)

scene.tx_array = PlanarArray(num_rows=1,
                             num_cols=1,
                             vertical_spacing=0.5,
                             horizontal_spacing=0.5,
                             pattern="iso",
                             polarization="V")

scene.rx_array = scene.tx_array

dist = 5
d = dist/np.sqrt(2)
scene.add(Transmitter(name="tx", position=[10*d,25*d,d/3]))
scene.add(Receiver(name="rx", position=[10.2*d,25*d,d/3]))

scene.add(Camera("my_cam", position=[0, -30, 20], look_at=[0,0,3]))

if colab_compat:
    scene.render("my_cam");
    raise ExitCell
scene.preview()

% scene.get("reflector").radio_material.scattering_coefficient = 0.5

paths = scene.compute_paths(num_samples=20, los=False, reflection=False, scattering=True, scat_keep_prob=1)
print(f"There are {tf.size(paths.a).numpy()} scattered paths.")


scene.preview(paths=paths)
@AbdolvakilFazli
Copy link
Author

AbdolvakilFazli commented Aug 25, 2023

Just checked more, interesting that also with street_canyon scene,
when

scene.add(Transmitter(name="tx", position=[10*d,25*d,d/3]))
scene.add(Receiver(name="rx", position=[10.2*d,25*d,d/3]))

which is outside the scene, we have a scattering path
while with

scene.add(Transmitter(name="tx", position=[-2*d,0*d,15*d]))
scene.add(Receiver(name="rx", position=[-2.2*d,0*d,15*d]))

we have the same error.

@faycalaa
Copy link
Collaborator

faycalaa commented Aug 28, 2023

Hi,

I cannot reproduce this error with the latest version of Sionna.

Are you using version 0.15.1? It seems that you are having the same issue as #174

@AbdolvakilFazli
Copy link
Author

Yes, Thank you very much.
I had to first upgrade the conda.
But the path coefficients are equal to zero. I saw an example in tutorial where the scattering_coefficient / pattern of the simple reflector has been modified.
I'm using the Munich site. Do I have to do this for every single material?
Also, for a self created environment, is it possible to modify these coefficients from the code itself automatically or through blender?

@faycalaa
Copy link
Collaborator

Hi,

To configure the properties of radio materials, you'll need to use the Sionna API (not Blender), and to specifically modify each radio material whose properties you wish to change.

For instance, if you're looking to modify the scattering coefficients for all radio materials within a scene, you can execute the following code snippet:

for rm in scene.radio_materials.values():
    if rm.is_used:
        rm.scattering_coefficient = 0.3

The is_used flag of a radio material is set to True when at least one object in the scene uses this radio material.

@AbdolvakilFazli
Copy link
Author

Thank you very much. So, does this mean that now we could do sensing with Sionna?
For example, for monostatic sensing (where Tx and Rx are co-located) one can put them at the same location and ignore the LoS link, We have the reflected and backscattered waves.
It would be nice if you could also include the Radar cross section (RCS).

@jhoydis
Copy link
Collaborator

jhoydis commented Sep 14, 2023

I think that you could do sensing with Sionna.
However, we currently do not have objects that scatter based on an RCS.

@AbdolvakilFazli
Copy link
Author

Okay, Thank you very much

@AbdolvakilFazli
Copy link
Author

AbdolvakilFazli commented Sep 27, 2023

Hi,
Just reopened this thread as more questions are coming
So, I tried to plot the range-velocity.
The scenarios include a moving box (itu_marble), a concrete plane surface, and co-located tx and rx (monostatic sensing). Instead of using Apply_doppler function, the position of the box changes in a "for loop" as a function of time to simulate one single OFDM frame where:
- t in np.arange(0,M_symbols*T_OFDM,T_OFDM)

Attached are two plots for two scenarios: only reflection and only scattering. In both plots, I made sure that we only had one reflection/scattering and making sure that we didn't have a reflection/scattering from the concrete plane (ground) by adjusting the scattering coefficient to 1/0.

In the first plot, where the effect of one reflection path is considered, you see that the delay-doppler is well plotted and the range and velocity values match with the actual scenario parameters.

In the second plot, where the effect of one scattering path is considered, you see that the Doppler cannot be seen.

The only difference that I saw is that the paths.a coefficient in the case where reflection is enabled (scattering_coeff=0) is
almost 1e6 times bigger than the case where scattering is enabled (i.e. scattering_coeff=0).

Do you know what could be the reason? is it related to Sionna? I tried to change many things including modifying the radio material properties(scattering coeff, permittivity, conductivity, scattering pattern, etc.) And even scaled this coefficient but no luck.

Note: apply_doppler function is doing great when it comes to a single object scenario, but when more complex (multiple objects for example even if only one is mobile) it really doesn't give you what you expected.
(url)
RefResult
ScatResult

@jhoydis
Copy link
Collaborator

jhoydis commented Sep 29, 2023

Hi,

I am just guessing, but it could be because the phases of the scattered paths are chosen at random. You would need to modify a line in the source code to avoid that this happens or might want to try to set TensorFlow’s random seed to the same value just before calling the function to compute the paths.

If this does not work, you would need to paste the code for a minimal example.

@jhoydis
Copy link
Collaborator

jhoydis commented Oct 2, 2023

I am not sure if I understand your last comment:

Note: apply_doppler function is doing great when it comes to a single object scenario, but when more complex (multiple objects for example even if only one is mobile) it really doesn't give you what you expected. (url)

The apply_doppler function adds mobility to the transmitters and/or receivers not to any objects. Could you provide a minimal scenario where it fails to do what you expect?

@AbdolvakilFazli
Copy link
Author

AbdolvakilFazli commented Oct 6, 2023

Hi,
Sorry for the late response, I spent a little time recreating the scene and have a closer look.
With the first comment, you are right. To see the Doppler effect, as we are interested in relative phase, it is enough to fix the seed value before compute_path.
For the second comment: as I am implementing a monostatic sensing scenario, whe
re the tx and rx are colocated, using Apply_doppler function in Sionna:

  1. it seems that we cannot define a scenario with a multi-object scenario where each object moving with a different velocity
  2. again, I cannot see the expected result in the range-doppler plot.
    I attached an example showing this. You can add your path in the variable "pathAd" and you can switch the Apply_doppler_util to True or False to see the difference.
    Especially for the second cube (which comes from the angle), we don't actually see the doppler.
    SensingSionna.zip

@jhoydis
Copy link
Collaborator

jhoydis commented Nov 29, 2023

Can you try this with release v0.16?

@jhoydis jhoydis closed this as completed Nov 29, 2023
@jhoydis jhoydis reopened this Nov 29, 2023
@AbdolvakilFazli
Copy link
Author

Hi again,
Thank you for the new version; it is quite intriguing.

I tried it in my code, didn't work.
In the scenario I've set up, there are two objects with different velocities. Given that the apply_doppler() function incorporates the velocities of both the tx and rx, I don't expect accurate velocity estimation for individual objects. It would be beneficial if there were an option to assign a specific velocity to each object.

Nevertheless, a workaround is to manually move the objects and observe how the CIR changes without relying on the apply_doppler function :)

@jhoydis
Copy link
Collaborator

jhoydis commented Jan 25, 2024

Hi, adding velocity vectors to individual objects is a feature that we might consider for a future Sionna release.
Is there any concrete issue/bug that you are facing in your current setup?

@AbdolvakilFazli
Copy link
Author

Hi,
I managed to change the location of some objects in a created scene with the Mitsuba package, so far so good.
There is no bug comes to my mind,
thank you again for all the efforts,
Bests

@jhoydis jhoydis closed this as completed Jan 25, 2024
@AbdolvakilFazli
Copy link
Author

AbdolvakilFazli commented Feb 28, 2024

Hi,
If an object moves from point A to B within a short time of delta_t, is there any way to figure out which paths are repeated or disappeared during the two snapshots at A and B?
do you associate a path ID or something similar so that one could track such changes?

@faycalaa
Copy link
Collaborator

faycalaa commented Mar 1, 2024

Hi,

There is no path ID that uniquely identifies paths.

To uniquely identify paths, you might consider using their angle of arrival and departure (properties theta_r, phi_r, theta_t, phi_t of Paths). You could also use the sequence of intersected objects or the sequence of intersection points with the scene. It's important to note, however, that these attributes could vary over time in scenarios involving mobility for the same path.

Hope this helps.

@AbdolvakilFazli
Copy link
Author

AbdolvakilFazli commented Mar 1, 2024

Thank you very much,
I used the former method which seems to work, at least for max_depth=1
But it would be great if you associate a path ID to every ray that is shooted. or an array of bolean value. This will help alot with complex scenarios as well as multipath.
Bests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants