Exemple #1
0
    def test_001_t(self):
        # set up fg
        test_len = 1024

        packet_len = test_len
        samp_rate = 2000

        center_freq = 1e9
        velocity = (5, 15, 20)

        src = radar.signal_generator_cw_c(packet_len, samp_rate, (0, 0), 1)
        head = blocks.head(8, test_len)
        sim = radar.static_target_simulator_cc(
            (10, 10, 10), velocity, (1e12, 1e12, 1e12), (0, 0, 0), (0, ),
            samp_rate, center_freq, 1, True, False)
        mult = blocks.multiply_cc()
        fft = radar.ts_fft_cc(packet_len)
        cfar = radar.os_cfar_c(samp_rate, 5, 0, 0.78, 10, True)
        est = radar.estimator_cw(center_freq)
        res1 = radar.print_results()
        res2 = radar.print_results()
        gate = radar.msg_gate(('velocity', 'bla'), (8, 8), (17, 17))
        debug1 = blocks.message_debug()
        debug2 = blocks.message_debug()

        self.tb.connect(src, head, (mult, 1))
        self.tb.connect(head, sim, (mult, 0))
        self.tb.connect(mult, fft, cfar)
        self.tb.msg_connect(cfar, 'Msg out', est, 'Msg in')
        self.tb.msg_connect(est, 'Msg out', res1, 'Msg in')
        self.tb.msg_connect(est, 'Msg out', debug1, 'store')
        self.tb.msg_connect(est, 'Msg out', gate, 'Msg in')
        self.tb.msg_connect(gate, 'Msg out', debug2, 'store')
        self.tb.msg_connect(gate, 'Msg out', res2, 'Msg in')

        self.tb.start()
        sleep(0.5)
        self.tb.stop()
        self.tb.wait()

        # check data
        msg1 = debug1.get_message(0)  # msg without gate
        msg2 = debug2.get_message(0)  # msg with gate
        self.assertEqual(
            "velocity", pmt.symbol_to_string(pmt.nth(0, (pmt.nth(
                1, msg1)))))  # check velocity message part (symbol), 1
        self.assertEqual(
            "velocity", pmt.symbol_to_string(pmt.nth(0, (pmt.nth(
                1, msg2)))))  # check velocity message part (symbol), 2
        self.assertEqual(pmt.length(pmt.nth(1, pmt.nth(1, msg1))),
                         3)  # check number of targets without gate
        self.assertEqual(pmt.length(pmt.nth(1, pmt.nth(1, msg2))),
                         1)  # check nubmer of targets with gate
        self.assertAlmostEqual(
            1, velocity[1] / pmt.f32vector_ref(pmt.nth(1,
                                                       (pmt.nth(1, msg2))), 0),
            1)  # check velocity value
