|
@@ -36,6 +36,16 @@ def clear_octomap():
|
|
|
except rospy.ServiceException as e:
|
|
|
rospy.logerr(f"Failed to call /clear_octomap service or it is not available: {e}. Skipping operation.")
|
|
|
|
|
|
+def check_file():
|
|
|
+ file_path = rospy.get_param("folder_path")
|
|
|
+ file_path_points = os.path.join(file_path, 'points.txt')
|
|
|
+ if os.path.exists(file_path_points):
|
|
|
+ result = True
|
|
|
+ else:
|
|
|
+ rospy.loginfo("焊缝数据不存在,请选择焊缝...")
|
|
|
+ result = False
|
|
|
+ return result
|
|
|
+
|
|
|
waited_once = False
|
|
|
tim_list=[]
|
|
|
|
|
@@ -93,58 +103,68 @@ if __name__ == "__main__":
|
|
|
# sys.exit(0)
|
|
|
waited_once = True
|
|
|
elif sign_control == "1":
|
|
|
- # 重置参数
|
|
|
- #rospy.set_param("sign_control",0) #在轨迹规划里重置 防止重复调用
|
|
|
- rospy.set_param("sign_traj_accepted",0)
|
|
|
- # 清除场景
|
|
|
- clear_octomap()
|
|
|
- # 点云计算并发布
|
|
|
- process = multiprocessing.Process(target=command.launch_publish_pointcloud_background)
|
|
|
- process.start()
|
|
|
- #计算焊接顺序和焊接姿态
|
|
|
- hjsx.run()
|
|
|
- hanqiangpose.run()
|
|
|
- # command.load_visual()
|
|
|
- # 等待 /move_group/monitored_planning_scene 话题发布消息
|
|
|
- rospy.loginfo("等待场景地图加载完毕...")
|
|
|
- wait_for_topic('/move_group/monitored_planning_scene', PlanningScene)
|
|
|
- rospy.loginfo("场景地图已加载完毕")
|
|
|
- rospy.set_param("sign_pointcloud",1)
|
|
|
- #rospy.loginfo("终止点云发布,关闭发布窗口")
|
|
|
- #input("按任意键继续...")
|
|
|
-
|
|
|
- rospy.loginfo("运行moveitserver2.py")
|
|
|
- process = multiprocessing.Process(target=command.launch_moveit_control_server_background)
|
|
|
- process.start()
|
|
|
-
|
|
|
- while rospy.get_param("sign_control"):
|
|
|
- pass
|
|
|
- #运行结束,重置参数
|
|
|
- waited_once = False
|
|
|
+ flag = check_file()
|
|
|
+ if flag:
|
|
|
+ # 重置参数
|
|
|
+ #rospy.set_param("sign_control",0) #在轨迹规划里重置 防止重复调用
|
|
|
+ rospy.set_param("sign_traj_accepted",0)
|
|
|
+ # 清除场景
|
|
|
+ clear_octomap()
|
|
|
+ # 点云计算并发布
|
|
|
+ process = multiprocessing.Process(target=command.launch_publish_pointcloud_background)
|
|
|
+ process.start()
|
|
|
+ #计算焊接顺序和焊接姿态
|
|
|
+ hjsx.run()
|
|
|
+ hanqiangpose.run()
|
|
|
+ # command.load_visual()
|
|
|
+ # 等待 /move_group/monitored_planning_scene 话题发布消息
|
|
|
+ rospy.loginfo("等待场景地图加载完毕...")
|
|
|
+ wait_for_topic('/move_group/monitored_planning_scene', PlanningScene)
|
|
|
+ rospy.loginfo("场景地图已加载完毕")
|
|
|
+ rospy.set_param("sign_pointcloud",1)
|
|
|
+ #rospy.loginfo("终止点云发布,关闭发布窗口")
|
|
|
+ #input("按任意键继续...")
|
|
|
+
|
|
|
+ rospy.loginfo("运行moveitserver2.py")
|
|
|
+ process = multiprocessing.Process(target=command.launch_moveit_control_server_background)
|
|
|
+ process.start()
|
|
|
+
|
|
|
+ while rospy.get_param("sign_control"):
|
|
|
+ pass
|
|
|
+ #运行结束,重置参数
|
|
|
+ waited_once = False
|
|
|
+ else:
|
|
|
+ rospy.set_param("sign_control",0)
|
|
|
+ waited_once = False
|
|
|
|
|
|
elif sign_control == "2":
|
|
|
- tim=time.time()
|
|
|
- rospy.set_param("time",0)
|
|
|
- # 重置参数
|
|
|
- #rospy.set_param("sign_control",0)
|
|
|
- rospy.set_param("sign_traj_accepted",0)
|
|
|
- hjsx.run()
|
|
|
- hanqiangpose.run()
|
|
|
- command.load_visual()
|
|
|
- process = multiprocessing.Process(target=command.launch_moveit_control_server_background)
|
|
|
- process.start()
|
|
|
-
|
|
|
- while rospy.get_param("sign_control"):
|
|
|
- pass
|
|
|
-
|
|
|
- tim=time.time()-tim
|
|
|
- tim_list.append(tim)
|
|
|
- print("-------------------------------------")
|
|
|
- print(f'第{rospy.get_param("cishu")}次规划:')
|
|
|
- print(tim_list)
|
|
|
- print("")
|
|
|
- #运行结束,重置参数
|
|
|
- waited_once = False
|
|
|
+ flag = check_file()
|
|
|
+ if flag:
|
|
|
+ tim=time.time()
|
|
|
+ rospy.set_param("time",0)
|
|
|
+ # 重置参数
|
|
|
+ #rospy.set_param("sign_control",0)
|
|
|
+ rospy.set_param("sign_traj_accepted",0)
|
|
|
+ hjsx.run()
|
|
|
+ hanqiangpose.run()
|
|
|
+ command.load_visual()
|
|
|
+ process = multiprocessing.Process(target=command.launch_moveit_control_server_background)
|
|
|
+ process.start()
|
|
|
+
|
|
|
+ while rospy.get_param("sign_control"):
|
|
|
+ pass
|
|
|
+
|
|
|
+ tim=time.time()-tim
|
|
|
+ tim_list.append(tim)
|
|
|
+ print("-------------------------------------")
|
|
|
+ print(f'第{rospy.get_param("cishu")}次规划:')
|
|
|
+ print(tim_list)
|
|
|
+ print("")
|
|
|
+ #运行结束,重置参数
|
|
|
+ waited_once = False
|
|
|
+ else:
|
|
|
+ rospy.set_param("sign_control",0)
|
|
|
+ waited_once = False
|
|
|
|
|
|
else:
|
|
|
rospy.loginfo("正在关闭规划程序...")
|