GNU Radio OOT 模块 AttributeError:“模块”对象没有属性“MME_cpp”

2024-04-17

我知道这个问题以前曾被问过,但我没有找到有用的解决方案。完整的错误是:

Executing: "/home/mint/Documents/test_sensor/cycl_test/top_block.py"

Using Volk machine: avx_64_mmx_orc
Traceback (most recent call last):
  File "/home/mint/Documents/test_sensor/cycl_test/top_block.py", line 87, in <module>
    tb = top_block()
  File "/home/mint/Documents/test_sensor/cycl_test/top_block.py", line 61, in __init__
    self.cycl_MME_cpp_0 = cycl.MME_cpp(1000, 16, 0.1)
AttributeError: 'module' object has no attribute 'MME_cpp'

从之前的问题中我发现了一些可能的原因:

  • 函数参数不匹配(包括在.cc和.h中引用函数)

  • 痛饮问题

  • .xml 文件中的回调

  • nm -C -u libgnuradio-.so

我已经检查了前 3 个原因,但我不确定如何使用最后一种方法找出未定义的符号。结果有一部分:

U gsl_linalg_SV_decomp
U gsl_matrix_alloc
U gsl_matrix_set
U gsl_matrix_set_zero
U gsl_vector_alloc
U gsl_vector_get

这是否意味着所有 gsl 函数都未定义?如果是的话我该如何处理?

除了这四个原因之外,对于我的问题还有其他提示吗?

我感谢您的帮助。

附录:

1.MME_cpp_impl.cc

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <gnuradio/io_signature.h>
#include "MME_cpp_impl.h"
#include <stdio.h>
#include <math.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_linalg.h>

namespace gr {
  namespace cycl {

    MME_cpp::sptr
    MME_cpp::make(int Ns, int M, float Pfa)
    {
      return gnuradio::get_initial_sptr
        (new MME_cpp_impl(Ns, M, Pfa));
    }

