|
@@ -0,0 +1,561 @@
|
|
|
+
|
|
|
+import os
|
|
|
+import moveit_msgs.msg
|
|
|
+import rospy, sys
|
|
|
+import moveit_commander
|
|
|
+import moveit_msgs
|
|
|
+import tf.transformations
|
|
|
+
|
|
|
+from logging.handlers import RotatingFileHandler
|
|
|
+from moveit_commander import MoveGroupCommander, PlanningSceneInterface, RobotCommander
|
|
|
+from moveit_msgs.msg import PlanningScene, ObjectColor,CollisionObject, AttachedCollisionObject,RobotTrajectory
|
|
|
+from moveit_msgs.msg import RobotState
|
|
|
+from moveit_msgs.msg import Constraints, PositionConstraint, OrientationConstraint
|
|
|
+from shape_msgs.msg import SolidPrimitive
|
|
|
+from sensor_msgs.msg import JointState
|
|
|
+from trajectory_msgs.msg import JointTrajectory,JointTrajectoryPoint
|
|
|
+from geometry_msgs.msg import PoseStamped, Pose,Point,Vector3
|
|
|
+
|
|
|
+from copy import deepcopy
|
|
|
+import numpy as np
|
|
|
+import tf
|
|
|
+from tf.transformations import euler_from_quaternion,quaternion_from_euler,quaternion_from_euler, quaternion_multiply
|
|
|
+import math
|
|
|
+import traceback
|
|
|
+from lst_robot_r.msg import JointTrajectoryPoint_ex,JointTrajectory_ex
|
|
|
+import json
|
|
|
+import termios
|
|
|
+from redis_publisher import Publisher
|
|
|
+from scipy.interpolate import CubicSpline
|
|
|
+
|
|
|
+pi = np.pi
|
|
|
+
|
|
|
+class MoveIt_Control:
|
|
|
+
|
|
|
+ def __init__(self, is_use_gripper=False):
|
|
|
+ self.home_pose = []
|
|
|
+ self.hf_num = 0
|
|
|
+ self.hf_fail = []
|
|
|
+
|
|
|
+ moveit_commander.roscpp_initialize(sys.argv)
|
|
|
+ self.robot = moveit_commander.RobotCommander()
|
|
|
+
|
|
|
+ self.arm = moveit_commander.MoveGroupCommander('manipulator')
|
|
|
+ self.arm.set_goal_joint_tolerance(0.0001)
|
|
|
+ self.arm.set_goal_position_tolerance(0.0005)
|
|
|
+ self.arm.set_goal_orientation_tolerance(0.1)
|
|
|
+
|
|
|
+
|
|
|
+ self.end_effector_link = self.arm.get_end_effector_link()
|
|
|
+
|
|
|
+ self.reference_frame = 'base_link'
|
|
|
+ self.arm.set_pose_reference_frame(self.reference_frame)
|
|
|
+
|
|
|
+
|
|
|
+ self.arm.set_planning_time(10.0)
|
|
|
+ self.arm.allow_replanning(True)
|
|
|
+
|
|
|
+ self.arm.set_max_acceleration_scaling_factor(1)
|
|
|
+ self.arm.set_max_velocity_scaling_factor(1)
|
|
|
+
|
|
|
+ self.arm.set_num_planning_attempts(10)
|
|
|
+
|
|
|
+
|
|
|
+ self.go_home()
|
|
|
+ self.home_pose = self.get_now_pose()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ def smooth_trajectory(self, trajectory, num_points=0):
|
|
|
+
|
|
|
+ print(f"原始轨迹点数: {len(trajectory.joint_trajectory.points)}")
|
|
|
+ num_points = len(trajectory.joint_trajectory.points) // 4
|
|
|
+ print(f"当前轨迹点数:{num_points}")
|
|
|
+
|
|
|
+ smoothed_trajectory = []
|
|
|
+ for i in range(len(trajectory.joint_trajectory.joint_names)):
|
|
|
+ joint_trajectory = [point.positions[i] for point in trajectory.joint_trajectory.points]
|
|
|
+ cs = CubicSpline(range(len(joint_trajectory)), joint_trajectory)
|
|
|
+ smooth_joint_trajectory = cs(np.linspace(0, len(joint_trajectory) - 1, num_points))
|
|
|
+ smoothed_trajectory.append(smooth_joint_trajectory)
|
|
|
+
|
|
|
+
|
|
|
+ smoothed_trajectory_points = []
|
|
|
+ for j in range(num_points):
|
|
|
+ point = trajectory.joint_trajectory.points[0]
|
|
|
+ smoothed_point = JointTrajectoryPoint()
|
|
|
+ smoothed_point.positions = [smoothed_trajectory[i][j] for i in range(len(smoothed_trajectory))]
|
|
|
+ smoothed_point.time_from_start = rospy.Duration(j * 0.05)
|
|
|
+ smoothed_trajectory_points.append(smoothed_point)
|
|
|
+
|
|
|
+
|
|
|
+ trajectory.joint_trajectory.points = smoothed_trajectory_points
|
|
|
+
|
|
|
+
|
|
|
+ return trajectory
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ def plan_cartesian_path_LLL(self, point_s, point_e, waypoints, trajectory, trajectory_with_type, v=1):
|
|
|
+ fraction = 0.0
|
|
|
+ maxtries = 50
|
|
|
+ attempts = 0
|
|
|
+
|
|
|
+
|
|
|
+ start_pose = self.arm.get_current_pose(self.end_effector_link).pose
|
|
|
+ wpose = deepcopy(start_pose)
|
|
|
+ waypoint = []
|
|
|
+
|
|
|
+ if waypoints:
|
|
|
+ wpose.position.x = waypoints[-1].position.x
|
|
|
+ wpose.position.y = waypoints[-1].position.y
|
|
|
+ wpose.position.z = waypoints[-1].position.z
|
|
|
+ wpose.orientation.x = waypoints[-1].orientation.x
|
|
|
+ wpose.orientation.y = waypoints[-1].orientation.y
|
|
|
+ wpose.orientation.z = waypoints[-1].orientation.z
|
|
|
+ wpose.orientation.w = waypoints[-1].orientation.w
|
|
|
+ waypoint.append(deepcopy(wpose))
|
|
|
+
|
|
|
+
|
|
|
+ wpose.position.x = point_s[0]
|
|
|
+ wpose.position.y = point_s[1]
|
|
|
+ wpose.position.z = point_s[2]
|
|
|
+ wpose.orientation.x = point_s[3]
|
|
|
+ wpose.orientation.y = point_s[4]
|
|
|
+ wpose.orientation.z = point_s[5]
|
|
|
+ wpose.orientation.w = point_s[6]
|
|
|
+ waypoint.append(deepcopy(wpose))
|
|
|
+ waypoints.append(deepcopy(wpose))
|
|
|
+
|
|
|
+ wpose.position.x = point_e[0]
|
|
|
+ wpose.position.y = point_e[1]
|
|
|
+ wpose.position.z = point_e[2]
|
|
|
+ wpose.orientation.x = point_e[3]
|
|
|
+ wpose.orientation.y = point_e[4]
|
|
|
+ wpose.orientation.z = point_e[5]
|
|
|
+ wpose.orientation.w = point_e[6]
|
|
|
+ waypoint.append(deepcopy(wpose))
|
|
|
+ waypoints.append(deepcopy(wpose))
|
|
|
+
|
|
|
+
|
|
|
+ while fraction < 1.0 and attempts < maxtries:
|
|
|
+ (plan, fraction) = self.arm.compute_cartesian_path(
|
|
|
+ waypoint,
|
|
|
+ 0.001,
|
|
|
+ 0.0,
|
|
|
+ True)
|
|
|
+ attempts += 1
|
|
|
+
|
|
|
+ if fraction == 1.0 :
|
|
|
+ rospy.loginfo("Path computed successfully.")
|
|
|
+
|
|
|
+ trajj = plan
|
|
|
+
|
|
|
+ replan_traj = self.smooth_trajectory(trajj)
|
|
|
+ trajj_with_type = mark_the_traj(trajj, "during-l", welding_sequence)
|
|
|
+ trajj_with_type.points[-len(trajj.joint_trajectory.points)].type = "start"
|
|
|
+ trajj_with_type.points[-1].type = "end"
|
|
|
+ trajectory.append(trajj)
|
|
|
+ rospy.loginfo("开始执行")
|
|
|
+ moveit_server.arm.execute(replan_traj)
|
|
|
+ rospy.loginfo("执行结束")
|
|
|
+ trajectory_with_type.append(trajj_with_type)
|
|
|
+ err = 0
|
|
|
+ else:
|
|
|
+ err = 1
|
|
|
+ rospy.loginfo("fraction=" + str(fraction) + " failed after " + str(maxtries))
|
|
|
+
|
|
|
+ return waypoints, trajectory, trajectory_with_type, err
|
|
|
+
|
|
|
+
|
|
|
+ def plan_cartesian_path_point(self, point_ss, point_ee, waypoints, trajectory, trajectory_with_type, v=1):
|
|
|
+ fraction = 0.0
|
|
|
+ maxtries = 50
|
|
|
+ attempts = 0
|
|
|
+
|
|
|
+
|
|
|
+ start_pose = self.arm.get_current_pose(self.end_effector_link).pose
|
|
|
+ wpose = deepcopy(start_pose)
|
|
|
+ waypoint = []
|
|
|
+
|
|
|
+ if waypoints:
|
|
|
+ wpose.position.x = waypoints[-1].position.x
|
|
|
+ wpose.position.y = waypoints[-1].position.y
|
|
|
+ wpose.position.z = waypoints[-1].position.z
|
|
|
+ wpose.orientation.x = waypoints[-1].orientation.x
|
|
|
+ wpose.orientation.y = waypoints[-1].orientation.y
|
|
|
+ wpose.orientation.z = waypoints[-1].orientation.z
|
|
|
+ wpose.orientation.w = waypoints[-1].orientation.w
|
|
|
+ waypoint.append(deepcopy(wpose))
|
|
|
+
|
|
|
+
|
|
|
+ wpose.position.x = point_ss[0]
|
|
|
+ wpose.position.y = point_ss[1]
|
|
|
+ wpose.position.z = point_ss[2]
|
|
|
+ wpose.orientation.x = point_ss[3]
|
|
|
+ wpose.orientation.y = point_ss[4]
|
|
|
+ wpose.orientation.z = point_ss[5]
|
|
|
+ wpose.orientation.w = point_ss[6]
|
|
|
+ waypoint.append(deepcopy(wpose))
|
|
|
+ waypoints.append(deepcopy(wpose))
|
|
|
+
|
|
|
+ wpose.position.x = point_ee[0]
|
|
|
+ wpose.position.y = point_ee[1]
|
|
|
+ wpose.position.z = point_ee[2]
|
|
|
+ wpose.orientation.x = point_ee[3]
|
|
|
+ wpose.orientation.y = point_ee[4]
|
|
|
+ wpose.orientation.z = point_ee[5]
|
|
|
+ wpose.orientation.w = point_ee[6]
|
|
|
+ waypoint.append(deepcopy(wpose))
|
|
|
+ waypoints.append(deepcopy(wpose))
|
|
|
+
|
|
|
+
|
|
|
+ while fraction < 1.0 and attempts < maxtries:
|
|
|
+ (plan, fraction) = self.arm.compute_cartesian_path(
|
|
|
+ waypoint,
|
|
|
+ 0.005,
|
|
|
+ 0.0,
|
|
|
+ True)
|
|
|
+ attempts += 1
|
|
|
+
|
|
|
+ if fraction == 1.0 :
|
|
|
+ rospy.loginfo("Path computed successfully.")
|
|
|
+
|
|
|
+ trajj = plan
|
|
|
+
|
|
|
+
|
|
|
+ trajj_with_type = mark_the_traj(trajj, "during-p", welding_sequence)
|
|
|
+ trajectory.append(trajj)
|
|
|
+ rospy.loginfo("开始执行")
|
|
|
+ moveit_server.arm.execute(trajj)
|
|
|
+ rospy.loginfo("执行结束")
|
|
|
+ trajectory_with_type.append(trajj_with_type)
|
|
|
+ err = 0
|
|
|
+ else:
|
|
|
+ err = 1
|
|
|
+ rospy.loginfo("fraction=" + str(fraction) + " failed after " + str(maxtries))
|
|
|
+
|
|
|
+ return waypoints, trajectory, trajectory_with_type, err
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ def retime_plan(self, traj, v):
|
|
|
+ current_state = self.arm.get_current_state()
|
|
|
+
|
|
|
+ retimed_traj = self.arm.retime_trajectory(
|
|
|
+ current_state,
|
|
|
+ traj,
|
|
|
+ velocity_scaling_factor=0.03,
|
|
|
+ acceleration_scaling_factor=1)
|
|
|
+
|
|
|
+ return retimed_traj
|
|
|
+
|
|
|
+
|
|
|
+ def get_now_pose(self):
|
|
|
+
|
|
|
+ current_pose = self.arm.get_current_pose(self.end_effector_link).pose
|
|
|
+ pose = []
|
|
|
+ pose.append(current_pose.position.x)
|
|
|
+ pose.append(current_pose.position.y)
|
|
|
+ pose.append(current_pose.position.z)
|
|
|
+
|
|
|
+ pose.append(current_pose.orientation.x)
|
|
|
+ pose.append(current_pose.orientation.y)
|
|
|
+ pose.append(current_pose.orientation.z)
|
|
|
+ pose.append(current_pose.orientation.w)
|
|
|
+
|
|
|
+
|
|
|
+ return pose
|
|
|
+
|
|
|
+
|
|
|
+ def go_home(self, a=1, v=1):
|
|
|
+ rospy.loginfo("go_home start")
|
|
|
+ self.arm.set_max_acceleration_scaling_factor(a)
|
|
|
+ self.arm.set_max_velocity_scaling_factor(v)
|
|
|
+ self.arm.set_named_target('home')
|
|
|
+ rospy.loginfo("get home_point")
|
|
|
+ self.arm.go()
|
|
|
+ rospy.loginfo("go_home end")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ def go_home_justplan(self, trajectory, trajectory_with_type, a=1, v=1):
|
|
|
+ rospy.loginfo("go_home start")
|
|
|
+ self.arm.set_max_acceleration_scaling_factor(a)
|
|
|
+ self.arm.set_max_velocity_scaling_factor(v)
|
|
|
+ state = self.arm.get_current_state()
|
|
|
+ if trajectory:
|
|
|
+ state.joint_state.position = trajectory[-1].joint_trajectory.points[-1].positions
|
|
|
+ self.arm.set_start_state(state)
|
|
|
+ self.arm.set_named_target('home')
|
|
|
+ traj = self.arm.plan()
|
|
|
+ trajj = traj[1]
|
|
|
+ moveit_server.arm.execute(trajj)
|
|
|
+ rospy.loginfo("go_home end")
|
|
|
+ traj_with_type = mark_the_traj(trajj, "go-home", welding_sequence)
|
|
|
+ trajectory.append(trajj)
|
|
|
+ trajectory_with_type.append(traj_with_type)
|
|
|
+ return trajectory,trajectory_with_type
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ def path_planning(self, folder_path, gohome=True):
|
|
|
+ file_path_result = os.path.join(folder_path, 'result.txt')
|
|
|
+ all_data = process_welding_data(file_path_result)
|
|
|
+
|
|
|
+ way_points,trajectory,trajectory_with_type = [], [], []
|
|
|
+ for i in range(len(all_data)):
|
|
|
+ rospy.loginfo("共读取到%d条焊缝,开始规划第%d条", len(all_data), i+1)
|
|
|
+ start_point = all_data[i][0]
|
|
|
+ end_point = all_data[i][1]
|
|
|
+ q1 = all_data[i][2]
|
|
|
+ q2 = all_data[i][3]
|
|
|
+
|
|
|
+ point11 = [start_point[0]/1000, start_point[1]/1000, start_point[2]/1000, q1[0], q1[1], q1[2], q1[3]]
|
|
|
+ point22 = [end_point[0]/1000, end_point[1]/1000, end_point[2]/1000, q2[0], q2[1], q2[2], q2[3]]
|
|
|
+
|
|
|
+ up_value = -0.08
|
|
|
+ point_up = [point11[0], point11[1], point11[2]-up_value, point11[3], point11[4], point11[5], point11[6]]
|
|
|
+
|
|
|
+ way_points, trajectory, trajectory_with_type, error = self.plan_cartesian_path_point(point_up, point11, way_points, trajectory, trajectory_with_type, v=speed_v)
|
|
|
+ rospy.loginfo("末端执行器上移完毕")
|
|
|
+ rospy.loginfo("*******************")
|
|
|
+
|
|
|
+ if(error == 1):
|
|
|
+ rospy.loginfo("焊缝规划出现失败 清空路径列表")
|
|
|
+ rospy.loginfo("*******************")
|
|
|
+ trajectory.clear()
|
|
|
+ trajectory_with_type.clear()
|
|
|
+ break
|
|
|
+
|
|
|
+
|
|
|
+ way_points, trajectory, trajectory_with_type, error = self.plan_cartesian_path_LLL(point11, point22, way_points, trajectory, trajectory_with_type, v=speed_v)
|
|
|
+
|
|
|
+ rospy.loginfo("第%d条焊缝规划完毕", i+1)
|
|
|
+ rospy.loginfo("*******************")
|
|
|
+ if(error == 1):
|
|
|
+ rospy.loginfo("焊缝规划出现失败 清空路径列表")
|
|
|
+ rospy.loginfo("*******************")
|
|
|
+ trajectory.clear()
|
|
|
+ trajectory_with_type.clear()
|
|
|
+ break
|
|
|
+
|
|
|
+ if i<len(all_data):
|
|
|
+ up_value = -0.08
|
|
|
+ point_up = [point22[0], point22[1], point22[2]-up_value, point22[3], point22[4], point22[5], point22[6]]
|
|
|
+
|
|
|
+ way_points, trajectory, trajectory_with_type, error = self.plan_cartesian_path_point(point22, point_up, way_points,trajectory,trajectory_with_type,v=speed_v)
|
|
|
+ rospy.loginfo("末端执行器上移完毕")
|
|
|
+ rospy.loginfo("*******************")
|
|
|
+
|
|
|
+ if(error == 1):
|
|
|
+ rospy.loginfo("焊缝规划出现失败 清空路径列表")
|
|
|
+ rospy.loginfo("*******************")
|
|
|
+ trajectory.clear()
|
|
|
+ trajectory_with_type.clear()
|
|
|
+ break
|
|
|
+
|
|
|
+
|
|
|
+ if gohome:
|
|
|
+
|
|
|
+ trajectory, trajectory_with_type = self.go_home_justplan(trajectory, trajectory_with_type)
|
|
|
+
|
|
|
+ traj_merge = merge_trajectories(trajectory)
|
|
|
+ trajectory_with_type_merge = merge_trajectories_with_type(trajectory_with_type)
|
|
|
+ return trajectory, traj_merge, trajectory_with_type_merge
|
|
|
+
|
|
|
+
|
|
|
+def process_welding_data(filename):
|
|
|
+ all_data = []
|
|
|
+ with open(filename, 'r') as file:
|
|
|
+ for line in file:
|
|
|
+ parts = line.strip().split('/')
|
|
|
+ coordinates_and_poses = [part.split(',') for part in parts[1:]]
|
|
|
+
|
|
|
+ start_point = tuple(map(float, coordinates_and_poses[0][:3]))
|
|
|
+ end_point = tuple(map(float, coordinates_and_poses[1][:3]))
|
|
|
+ q1 = tuple(map(float, coordinates_and_poses[2][:4]))
|
|
|
+ q2 = tuple(map(float, coordinates_and_poses[3][:4]))
|
|
|
+
|
|
|
+
|
|
|
+ all_data.append((start_point, end_point, q1, q2))
|
|
|
+
|
|
|
+ return all_data
|
|
|
+
|
|
|
+
|
|
|
+def mark_the_traj(traj,TYPE,SEQUENCE):
|
|
|
+ traj_with_type = JointTrajectory_ex()
|
|
|
+ traj_with_type.header = traj.joint_trajectory.header
|
|
|
+ traj_with_type.joint_names = traj.joint_trajectory.joint_names
|
|
|
+ traj_with_type.points = [
|
|
|
+ JointTrajectoryPoint_ex(
|
|
|
+ positions = point.positions,
|
|
|
+ velocities = point.velocities,
|
|
|
+ accelerations = point.accelerations,
|
|
|
+ effort = point.effort,
|
|
|
+ type = TYPE,
|
|
|
+ sequence = SEQUENCE
|
|
|
+ ) for point in traj.joint_trajectory.points
|
|
|
+ ]
|
|
|
+ return traj_with_type
|
|
|
+
|
|
|
+
|
|
|
+def merge_trajectories(trajectories):
|
|
|
+ if not trajectories:
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
+ merged_trajectory = JointTrajectory()
|
|
|
+ merged_trajectory.header = trajectories[0].joint_trajectory.header
|
|
|
+ merged_trajectory.joint_names = trajectories[0].joint_trajectory.joint_names
|
|
|
+
|
|
|
+
|
|
|
+ last_time_from_start = rospy.Duration(0)
|
|
|
+
|
|
|
+
|
|
|
+ for traj in trajectories:
|
|
|
+
|
|
|
+ for point in traj.joint_trajectory.points:
|
|
|
+
|
|
|
+ new_point = deepcopy(point)
|
|
|
+
|
|
|
+ new_point.time_from_start += last_time_from_start
|
|
|
+ merged_trajectory.points.append(new_point)
|
|
|
+
|
|
|
+
|
|
|
+ if traj.joint_trajectory.points:
|
|
|
+ last_time_from_start = traj.joint_trajectory.points[-1].time_from_start + last_time_from_start
|
|
|
+
|
|
|
+ return merged_trajectory
|
|
|
+
|
|
|
+
|
|
|
+def merge_trajectories_with_type(trajectory_with_type):
|
|
|
+ if not trajectory_with_type:
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
+ merged_trajectory_with_type = JointTrajectory_ex()
|
|
|
+ merged_trajectory_with_type.header = trajectory_with_type[0].header
|
|
|
+ merged_trajectory_with_type.joint_names = trajectory_with_type[0].joint_names
|
|
|
+
|
|
|
+
|
|
|
+ last_time_from_start = rospy.Duration(0)
|
|
|
+
|
|
|
+
|
|
|
+ for traj in trajectory_with_type:
|
|
|
+
|
|
|
+ for point in traj.points:
|
|
|
+
|
|
|
+ new_point = deepcopy(point)
|
|
|
+
|
|
|
+ new_point.time_from_start += last_time_from_start
|
|
|
+ merged_trajectory_with_type.points.append(new_point)
|
|
|
+
|
|
|
+
|
|
|
+ if traj.points:
|
|
|
+ last_time_from_start = traj.points[-1].time_from_start + last_time_from_start
|
|
|
+
|
|
|
+ return merged_trajectory_with_type
|
|
|
+
|
|
|
+
|
|
|
+class py_msgs():
|
|
|
+ fial = []
|
|
|
+ shun_xv = []
|
|
|
+ class point():
|
|
|
+ xyz_list = []
|
|
|
+ type = []
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+def ROS2PY_msgs(msgs, m_sr):
|
|
|
+ for i in range(len(msgs.points)):
|
|
|
+
|
|
|
+ if msgs.points[i].type == "during-p" or msgs.points[i].type =="start" or msgs.points[i].type =="end":
|
|
|
+ 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()
|
|
|
+
|
|
|
+
|
|
|
+ print("关节轨迹点信息:")
|
|
|
+ for i in range(len(py_msgs.point.type)):
|
|
|
+ print(py_msgs.point.xyz_list[i])
|
|
|
+ print(py_msgs.point.type[i])
|
|
|
+
|
|
|
+ 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)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+if __name__ =="__main__":
|
|
|
+ publisher = Publisher()
|
|
|
+
|
|
|
+ folder_path = rospy.get_param("folder_path")
|
|
|
+ rospy.init_node('moveit_control_server', anonymous=False)
|
|
|
+ moveit_server = MoveIt_Control(is_use_gripper=False)
|
|
|
+ welding_sequence = rospy.get_param('welding_sequence')
|
|
|
+
|
|
|
+ speed_v = 0.001
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ trajectory, trajectory_merge, trajectory_with_type_merge = moveit_server.path_planning(folder_path)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ message = ROS2PY_msgs(trajectory_with_type_merge, moveit_server)
|
|
|
+ publisher.pub_plan_result(message)
|
|
|
+ print("路径规划信息已发布....")
|