【发布时间】:2022-01-23 08:17:30
【问题描述】:
此 GRC 应用程序中的顶部嵌入式 Python 块是 stock 块。底部是 LPF,代码如下。
如果没有油门块,应用程序可以正常工作。使用油门块会生成错误gr::log :ERROR: thread_body_wrapper - ERROR thread[thread-per-block[2]: <block Embedded Python Block 2(3)>]: ValueError: could not broadcast input array from shape (17,) into shape (16,)。当油门块在库存块的路径中时,不会出现这样的问题。
我正在学习 GRC,想了解为什么引入油门会导致问题。
import numpy as np
from gnuradio import gr
class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block
"""Embedded Python Block example - a simple multiply const"""
h = np.array([0.0397989, -0.0488053, -0.0345932, 0.0659844, 0.0315417, -0.1074744,
-0.0299212, 0.3187633, 0.5294118, 0.3187633, -0.0299212, -0.1074744, 0.0315417,
0.0659844, -0.0345932, -0.0488053, 0.0397989], dtype=np.float32)
a = True;
def __init__(self, example_param=2.0): # only default arguments here
"""arguments to this function show up as parameters in GRC"""
gr.sync_block.__init__(
self,
name='Embedded Python Block 2', # will show up in GRC
in_sig=[np.float32],
out_sig=[np.float32]
)
# if an attribute with the same name as a parameter is found,
# a callback is registered (properties work, too).
self.example_param = example_param
def work(self, input_items, output_items):
"""Convolution of input with LPF coefficients"""
output_items[0][:] = np.convolve(input_items[0], self.h, 'same')
return len(output_items[0])
【问题讨论】:
标签: python gnuradio gnuradio-companion