I am trying to build a sink block with FFT and Kurtosis capability using gr_modtool.
The code itself can be compiled without error.
But when I run the flow graph in GRC, it produces following error message.
Generating: '/home/nomo/gr-Kurtosis/kurtosis.py'
Executing: /usr/bin/python3 -u /home/nomo/gr-Kurtosis/kurtosis.py
Traceback (most recent call last):
File "/home/nomo/gr-Kurtosis/kurtosis.py", line 134, in <module>
main()
File "/home/nomo/gr-Kurtosis/kurtosis.py", line 112, in main
tb = top_block_cls()
File "/home/nomo/gr-Kurtosis/kurtosis.py", line 81, in __init__
self.Kurtosis_Kurtosis_c_0 = Kurtosis.Kurtosis_c(1024)
AttributeError: module 'Kurtosis' has no attribute 'Kurtosis_c'
Below is the implmentation source file:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "Kurtosis_c_impl.h"
namespace gr {
namespace Kurtosis {
Kurtosis_c::sptr
Kurtosis_c::make(int fftsize)
{
return gnuradio::get_initial_sptr
(new Kurtosis_c_impl(fftsize));
}
/*
* The private constructor
*/
Kurtosis_c_impl::Kurtosis_c_impl(int fftsize)
: gr::sync_block("Kurtosis_c",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(0, 0, 0)),
d_N(fftsize)
{
d_input = (fftw_complex*)fftw_malloc(sizeof(gr_complex) * d_N);
K = (fftw_complex*)fftw_malloc(sizeof(gr_complex) * d_N);
d_plan = fftw_plan_dft_1d(d_N, d_input, d_input, FFTW_BACKWARD, FFTW_ESTIMATE);
}
/*
* Our virtual destructor.
*/
Kurtosis_c_impl::~Kurtosis_c_impl()
{
}
int
Kurtosis_c_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex*) input_items[0];
for(int i = 0; i < noutput_items; i++)
{
d_input[i][0] = in[i].real();
d_input[i][1] = in[i].imag();
}
fftw_execute(d_plan);
for(int i = 0; i < noutput_items ;i++)
{
S1[i][0] = S1[i][0] + d_input[i][0];
S1[i][1] = S1[i][1] + d_input[i][1];
S2[i][0] = S2[i][0] + d_input[i][0] * d_input[i][0];
S2[i][1] = S2[i][1] + d_input[i][1] * d_input[i][1];
S3[i][0] = S3[i][0] + d_input[i][0] * d_input[i][0] * d_input[i][0];
S3[i][1] = S3[i][1] + d_input[i][1] * d_input[i][1] * d_input[i][1];
S4[i][0] = S4[i][0] + d_input[i][0] * d_input[i][0] * d_input[i][0] * d_input[i][0];
S4[i][1] = S4[i][1] + d_input[i][1] * d_input[i][1] * d_input[i][1] * d_input[i][1];
dc[i][0] = dc[i][0] + 1;
dc[i][1] = dc[i][1] + 1;
}
for(int i = 0; i < noutput_items; i++)
{
Myu1[i][0] = S1[i][0] / dc[i][0];
Myu1[i][1] = S1[i][1] / dc[i][1];
Myu2[i][0] = S2[i][0] / dc[i][0];
Myu2[i][1] = S2[i][1] / dc[i][1];
Myu3[i][0] = S3[i][0] / dc[i][0];
Myu3[i][1] = S3[i][1] / dc[i][1];
Myu4[i][0] = S4[i][0] / dc[i][0];
Myu4[i][1] = S4[i][1] / dc[i][1];
}
for(int i = 0; i < noutput_items; i++)
{
K[i][0] = (Myu4[i][0] - 4 * Myu3[i][0] * Myu1[i][0] + 6 * Myu2[i][0] * Myu1[i][0]
* Myu1[i][0] - 3 * Myu1[i][0] * Myu1[i][0] * Myu1[i][0] * Myu1[i][0]) /
((Myu2[i][0] - Myu1[i][0] * Myu1[i][0]) * (Myu2[i][0] - Myu1[i][0]
* Myu1[i][0]));
K[i][1] = (Myu4[i][1] - 4 * Myu3[i][1] * Myu1[i][1] + 6 * Myu2[i][1] * Myu1[i][1]
* Myu1[i][1] - 3 * Myu1[i][1] * Myu1[i][1] * Myu1[i][1] * Myu1[i][1]) /
((Myu2[i][1] - Myu1[i][1] * Myu1[i][1]) * (Myu2[i][1] - Myu1[i][1]
* Myu1[i][1]));
}
// Tell runtime system how many output items we produced.
return noutput_items;
}
} /* namespace Kurtosis1 */
} /* namespace gr */
The implementation header file is as below:
#ifndef INCLUDED_KURTOSIS1_KURTOSIS_C1_IMPL_H
#define INCLUDED_KURTOSIS1_KURTOSIS_C1_IMPL_H
#include <Kurtosis/Kurtosis_c.h>
#include <fftw3.h>
namespace gr {
namespace Kurtosis {
class Kurtosis_c_impl : public Kurtosis_c
{
private:
int d_N;
fftw_complex *K;
fftw_complex *S1;
fftw_complex *S2;
fftw_complex *S3;
fftw_complex *S4;
fftw_complex *Myu1;
fftw_complex *Myu2;
fftw_complex *Myu3;
fftw_complex *Myu4;
fftw_complex *dc;
fftw_complex *d_input;
fftw_plan d_plan;
public:
Kurtosis_c_impl(int fftsize);
~Kurtosis_c_impl();
// Where all the action really happens
int work(
int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items
);
};
} // namespace Kurtosis1
} // namespace gr
#endif /* INCLUDED_KURTOSIS1_KURTOSIS_C1_IMPL_H */
Question: How to solve this error?
Thank you in advance for any guidance you may be able to provide.