修改检测端口连接
This commit is contained in:
parent
114ca221ac
commit
e244d47021
@ -78,53 +78,18 @@ class dobot_nova5:
|
|||||||
self.feedbackData = feedbackItem() # 自定义反馈数据结构体
|
self.feedbackData = feedbackItem() # 自定义反馈数据结构体
|
||||||
self.logger = CustomLogger('Dobot_nova5')
|
self.logger = CustomLogger('Dobot_nova5')
|
||||||
|
|
||||||
# try:
|
|
||||||
# self.dashboard = DobotApiDashboard(self.ip, self.dashboardPort)
|
|
||||||
# if not self.dashboard.connect():
|
|
||||||
# print(f"[ERROR] 无法连接 Dashboard {self.ip}:{self.dashboardPort}")
|
|
||||||
# self.dashboard = None
|
|
||||||
# else:
|
|
||||||
# print("[INFO] Dashboard 连接成功")
|
|
||||||
|
|
||||||
# except Exception as e:
|
|
||||||
# print(f"[ERROR] Dashboard 初始化失败: {e}")
|
|
||||||
# self.dashboard = None
|
|
||||||
|
|
||||||
# 尝试连接 Dashboard 控制接口(默认 29999 端口)
|
|
||||||
try:
|
|
||||||
self.dashboard = DobotApiDashboard(self.ip, self.dashboardPort)
|
|
||||||
if self.dashboard.is_connected():
|
|
||||||
print("[INFO] Dashboard 连接成功")
|
|
||||||
else:
|
|
||||||
print("[ERROR] Dashboard 未连接成功")
|
|
||||||
self.dashboard = None
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[ERROR] Dashboard 连接失败: {e}")
|
|
||||||
self.dashboard = None
|
|
||||||
|
|
||||||
# 尝试连接 Feedback 接口(默认 30003 端口)
|
|
||||||
try:
|
|
||||||
self.feedFour = DobotApiFeedBack(self.ip, self.feedFourPort)
|
|
||||||
if self.feedFour.is_connected():
|
|
||||||
print("[INFO] Feedback 连接成功")
|
|
||||||
else:
|
|
||||||
print("[ERROR] Feedback 未连接成功")
|
|
||||||
self.feedFour = None
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[ERROR] Feedback 连接失败: {e}")
|
|
||||||
self.feedFour = None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# self.dashboard = DobotApiDashboard(self.ip,self.dashboardPort)
|
|
||||||
# self.feedFour = DobotApiFeedBack(self.ip,self.feedFourPort)
|
|
||||||
|
|
||||||
self.stop_feedback = threading.Event()
|
self.stop_feedback = threading.Event()
|
||||||
self.stop_feedback.clear()
|
self.stop_feedback.clear()
|
||||||
# 状态反馈线程
|
# 状态反馈线程
|
||||||
self.feedback_thread = threading.Thread(
|
self.feedback_thread = threading.Thread(
|
||||||
target=self.GetFeedback # 机器状态反馈线程
|
target=self.GetFeedback # 机器状态反馈线程
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.dashboard = DobotApiDashboard(self.ip, self.dashboardPort)
|
||||||
|
self.feedFour = DobotApiFeedBack(self.ip, self.feedFourPort)
|
||||||
|
if self.dashboard.is_connected() and self.feedFour.is_connected():
|
||||||
|
print("连接成功")
|
||||||
self.feedback_thread.daemon = True
|
self.feedback_thread.daemon = True
|
||||||
self.feedback_thread.start()
|
self.feedback_thread.start()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -169,11 +134,22 @@ class dobot_nova5:
|
|||||||
self.clearError() # 清除报警
|
self.clearError() # 清除报警
|
||||||
cnt_num += 1
|
cnt_num += 1
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.logger.log_error(f"连接机械臂失败,尝试第{cnt_num+1}次连接")
|
self.logger.log_error(f"连接机械臂失败,尝试第{cnt_num+1}次连接")
|
||||||
cnt_num += 1
|
cnt_num += 1
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
else:
|
||||||
|
print("[ERROR]未连接成功")
|
||||||
|
self.dashboard = None
|
||||||
|
self.feedFour = None
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[ERROR] Dashboard 连接失败: {e}")
|
||||||
|
self.dashboard = None
|
||||||
|
self.feedFour = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
atexit.register(self.exit_task)
|
atexit.register(self.exit_task)
|
||||||
|
|
||||||
self.init_pos = [-45.0009079*np.pi/180,55.5785141*np.pi/180,-120.68821716*np.pi/180,5.11103201*np.pi/180,90.00195312*np.pi/180,-90.00085449*np.pi/180]
|
self.init_pos = [-45.0009079*np.pi/180,55.5785141*np.pi/180,-120.68821716*np.pi/180,5.11103201*np.pi/180,90.00195312*np.pi/180,-90.00085449*np.pi/180]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user