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

Issue with apply_doppler ? #222

Closed
jj6142 opened this issue Sep 28, 2023 · 3 comments
Closed

Issue with apply_doppler ? #222

jj6142 opened this issue Sep 28, 2023 · 3 comments

Comments

@jj6142
Copy link

jj6142 commented Sep 28, 2023

Hello,

I have been playing with Sionna ray tracer and tried to follow this guide:
https://nvlabs.github.io/sionna/examples/Sionna_Ray_Tracing_Introduction.html
The code there works fine as is and let's have it as starting point.

First, I try to add two more receivers by adding these lines to cell 6:
rx2 = Receiver(name="rx2",
position=[25,90,1.5],
orientation=[0,0,0])
scene.add(rx2)
rx3 = Receiver(name="rx3",
position=[35,70,1.5],
orientation=[0,0,0])
scene.add(rx3)
This is still fine. But when I try to modify apply_doppler such that each RX has their own velocity by modifying apply_doppler call in cell 13 like this:

rx_vel=tf.convert_to_tensor([[0,0,0],[1,0,1],[0,1,2]])
rx_vel=rx_vel[tf.newaxis,...]
print('rx_vel',rx_vel.shape) # this gives (1, 3, 3)

paths.apply_doppler(sampling_frequency=subcarrier_spacing,
num_time_steps=14, tx_velocities=[0,0,0], rx_velocities=rx_vel)

I will get the following error at the end. The dimension of rx_vel should be correct (I assume that dimension for rx_velocities should be [batch_size, num_rx, 3] and not [batch_size, num_tx, 3] as in the documentation.

Do I miss something?


InvalidArgumentError Traceback (most recent call last)
Cell In[27], line 10
8 print('rx_vel',rx_vel.shape)
9 # Apply Doppler shifts
---> 10 paths.apply_doppler(sampling_frequency=subcarrier_spacing, # Set to 15e3 Hz
11 num_time_steps=14, # Number of OFDM symbols
12 tx_velocities=[0,0,0], # We can set additional tx speeds
13 rx_velocities=rx_vel) # Or rx speeds
15 print("Shape of a after applying Doppler shifts: ", paths.a.shape)
17 a, tau = paths.cir()

File ~/python/miniconda3/envs/tf213/lib/python3.9/site-packages/sionna/rt/paths.py:427, in Paths.apply_doppler(self, sampling_frequency, num_time_steps, tx_velocities, rx_velocities)
422 # Compute the Doppler shift
423 # [batch_dim, num_rx, num_rx_ant, num_tx, num_tx_ant, max_num_paths]
424 # or
425 # [batch_dim, num_rx, 1, num_tx, 1, max_num_paths]
426 tx_ds = two_pidot(tx_velocities, k_t)/self._scene.wavelength
--> 427 rx_ds = two_pi
dot(rx_velocities, k_r)/self._scene.wavelength
428 ds = tx_ds + rx_ds
429 # Expand for the time sample dimension
430 # [batch_dim, num_rx, num_rx_ant, num_tx, num_tx_ant, max_num_paths, 1]
431 # or
432 # [batch_dim, num_rx, 1, num_tx, 1, max_num_paths, 1]

File ~/python/miniconda3/envs/tf213/lib/python3.9/site-packages/sionna/rt/utils.py:247, in dot(u, v, keepdim)
224 def dot(u, v, keepdim=False):
225 r"""
226 Computes and the dot (or scalar) product between u and v
227
(...)
245 is set to False.
246 """
--> 247 res = tf.linalg.matvec(tf.expand_dims(u, -2), v)
248 if not keepdim:
249 res = tf.squeeze(res,axis=-1)

File ~/python/miniconda3/envs/tf213/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py:153, in filter_traceback..error_handler(*args, **kwargs)
151 except Exception as e:
152 filtered_tb = _process_traceback_frames(e.traceback)
--> 153 raise e.with_traceback(filtered_tb) from None
154 finally:
155 del filtered_tb

File ~/python/miniconda3/envs/tf213/lib/python3.9/site-packages/tensorflow/python/framework/ops.py:6656, in raise_from_not_ok_status(e, name)
6654 def raise_from_not_ok_status(e, name):
6655 e.message += (" name: " + str(name if name is not None else ""))
-> 6656 raise core._status_to_exception(e) from None

InvalidArgumentError: {{function_node _wrapped__BatchMatMulV2_device/job:localhost/replica:0/task:0/device:CPU:0}} In[0] and In[1] must have compatible batch dimensions: [1,1,1,1,1,3,1,3] vs. [1,3,1,1,1,19,3,1] [Op:BatchMatMulV2] name:

These are with tensorflow 2.13 and sionna 0.15.1

@jj6142
Copy link
Author

jj6142 commented Sep 29, 2023

I noticed another error related to this example. If I specify another transmitter i.e. I have 2 TX+3RX case, I will get the following error with paths.cir():


UnimplementedError Traceback (most recent call last)
Cell In[20], line 18
9 # Apply Doppler shifts
10 # apply_doppler(paths,sampling_frequency=subcarrier_spacing, # Set to 15e3 Hz
11 # num_time_steps=14, # Number of OFDM symbols
12 # tx_velocities=[0,0,0], # We can set additional tx speeds
13 # rx_velocities=[0,0,0]) # Or rx speeds
16 print("Shape of a after applying Doppler shifts: ", paths.a.shape)
---> 18 a, tau = paths.cir()
19 print("Shape of tau: ", tau.shape)

File ~/python/miniconda3/envs/tf213/lib/python3.9/site-packages/sionna/rt/paths.py:577, in Paths.cir(self, los, reflection, diffraction, scattering)
574 tau_ = tf.expand_dims(tau_, -1)
575 phase = tf.complex(tf.zeros_like(tau_),
576 -2PIself.scene.frequency*tau)
--> 577 a = a*tf.exp(phase)
579 return a,tau

File ~/python/miniconda3/envs/tf213/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py:153, in filter_traceback..error_handler(*args, **kwargs)
151 except Exception as e:
152 filtered_tb = _process_traceback_frames(e.traceback)
--> 153 raise e.with_traceback(filtered_tb) from None
154 finally:
155 del filtered_tb

File ~/python/miniconda3/envs/tf213/lib/python3.9/site-packages/tensorflow/python/framework/ops.py:6656, in raise_from_not_ok_status(e, name)
6654 def raise_from_not_ok_status(e, name):
6655 e.message += (" name: " + str(name if name is not None else ""))
-> 6656 raise core._status_to_exception(e) from None

UnimplementedError: {{function_node _wrapped__Mul_device/job:localhost/replica:0/task:0/device:CPU:0}} Broadcast between [1,3,2,2,16,19,14] and [1,3,1,2,1,19,1] is not supported yet. [Op:Mul] name:

@jhoydis
Copy link
Collaborator

jhoydis commented Oct 3, 2023

Hi,

Thanks for reporting these issues. I was able to reproduce them. They will be fixed in the next release. In case that you do not want to wait for so long, I could let you know the changes that need to be applied to the source code (three lines).

@faycalaa
Copy link
Collaborator

Fixed by v0.16.

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