Exemple #2
0
    def test_001_t(self):
        # set up fg
        test_len = 1024

        packet_len = test_len
        samp_rate = 2000

        center_freq = 1e9
        velocity = (5, 15, 20)

        src = radar.signal_generator_cw_c(packet_len, samp_rate, (0, 0), 1)
        head = blocks.head(8, test_len)
        sim = radar.static_target_simulator_cc(
            (10, 10, 10), velocity, (1e12, 1e12, 1e12), (0, 0, 0), (0,), samp_rate, center_freq, 1, True, False
        )
        mult = blocks.multiply_cc()
        fft = radar.ts_fft_cc(packet_len)
        cfar = radar.os_cfar_c(samp_rate, 5, 0, 0.78, 10, True)
        est = radar.estimator_cw(center_freq)
        res1 = radar.print_results()
        res2 = radar.print_results()
        gate = radar.msg_gate(("velocity", "bla"), (8, 8), (17, 17))
        debug1 = blocks.message_debug()
        debug2 = blocks.message_debug()

        self.tb.connect(src, head, (mult, 1))
        self.tb.connect(head, sim, (mult, 0))
        self.tb.connect(mult, fft, cfar)
        self.tb.msg_connect(cfar, "Msg out", est, "Msg in")
        self.tb.msg_connect(est, "Msg out", res1, "Msg in")
        self.tb.msg_connect(est, "Msg out", debug1, "store")
        self.tb.msg_connect(est, "Msg out", gate, "Msg in")
        self.tb.msg_connect(gate, "Msg out", debug2, "store")
        self.tb.msg_connect(gate, "Msg out", res2, "Msg in")

        self.tb.start()
        sleep(0.5)
        self.tb.stop()
        self.tb.wait()

        # check data
        msg1 = debug1.get_message(0)  # msg without gate
        msg2 = debug2.get_message(0)  # msg with gate
        self.assertEqual(
            "velocity", pmt.symbol_to_string(pmt.nth(0, (pmt.nth(1, msg1))))
        )  # check velocity message part (symbol), 1
        self.assertEqual(
            "velocity", pmt.symbol_to_string(pmt.nth(0, (pmt.nth(1, msg2))))
        )  # check velocity message part (symbol), 2
        self.assertEqual(pmt.length(pmt.nth(1, pmt.nth(1, msg1))), 3)  # check number of targets without gate
        self.assertEqual(pmt.length(pmt.nth(1, pmt.nth(1, msg2))), 1)  # check nubmer of targets with gate
        self.assertAlmostEqual(
            1, velocity[1] / pmt.f32vector_ref(pmt.nth(1, (pmt.nth(1, msg2))), 0), 1
        )  # check velocity value
    def test_001_t(self):
        # set up fg
        test_len = 1024

        packet_len = test_len
        samp_rate = 2000

        center_freq = 1e9
        velocity = 15

        src = radar.signal_generator_cw_c(packet_len, samp_rate, (0, 0), 1)
        head = blocks.head(8, test_len)
        sim = radar.static_target_simulator_cc(
            (10, 10), (velocity, velocity), (1e9, 1e9), (0, 0), (0, ),
            samp_rate, center_freq, 1, True, False)
        mult = blocks.multiply_cc()
        fft = radar.ts_fft_cc(packet_len)
        cfar = radar.os_cfar_c(samp_rate, 5, 0, 0.78, 10, True)
        est = radar.estimator_cw(center_freq)
        res = radar.print_results()
        debug = blocks.message_debug()

        self.tb.connect(src, head, (mult, 1))
        self.tb.connect(head, sim, (mult, 0))
        self.tb.connect(mult, fft, cfar)
        self.tb.msg_connect(cfar, 'Msg out', est, 'Msg in')
        self.tb.msg_connect(est, 'Msg out', res, 'Msg in')
        self.tb.msg_connect(est, 'Msg out', debug, 'store')
        #self.tb.msg_connect(est,'Msg out',debug,'print')

        self.tb.start()
        sleep(0.5)
        self.tb.stop()
        self.tb.wait()

        # check data
        msg = debug.get_message(0)
        self.assertEqual("rx_time",
                         pmt.symbol_to_string(pmt.nth(0, (pmt.nth(
                             0, msg)))))  # check rx_time message part (symbol)
        self.assertEqual(0,
                         pmt.to_uint64(
                             pmt.tuple_ref(pmt.nth(1, (pmt.nth(0, msg))),
                                           0)))  # check rx_time value
        self.assertEqual(
            0.0, pmt.to_double(pmt.tuple_ref(pmt.nth(1, (pmt.nth(0, msg))),
                                             1)))
        self.assertEqual(
            "velocity", pmt.symbol_to_string(pmt.nth(
                0, (pmt.nth(1, msg)))))  # check velocity message part (symbol)
        self.assertAlmostEqual(
            1, velocity / pmt.f32vector_ref(pmt.nth(1, (pmt.nth(1, msg))), 0),
            2)  # check velocity value
	def test_001_t (self):
		# set up fg
		test_len = 1024

		packet_len = test_len
		samp_rate = 2000
		
		center_freq = 1e9
		velocity = 15

		src = radar.signal_generator_cw_c(packet_len,samp_rate,(0,0),1)
		head = blocks.head(8,test_len)
		sim = radar.static_target_simulator_cc((10,10),(velocity,velocity),(1e9,1e9),(0,0),(0,),samp_rate,center_freq,1,True,False)
		mult = blocks.multiply_cc()
		fft = radar.ts_fft_cc(packet_len)
		cfar = radar.os_cfar_c(samp_rate, 5, 0, 0.78, 10, True)
		est = radar.estimator_cw(center_freq)
		res = radar.print_results()
		debug = blocks.message_debug()

		self.tb.connect(src,head,(mult,1))
		self.tb.connect(head,sim,(mult,0))
		self.tb.connect(mult,fft,cfar)
		self.tb.msg_connect(cfar,'Msg out',est,'Msg in')
		self.tb.msg_connect(est,'Msg out',res,'Msg in')
		self.tb.msg_connect(est,'Msg out',debug,'store')
		#self.tb.msg_connect(est,'Msg out',debug,'print')

		self.tb.start()
		sleep(0.5)
		self.tb.stop()
		self.tb.wait()
		
		# check data
		msg = debug.get_message(0)
		self.assertEqual( "rx_time", pmt.symbol_to_string(pmt.nth(0,(pmt.nth(0,msg)))) ) # check rx_time message part (symbol)
		self.assertEqual( 0, pmt.to_uint64(pmt.tuple_ref(pmt.nth(1,(pmt.nth(0,msg))),0)) ) # check rx_time value
		self.assertEqual( 0.0, pmt.to_double(pmt.tuple_ref(pmt.nth(1,(pmt.nth(0,msg))),1)) )
		self.assertEqual( "velocity", pmt.symbol_to_string(pmt.nth(0,(pmt.nth(1,msg)))) ) # check velocity message part (symbol)
		self.assertAlmostEqual( 1, velocity/pmt.f32vector_ref(pmt.nth(1,(pmt.nth(1,msg))),0), 2 ) # check velocity value