    /*
 * The private constructor
 */
MME_cpp_impl::MME_cpp_impl(int Ns, int M, float Pfa)
  : gr::sync_block("MME_cpp",
          gr::io_signature::make(1, 1, sizeof(float)),
          gr::io_signature::make(1, 1, sizeof(float))),
    d_Ns(Ns), d_M(M), d_Pfa(Pfa)
{}

/*
 * Our virtual destructor.
 */
MME_cpp_impl::~MME_cpp_impl()
{
}

/*This function gives the CDF value for the pfa in input*/
float 
TracyWidom (float p){
    float pd, tw;
    tw = 0.45;
    pd = 1 - p;
    if (pd >= 0.01 && pd <= 0.05){
    tw = 18*(pd - (17/75)); printf("a - %f\n", tw);
    }else if (pd >= 0.05 && pd <= 0.1){
    tw = 8*(pd - (179/400)); printf("b - %f\n", tw);
    }else if (pd >= 0.1 && pd <= 0.3){
    tw = (87/20)*(pd - (643/870)); printf("c - %f\n", tw);
    }else if (pd >= 0.3 && pd <= 0.5){
    tw = (16/5)*(pd - (287/320)); printf("d - %f\n", tw);
    }else if (pd >= 0.5 && pd <= 0.7){
    tw = (17/5)*(pd - (297/340)); printf("e - %f\n", tw);
    }else if (pd >= 0.7 && pd <= 0.9){
    tw = (5.2)*(pd - (0.813)); printf("f - %f\n", tw);
    }else if (pd >= 0.9 && pd <= 0.95){
    tw = (53/5)*(pd - (909/1060)); printf("g - %f\n", tw);
    }else if (pd >= 0.95 && pd <= 1){
    tw = 26*(pd - (593/650)); printf("h - %f\n", tw);
    }else{
    printf ("wrong pfa value: it must be between 0 and 1\n");
    printf ("the pfa value standard is 0.1\n");
    tw = (53/5)*(0.9 - (909/1060));
    }
    return tw;
    } 

/*this function calculates the threshold for the test
the inputs are: 
ns = numbers of samples/L;
L = length of the correlation function;
pfa = probability of false alarm*/
float 
gamma (int ns, int L, float tw){
    float A, B, C, ratio1, ratio2, g;
    A = sqrt(ns)+sqrt(L*ns);
    B = sqrt(ns)-sqrt(L*ns);
    C = ns*ns*L;
    ratio1 = pow(A,2)/pow(B,2);
    ratio2 = 1+( pow(A,-0.667) / pow(C,0.167) )*tw;
    g = ratio1*ratio2;
    return g;
    } 

/*This function makes the detection test*/
float 
test (float r, float t){
    float decision;
    if(r > -1){
        if(r <= t){
          decision = 0;
        }   
        else{
          decision = 1;
        }
    }
    return decision;}
    //-------------end functions-----------         

int
MME_cpp_impl::work(int noutput_items,
          gr_vector_const_void_star &input_items,
          gr_vector_void_star &output_items)
{
    const float *in = (const float *) input_items[0];
    float *out = (float *) output_items[0];
    //float cov;

    //int ninputs = input_items.size ();

    //for(int i=0; i<noutput_items*Ns; ++i){
    //  cov = compute_convariance(in[i]);
    //int lenght = floor(d_samples / d_L) * d_L;
    float vett[d_Ns];
    int lenght = floor(d_Ns / d_M) ;
    int p, j, k=0;
    float thr, lmax, lmin, ratio=-1, TW, mem=0;
    // char c[1];
    gsl_matrix * hankel = gsl_matrix_alloc (lenght,d_M);
    gsl_matrix * V = gsl_matrix_alloc (d_M,d_M);
    gsl_vector * S = gsl_vector_alloc (d_M);
    gsl_vector * temp = gsl_vector_alloc (d_M);
    //FILE *story;

    gsl_matrix_set_zero (hankel);
    TW = TracyWidom (d_Pfa);
    thr = gamma(lenght, d_M, TW); //calculate the threshold

    for (int i = 0; i < noutput_items; i++){
        vett[k]=in[i];
        k++;
        if (k >= lenght*d_M){
          k = 0;
         // story = fopen("filestory.txt", "a");

          for( p=0; p<lenght; p++ ){
            for( j=0; j<d_M; j++ ){
                gsl_matrix_set (hankel, p, j, vett[p+j]);
            }
          }
        gsl_linalg_SV_decomp (hankel, V, S, temp);//using SDV to calculate eigenvalue
        lmax = gsl_vector_get(S, 0);//maximal eigenvalue
        lmin = gsl_vector_get(S, (d_M -1));//minimal eigenvalue
        ratio = lmax/lmin;
        mem = test(ratio, thr);
        //fprintf(story, "%f - ratio=%f - soglia=%f\n ", mem, ratio, thr);
        //fclose(story);
        }
        out[i] = mem; 
    }

    // Tell runtime system how many output items we produced.
    return noutput_items;
}

} /* 命名空间循环/ } /命名空间 gr */

2.MME_cpp_impl.h

#ifndef INCLUDED_CYCL_MME_CPP_IMPL_H
#define INCLUDED_CYCL_MME_CPP_IMPL_H

#include <cycl/MME_cpp.h>

namespace gr {
  namespace cycl {

    class MME_cpp_impl : public MME_cpp
    {
     private:
      int d_Ns, d_M;
      float d_Pfa;

     public:
      MME_cpp_impl(int Ns, int M, float Pfa);
      ~MME_cpp_impl();

      int Ns() const { return d_Ns; }
      void set_Ns(int Ns) { d_Ns = Ns; }
      int M() const { return d_M; }
      void set_M(int M) { d_M = M; }
      float Pfa() const { return d_Pfa; }
      void set_Pfa(float Pfa) { d_Pfa = Pfa; }

      // Where all the action really happens
      int work(int noutput_items,
           gr_vector_const_void_star &input_items,
           gr_vector_void_star &output_items);
      //float compute_covariance(float & d, int i, int j);
    friend float TracyWidom (float p);
    friend float gamma (int ns, int L, float tw);
    friend float test (float r, float t);
    };

    float TracyWidom (float p);
    float gamma (int ns, int L, float tw);
    float test (float r, float t);

  } // namespace cycl
} // namespace gr

#endif /* INCLUDED_CYCL_MME_CPP_IMPL_H */

3.MME_cpp.h

#ifndef INCLUDED_CYCL_MME_CPP_H
#define INCLUDED_CYCL_MME_CPP_H

#include <cycl/api.h>
#include <gnuradio/sync_block.h>

namespace gr {
  namespace cycl {

