fix up by cursor
This commit is contained in:
parent
a3c38372dd
commit
4449dc62d1
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"cmake.ignoreCMakeListsMissing": true
|
||||
}
|
6
main.py
6
main.py
@ -165,7 +165,6 @@ def main():
|
||||
print("\n程序被用户中断")
|
||||
except Exception as e:
|
||||
import traceback
|
||||
import sys
|
||||
exc_type, exc_value, exc_tb = sys.exc_info()
|
||||
tb = traceback.extract_tb(exc_tb)
|
||||
if tb:
|
||||
@ -300,7 +299,10 @@ class Robot_Ctrl(object):
|
||||
self.runing = 0
|
||||
self.rec_thread.join()
|
||||
self.send_thread.join()
|
||||
# self.image_processor.destroy()
|
||||
try:
|
||||
self.image_processor.destroy()
|
||||
except Exception as e:
|
||||
print(f"销毁图像处理器失败: {e}")
|
||||
# 销毁 MarkerRunner
|
||||
if hasattr(self, 'marker_runner') and self.marker_runner is not None:
|
||||
try:
|
||||
|
@ -255,7 +255,7 @@ class ImageProcessor:
|
||||
self.image_subscriber = ImageSubscriber()
|
||||
self.spin_thread = None
|
||||
self.running = True
|
||||
# self.log = get_logger("图像处理器")
|
||||
self.log = get_logger("图像处理器")
|
||||
|
||||
# 异步 QR 码扫描相关
|
||||
self.scan_thread = None
|
||||
@ -288,17 +288,28 @@ class ImageProcessor:
|
||||
# self.image_subscriber.destroy_node()
|
||||
|
||||
def destroy(self):
|
||||
if not self._ros_initialized:
|
||||
return
|
||||
|
||||
self._shutdown_flag = True
|
||||
if self.spin_thread:
|
||||
self.spin_thread.join(timeout=1.0)
|
||||
|
||||
self.image_subscriber.stop_camera()
|
||||
self.image_subscriber.destroy_node()
|
||||
rclpy.shutdown()
|
||||
self._ros_initialized = False
|
||||
"""优雅关闭:停止扫描与spin线程,释放ROS资源(不在此shutdown全局)。"""
|
||||
try:
|
||||
self.running = False
|
||||
self.stop_async_scan()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
if self.spin_thread and self.spin_thread.is_alive():
|
||||
self.spin_thread.join(timeout=1.0)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
self.image_subscriber.stop_camera()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
self.image_subscriber.destroy_node()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def get_current_image(self, text = 'rgb'):
|
||||
# INFO 默认返回 rgb 图像
|
||||
|
Loading…
x
Reference in New Issue
Block a user