2016-03-03 81 views
2

我知道這個問題之前已經被問過了,但我沒有找到有用的解決方案。完整的錯誤是:GNU Radio OOT模塊AttributeError:'模塊'對象沒有屬性'MME_cpp'

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文件中的回調

  • 納米-C -u libgnuradio-.so

我檢查前3個原因,但我不知道如何找出使用最後方法未定義symblos。有部分結果:

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; 
} 

}/*命名空間CYCL / }/命名空間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> 

回答

3

我同時制定了塊有同樣的問題。我注意到CMake腳本抱怨swig庫丟失了。雖然這不是一個致命的錯誤,但如果沒有它,它就無法工作。

安裝痛飲後,我可以用我的模塊:sudo apt-get install swig

+0

這當然幫助了我......但我也有下面的問題(你知道......只是爲了很好的衡量:Ø加1到兩者:) –

1

這可能是由於你的。所以默認安裝路徑。我最近遇到了這個問題,並且發現/ usr/local/lib默認情況下不在我的/etc/ld.so.conf中(Arch Linux)。更新/etc/ld.so.conf後,我跑了:

sudo ldconfig 

問題已解決。

+0

正如約翰內斯在上面的回答中所述,謝謝:)) –

相關問題