    /*!
     * \brief <+description of block+>
     * \ingroup cycl
     *
     */
    class CYCL_API MME_cpp : virtual public gr::sync_block
    {
     public:
      typedef boost::shared_ptr<MME_cpp> sptr;

      /*!
       * \brief Return a shared_ptr to a new instance of cycl::MME_cpp.
       *
       * To avoid accidental use of raw pointers, cycl::MME_cpp's
       * constructor is in a private implementation
       * class. cycl::MME_cpp::make is the public interface for
       * creating new instances.
       */
      static sptr make(int Ns, int M, float Pfa);

      virtual int Ns() const = 0;
      virtual void set_Ns(int Ns) = 0;
      virtual int M() const = 0;
      virtual void set_M(int M) = 0;
      virtual float Pfa() const = 0;
      virtual void set_Pfa(float Pfa) = 0;
    };

  } // namespace cycl
} // namespace gr

#endif /* INCLUDED_CYCL_MME_CPP_H */

4.cycl_MME_cpp.xml

<?xml version="1.0"?>
<block>
  <name>MME_cpp</name>
  <key>cycl_MME_cpp</key>
  <category>cycl</category>
  <import>import cycl</import>
  <make>cycl.MME_cpp($Ns, $M, $Pfa)</make>
  <callback>set_Ns($Ns)</callback>
  <callback>set_M($M)</callback>
  <callback>set_Pfa($Pfa)</callback>

  <param>
    <name>Number of samples</name>
    <key>Ns</key>
    <type>int</type>
  </param>
 <param>
    <name>Length of correlation function</name>
    <key>M</key>
    <type>int</type>
  </param>
 <param>
    <name>false probability</name>
    <key>Pfa</key>
    <type>float</type>
  </param>


  <sink>
    <name>in</name>
    <type>float</type>
  </sink>


  <source>
    <name>out</name>
    <type>float</type>
  </source>
</block>

我在开发块时遇到了同样的问题。我注意到 CMake 脚本抱怨缺少 swig 库。虽然这不是致命错误,但没有它就无法工作。

安装 swig 后我可以使用我的模块:sudo apt-get install swig

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

GNU Radio OOT 模块 AttributeError:“模块”对象没有属性“MME_cpp” 的相关文章

随机推荐

  • 源操作数和目标操作数是否需要相同大小?

    我刚刚尝试了这个问题 要求你解释一下代码行有什么问题 movl eax rdx 解决方案表明目标操作数的大小错误 仅当从较大尺寸变为较小尺寸时才 非法 还是源操作数和目标操作数对于所有指令 或至少 mov 类类型 必须具有相同的尺寸 是的
  • POV-Ray:在脚本中设置输出分辨率或宽度/高度比

    我有一个代码可以生成一堆 pov使用 POV Ray 进行可视化的文件 不幸的是 它们具有不同的纵横比 宽度 高度 该信息以向上 向右向量的形式存在于脚本中 但是 当我渲染没有任何额外参数的脚本时 即通过povray test pov PO
  • 如何在初始化数据库时显示启动屏幕?

    我创建了一个启动画面 效果非常好 现在我想在显示启动屏幕的同时加载数据库 并在数据库完全加载后显示应用程序 UI 我有以下代码来执行此操作 对吗 public class Splash extends Activity Override p
  • 从 MySQL 中的字符串中删除引号和逗号

    我正在从一个导入一些数据CSV文件 以及大于的数字1000变成1 100 etc 有什么好方法可以从中删除引号和逗号 以便我可以将其放入int field Edit 数据实际上已经在 MySQL 表中 所以我需要能够使用 SQL 来完成此操
  • JavaScript 正则表达式 - g 修饰符不起作用[重复]

    这个问题在这里已经有答案了 我有以下代码 var str 4 shnitzel 5 ducks var rgx new RegExp 0 9 g console log rgx exec str chrome 和 firefox 上的输出是
  • 如果Bokeh有很多图表,输出文件很重并且系统很慢

    我使用散景 我非常喜欢Bokeh 因为Bokeh有很多图表并且输出文件非常简单 我在半导体公司工作 有时我会分析半导体 数据 我有很多数据 我制作了很多图表 可能是 1000 4000 次图表操作 我用Bokeh来制作图表 但是Bokeh很
  • 在 PowerShell 中检查路径是否存在的更好方法[关闭]

