|
@@ -23,7 +23,7 @@ from tf.transformations import euler_from_quaternion,quaternion_from_euler,quate
|
|
|
import math
|
|
|
import traceback
|
|
|
from lstrobot_planning.msg import JointTrajectoryPoint_ex,JointTrajectory_ex
|
|
|
-
|
|
|
+import json
|
|
|
|
|
|
pi = np.pi
|
|
|
|
|
@@ -436,43 +436,42 @@ class py_msgs():
|
|
|
xyz_list=[]
|
|
|
type=[]
|
|
|
|
|
|
-def ROS2PY_msgs(msgs,m_sr):
|
|
|
+def ROS2PY_msgs(msgs, m_sr):
|
|
|
for i in range(len(msgs.points)):
|
|
|
py_msgs.point.xyz_list.append(msgs.points[i].positions)
|
|
|
py_msgs.point.type.append(msgs.points[i].type)
|
|
|
- py_msgs.fail=m_sr.hf_fail.copy()
|
|
|
- py_msgs.shun_xv=msgs.points[0].sequence.copy()
|
|
|
+ py_msgs.fail = m_sr.hf_fail.copy()
|
|
|
+ py_msgs.shun_xv = msgs.points[0].sequence.copy()
|
|
|
|
|
|
# for i in range(len(py_msgs.point.type)):
|
|
|
# print(py_msgs.point.xyz_list[i])
|
|
|
# print(py_msgs.point.type[i])
|
|
|
- print(py_msgs.shun_xv)
|
|
|
- print(py_msgs.fial)
|
|
|
|
|
|
+ message = {
|
|
|
+ 'positions': py_msgs.point.xyz_list, # 规划路径点结果
|
|
|
+ 'flags': py_msgs.point.type, # 规划路径点的类型,焊接点移动点
|
|
|
+ 'weld_order': py_msgs.shun_xv, # 规划路径顺序
|
|
|
+ 'failed': py_msgs.fail, # 规划路径失败的焊缝
|
|
|
+ }
|
|
|
+ return json.dumps(message)
|
|
|
# for i in range(len(py_msgs.point.type)):
|
|
|
# moveit_server.move_j(py_msgs.point.xyz_list[i])
|
|
|
# #input("任意键继续")
|
|
|
|
|
|
if __name__ =="__main__":
|
|
|
+ # from redis_publisher import Publisher
|
|
|
+ # publisher = Publisher()
|
|
|
|
|
|
folder_path = rospy.get_param("folder_path")
|
|
|
- # 初始化ROS节点
|
|
|
rospy.init_node('moveit_control_server', anonymous=False)
|
|
|
moveit_server = MoveIt_Control(is_use_gripper=False)
|
|
|
|
|
|
welding_sequence = rospy.get_param('welding_sequence')
|
|
|
trajectory,trajectory_merge,trajectory_with_type_merge = moveit_server.path_planning(folder_path)
|
|
|
- # trajectory,trajectory_merge,trajectory_with_type_merge = moveit_server.path_planning_test(folder_path,1,True)
|
|
|
- #执行动作
|
|
|
-
|
|
|
- #ROS2PY_msgs(trajectory_with_type_merge,moveit_server)
|
|
|
-
|
|
|
- #moveit_server.arm.execute(trajectory_merge)
|
|
|
|
|
|
+ # plan_result = ROS2PY_msgs(trajectory_with_type_merge, moveit_server)
|
|
|
+ # publisher.pub_plan_result(plan_result)
|
|
|
|
|
|
- # for i in range(1 * 2 - 0): #执行到第i条焊缝
|
|
|
- # moveit_server.arm.execute(trajectory[i])
|
|
|
+ moveit_server.arm.execute(trajectory_merge)
|
|
|
|
|
|
- #发布规划完毕的轨迹信息
|
|
|
- #pub_trajectories(trajectory_with_type_merge)
|
|
|
rospy.set_param("sign_control",0)
|