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