    Closed 这个问题是基于意见的 help closed questions 目前不接受答案 PowerShell 中是否有更简洁且不易出错的方法来检查路径是否不存在 对于这样一个常见的用例来说 客观上来说太冗长了 if not Test
  • Symfony2 创建自己的编码器来存储密码

    我是 Symfony2 的新手 我可能有一个关于在数据库中编码用户密码的简单问题 我想以这种方式编码并存储在数据库中我的用户密码 encoded password salt sha1 salt raw password 我找到了各种编码器
  • 是Pythonic吗:命名lambdas

    我开始欣赏 python 中 lambda 表达式的价值 特别是在函数式编程方面 map 函数返回函数 https stackoverflow com a 16509 1533474等等 但是 我也在函数中命名 lambda 因为 我多次需
  • fseek() 按行而不是字节?

    我有一个可以逐行解析大文件的脚本 当它遇到无法处理的错误时 它会停止 通知我们解析的最后一行 这真的是寻找文件中特定行的最佳 唯一方法吗 fseek 在我的情况下不可用
  • ASP.NET 日期和时间选择器?

    我将 ASP NET 2 0 与 SQL Server 2005 结合使用 我希望用户选择日期和时间 然后将这些值保存到数据库中 在 VS 中 我可以使用日历控件来获取日期 但是处理用户选择的日期以及用户还必须从控件中选择的时间有什么好处
  • 如何删除 Rmd 输出到 PDF 中代码块之间的空白?

    如何删除图表末尾与下一个图表之间的多余空白 我有一个闪亮的应用程序 运行参数化的 Rmd 输出为 html 和 PDF html 很好 但 PDF 中有太多空白 我应该将所有内容都放入两页中 因此边距 几何形状很软 但是我需要在第 1 页底
  • 使用 LaTeX,如何在每个部分的末尾提供参考文献列表? [关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 我想为每个部分生成参考书目 并将其放在该部分的末尾 当我现在这样做时 它会生成完整的参考书目并将其放置在每个部分之后 有没有办法可以做到这一点 建议h
  • AFJSONRequestOperation 数组填充,但无法在成功块之外填充 NSLog 内容

    以下代码摘自本教程 http mobile tutsplus com tutorials iphone ios sdk afnetworking 我以前用过这个片段 但之前从未注意到这个问题 数组内容的 NSLog 在委托方法中打印 但不在
  • Socket IO 涉及磁盘 IO 吗?

    如果一个进程通过套接字向同一台机器上的另一个进程发送数据 传输过程中发生磁盘读 写的可能性有多大 似乎有一个套接字文件类型 如果有空闲内存 这些文件是否保证在内存中 不直接 TCP UDP 网络套接字 本地主机或 UNIX 域套接字将在内存
  • 使用 NumPy 的数据类型大小

    在 NumPy 中 我可以通过以下方式获取特定数据类型的大小 以字节为单位 datatype itemsize or datatype nbytes 例如 np float32 5 itemsize 4 np float32 5 nbyte
  • 如何从给定 C# 链接的特定 GitHub 存储库中获取文件列表?

    如何从 GitHub 链接获取文件列表 例如 来自此 GitHub 存储库链接 https github com crs2007 ActiveReport tree master ActiveReport SQLFiles 我们可以看到有S
  • 自动执行 rake 任务以在 Heroku 上启动时运行?

    假设有一个任务 rake startupscript 它应该在应用程序启动时运行 我们如何在heroku上自动化它 我知道有一个 heroku 调度程序 但它会每 10 分钟运行一次任务 而不是只在启动时运行一次 我也知道Procfile
  • 如何撤消“git add --intent-to-add”

    当我跑步时git add intent to add 所有未跟踪的文件都从 未跟踪的文件 更改了状态 git status s showed 到 未暂存提交的更改 git status s现在显示A 现在 每当我跑步时git diff我也看
  • GNU Radio OOT 模块 AttributeError:“模块”对象没有属性“MME_cpp”

    我知道这个问题以前曾被问过 但我没有找到有用的解决方案 完整的错误是 Executing home mint Documents test sensor cycl test top block py Using Volk machine a