Example #1
0
    def gen_heatmap(self, phi, theta):
        if self.counter%120 == 0:
            lobe_values = lobe_values_x*np.sin(theta)*np.cos(phi) + lobe_values_y*np.sin(theta)*np.sin(phi) + lobe_values_z*np.cos(theta)
            lobe_values = 0.5*lobe_amplitude*np.exp(lobe_sharpness*(lobe_values-1))

            phi0 = np.pi
            theta0 = np.pi/2.0
            lobe_values0 = lobe_values_x*np.sin(theta0)*np.cos(phi0) + lobe_values_y*np.sin(theta0)*np.sin(phi0) + lobe_values_z*np.cos(theta0)
            lobe_values += 0.75*lobe_amplitude*np.exp(lobe_sharpness*(lobe_values0-1))

            min_lobe = np.min(lobe_values)
            max_lobe = np.max(lobe_values)
            lobe_values = (lobe_values-min_lobe)/(max_lobe-min_lobe)*255.0
            h = lobe_values.astype(int)
            h = np.ndarray.tolist(h.flatten())
            h = [chr(n) for n in h]
            h = ''.join(h)
            msg = image_t()
            msg.utime = self.counter*1e5/12.0
            msg.width = 360
            msg.height = 180
            msg.row_stride = 360
            msg.pixelformat = 1497715271
            msg.size = len(h)
            msg.data = h
            msg.nmetadata = 0
            #lc.publish("BF_HEATMAP_ONLINE", msg.encode())
            #print 'elevation:', theta*180/np.pi, 'azimuth:', phi*180/np.pi
            lc.publish("BF_HEATMAP", msg.encode())
        self.counter += 1
Example #2
0
    def gen_heatmap(self, phi, theta):
        if self.counter % 120 == 0:
            lobe_values = (
                lobe_values_x * np.sin(theta) * np.cos(phi)
                + lobe_values_y * np.sin(theta) * np.sin(phi)
                + lobe_values_z * np.cos(theta)
            )
            lobe_values = 0.5 * lobe_amplitude * np.exp(lobe_sharpness * (lobe_values - 1))

            phi0 = np.pi
            theta0 = np.pi / 2.0
            lobe_values0 = (
                lobe_values_x * np.sin(theta0) * np.cos(phi0)
                + lobe_values_y * np.sin(theta0) * np.sin(phi0)
                + lobe_values_z * np.cos(theta0)
            )
            lobe_values += 0.75 * lobe_amplitude * np.exp(lobe_sharpness * (lobe_values0 - 1))

            min_lobe = np.min(lobe_values)
            max_lobe = np.max(lobe_values)
            lobe_values = (lobe_values - min_lobe) / (max_lobe - min_lobe) * 255.0
            h = lobe_values.astype(int)
            h = np.ndarray.tolist(h.flatten())
            h = [chr(n) for n in h]
            h = "".join(h)
            msg = image_t()
            msg.utime = self.counter * 1e5 / 12.0
            msg.width = 360
            msg.height = 180
            msg.row_stride = 360
            msg.pixelformat = 1497715271
            msg.size = len(h)
            msg.data = h
            msg.nmetadata = 0
            # lc.publish("BF_HEATMAP_ONLINE", msg.encode())
            # print 'elevation:', theta*180/np.pi, 'azimuth:', phi*180/np.pi
            lc.publish("BF_HEATMAP", msg.encode())
        self.counter += 1
Example #3
0
					phi = np.arctan2(source_bf[1,0], source_bf[0,0])						#azimuth
					if phi < 0:
						phi = -phi
					else:
						phi = 2*np.pi - phi
					# create the heatmap as a spherical gaussian centered at this azimuth and elevation, and publish in image_t format
					lobe_values = lobe_values_x*np.sin(theta)*np.cos(phi) + lobe_values_y*np.sin(theta)*np.sin(phi) + lobe_values_z*np.cos(theta)
					lobe_values = lobe_amplitude*np.exp(lobe_sharpness*(lobe_values-1))
					min_lobe = np.min(lobe_values)
					max_lobe = np.max(lobe_values)
					lobe_values = (lobe_values-min_lobe)/(max_lobe-min_lobe)*255.0
					h = lobe_values.astype(int)
					h = np.ndarray.tolist(h.flatten())
					h = [chr(n) for n in h]
					h = ''.join(h)
					msg = image_t()
					msg.utime = curr_time
					msg.width = 360
					msg.height = 180
					msg.row_stride = 360
					msg.pixelformat = 1497715271
					msg.size = len(h)
					msg.data = h
					msg.nmetadata = 0
					lc.publish("BF_HEATMAP", msg.encode())
					print 'elevation:', theta*180/np.pi, 'azimuth:', phi*180/np.pi

except KeyboardInterrupt:
	pass

''' rejection sampling scheme for Von-Mises-Fisher '''