This commit is contained in:
张梦南 2025-07-02 15:54:13 +08:00
parent b5d0d09a1e
commit 8400d190d8

View File

@ -110,17 +110,17 @@ def position_callback(msg):
res = fft_client(data_x=noisy_x_history[-FFT_WINDOW_SIZE:], res = fft_client(data_x=noisy_x_history[-FFT_WINDOW_SIZE:],
data_y=noisy_y_history[-FFT_WINDOW_SIZE:], data_y=noisy_y_history[-FFT_WINDOW_SIZE:],
window_size=FFT_WINDOW_SIZE) window_size=FFT_WINDOW_SIZE)
rospy.loginfo("FFT computed successfully") rospy.loginfo("FFT计算成功")
current_x_magnitudes[:] = res.magnitude_x current_x_magnitudes[:] = res.magnitude_x
current_y_magnitudes[:] = res.magnitude_y current_y_magnitudes[:] = res.magnitude_y
except rospy.ServiceException as e: except rospy.ServiceException as e:
rospy.logerr("Failed to call FFT service: %s" % e) rospy.logerr("FFT计算失败: %s" % e)
# 判断频谱,生成频谱图 # 判断频谱,生成频谱图
if current_x_magnitudes and current_y_magnitudes: if current_x_magnitudes and current_y_magnitudes:
x_spectrum = Marker() x_spectrum = Marker()
x_spectrum.header = msg.header x_spectrum.header = msg.header
x_spectrum.ns = "坐标x频谱" x_spectrum.ns = "x_spectrum"
x_spectrum.id = 2 x_spectrum.id = 2
x_spectrum.type = Marker.CUBE_LIST x_spectrum.type = Marker.CUBE_LIST
x_spectrum.action = Marker.ADD x_spectrum.action = Marker.ADD
@ -132,7 +132,7 @@ def position_callback(msg):
y_spectrum = Marker() y_spectrum = Marker()
y_spectrum.header = msg.header y_spectrum.header = msg.header
y_spectrum.ns = "坐标y频谱" y_spectrum.ns = "y_spectrum"
y_spectrum.id = 3 y_spectrum.id = 3
y_spectrum.type = Marker.CUBE_LIST y_spectrum.type = Marker.CUBE_LIST
y_spectrum.action = Marker.ADD y_spectrum.action = Marker.ADD