|
@@ -14,11 +14,11 @@ from rospy.exceptions import ROSException
|
|
from std_srvs.srv import Empty
|
|
from std_srvs.srv import Empty
|
|
from rospy.service import ServiceException
|
|
from rospy.service import ServiceException
|
|
|
|
|
|
|
|
+import actionlib_msgs.msg._GoalStatusArray
|
|
|
|
+import sys
|
|
def wait_for_topic(topic_name, message_type):
|
|
def wait_for_topic(topic_name, message_type):
|
|
try:
|
|
try:
|
|
- rospy.loginfo("等待场景地图加载完毕...")
|
|
|
|
message = rospy.wait_for_message(topic_name, message_type, timeout=None)
|
|
message = rospy.wait_for_message(topic_name, message_type, timeout=None)
|
|
- rospy.loginfo(f"场景地图已加载完毕")
|
|
|
|
return message
|
|
return message
|
|
except rospy.ROSException as e:
|
|
except rospy.ROSException as e:
|
|
rospy.logerr(f"等待话题 {topic_name} 时程序被中断: {e}")
|
|
rospy.logerr(f"等待话题 {topic_name} 时程序被中断: {e}")
|
|
@@ -54,20 +54,29 @@ if __name__ == "__main__":
|
|
rospy.loginfo("yaw = %s",rospy.get_param("yaw")/np.pi*180)
|
|
rospy.loginfo("yaw = %s",rospy.get_param("yaw")/np.pi*180)
|
|
rospy.loginfo("pitch_of_Horizontalweld = %s",rospy.get_param("pitch_of_Horizontalweld")/np.pi*180)
|
|
rospy.loginfo("pitch_of_Horizontalweld = %s",rospy.get_param("pitch_of_Horizontalweld")/np.pi*180)
|
|
rospy.loginfo("pitch_of_Verticalweld = %s",rospy.get_param("pitch_of_Verticalweld")/np.pi*180)
|
|
rospy.loginfo("pitch_of_Verticalweld = %s",rospy.get_param("pitch_of_Verticalweld")/np.pi*180)
|
|
|
|
+ rospy.loginfo("等待rviz启动")
|
|
|
|
+ wait_for_topic("/execute_trajectory/status",actionlib_msgs.msg.GoalStatusArray)
|
|
|
|
|
|
- while True:
|
|
|
|
|
|
+ while not rospy.is_shutdown():
|
|
sign_control = str(rospy.get_param("sign_control"))
|
|
sign_control = str(rospy.get_param("sign_control"))
|
|
if sign_control == "0":
|
|
if sign_control == "0":
|
|
if not waited_once:
|
|
if not waited_once:
|
|
print("等待点云数据准备完成...")
|
|
print("等待点云数据准备完成...")
|
|
|
|
+ sys.stdin.flush()#清空键盘缓冲区
|
|
|
|
+ aaa=input("请选择 1-2: ")
|
|
|
|
+ if(aaa =='1' or aaa=='2'):
|
|
|
|
+ rospy.set_param("sign_control",aaa)
|
|
|
|
+ else:
|
|
|
|
+ command.close_rviz("/usr/bin/python3 /opt/ros/noetic/bin/roslaunch lstrobot_moveit_config_0605 demo.launch")
|
|
|
|
+ exit(0)
|
|
waited_once = True
|
|
waited_once = True
|
|
elif sign_control == "1":
|
|
elif sign_control == "1":
|
|
# 重置参数
|
|
# 重置参数
|
|
- rospy.set_param("sign_control",0)
|
|
|
|
|
|
+ #rospy.set_param("sign_control",0) #在轨迹规划里重置 防止重复调用
|
|
rospy.set_param("sign_traj_accepted",0)
|
|
rospy.set_param("sign_traj_accepted",0)
|
|
# 清除场景
|
|
# 清除场景
|
|
clear_octomap()
|
|
clear_octomap()
|
|
- #点云发布
|
|
|
|
|
|
+ #点云计算并发布
|
|
process = multiprocessing.Process(target=command.launch_publish_pointcloud_background)
|
|
process = multiprocessing.Process(target=command.launch_publish_pointcloud_background)
|
|
process.start()
|
|
process.start()
|
|
#计算焊接顺序和焊接姿态
|
|
#计算焊接顺序和焊接姿态
|
|
@@ -75,27 +84,33 @@ if __name__ == "__main__":
|
|
hanqiangpose.run()
|
|
hanqiangpose.run()
|
|
|
|
|
|
# 等待 /move_group/monitored_planning_scene 话题发布消息
|
|
# 等待 /move_group/monitored_planning_scene 话题发布消息
|
|
|
|
+ rospy.loginfo("等待场景地图加载完毕...")
|
|
wait_for_topic('/move_group/monitored_planning_scene', PlanningScene)
|
|
wait_for_topic('/move_group/monitored_planning_scene', PlanningScene)
|
|
|
|
+ rospy.loginfo(f"场景地图已加载完毕")
|
|
rospy.set_param("sign_pointcloud",1)
|
|
rospy.set_param("sign_pointcloud",1)
|
|
#rospy.loginfo("终止点云发布,关闭发布窗口")
|
|
#rospy.loginfo("终止点云发布,关闭发布窗口")
|
|
|
|
|
|
rospy.loginfo("运行moveitserver2.py")
|
|
rospy.loginfo("运行moveitserver2.py")
|
|
process = multiprocessing.Process(target=command.launch_moveit_control_server_background)
|
|
process = multiprocessing.Process(target=command.launch_moveit_control_server_background)
|
|
process.start()
|
|
process.start()
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ while rospy.get_param("sign_control"):
|
|
|
|
+ pass
|
|
#运行结束,重置参数
|
|
#运行结束,重置参数
|
|
waited_once = False
|
|
waited_once = False
|
|
|
|
|
|
elif sign_control == "2":
|
|
elif sign_control == "2":
|
|
# 重置参数
|
|
# 重置参数
|
|
- rospy.set_param("sign_control",0)
|
|
|
|
|
|
+ #rospy.set_param("sign_control",0)
|
|
rospy.set_param("sign_traj_accepted",0)
|
|
rospy.set_param("sign_traj_accepted",0)
|
|
|
|
|
|
process = multiprocessing.Process(target=command.launch_moveit_control_server_background)
|
|
process = multiprocessing.Process(target=command.launch_moveit_control_server_background)
|
|
process.start()
|
|
process.start()
|
|
|
|
|
|
|
|
+ while rospy.get_param("sign_control"):
|
|
|
|
+ pass
|
|
#运行结束,重置参数
|
|
#运行结束,重置参数
|
|
waited_once = False
|
|
waited_once = False
|
|
-
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|