|
@@ -22,7 +22,7 @@ import tf
|
|
from tf.transformations import euler_from_quaternion,quaternion_from_euler,quaternion_from_euler, quaternion_multiply
|
|
from tf.transformations import euler_from_quaternion,quaternion_from_euler,quaternion_from_euler, quaternion_multiply
|
|
import math
|
|
import math
|
|
import traceback
|
|
import traceback
|
|
-from lstrobot_planning.msg import JointTrajectoryPoint_ex,JointTrajectory_ex
|
|
|
|
|
|
+from lst_robot_r.msg import JointTrajectoryPoint_ex,JointTrajectory_ex
|
|
import json
|
|
import json
|
|
import termios
|
|
import termios
|
|
from decorator_time import decorator_time
|
|
from decorator_time import decorator_time
|
|
@@ -112,9 +112,8 @@ class MoveIt_Control:
|
|
(plan, fraction) = self.arm.compute_cartesian_path(
|
|
(plan, fraction) = self.arm.compute_cartesian_path(
|
|
waypoint, # waypoint poses,路点列表
|
|
waypoint, # waypoint poses,路点列表
|
|
0.001, # eef_step,终端步进值
|
|
0.001, # eef_step,终端步进值
|
|
- #0.0, # jump_threshold,跳跃阈值
|
|
|
|
- True,
|
|
|
|
- None) # avoid_collisions,避障规划
|
|
|
|
|
|
+ 0.0, # jump_threshold,跳跃阈值
|
|
|
|
+ True) # avoid_collisions,避障规划
|
|
attempts += 1
|
|
attempts += 1
|
|
|
|
|
|
if fraction == 1.0 :
|
|
if fraction == 1.0 :
|
|
@@ -335,9 +334,18 @@ class MoveIt_Control:
|
|
point11 = [start_point[0]/1000, start_point[1]/1000, start_point[2]/1000, q1[0],q1[1],q1[2],q1[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]]
|
|
point22 = [end_point[0]/1000, end_point[1]/1000, end_point[2]/1000, q2[0],q2[1],q2[2],q2[3]]
|
|
way_points,trajectory,trajectory_with_type = self.plan_cartesian_path_LLL(point11,point22,way_points,trajectory,trajectory_with_type,v=speed_v)
|
|
way_points,trajectory,trajectory_with_type = self.plan_cartesian_path_LLL(point11,point22,way_points,trajectory,trajectory_with_type,v=speed_v)
|
|
-
|
|
|
|
|
|
+
|
|
rospy.loginfo("第%d条焊缝规划完毕",i+1)
|
|
rospy.loginfo("第%d条焊缝规划完毕",i+1)
|
|
rospy.loginfo("*******************")
|
|
rospy.loginfo("*******************")
|
|
|
|
+
|
|
|
|
+ #向上移动末端执行器
|
|
|
|
+ if i<len(all_data)-1:
|
|
|
|
+ up_value=0.1
|
|
|
|
+ point_up=[point22[0], point22[1], point22[2]-up_value, point22[3], point22[4],point22[5],point22[6]]
|
|
|
|
+ way_points, trajectory, trajectory_with_type = self.plan_cartesian_path_LLL(point22,point_up,way_points,trajectory,trajectory_with_type,v=speed_v)
|
|
|
|
+ rospy.loginfo("末端执行器上移完毕")
|
|
|
|
+ rospy.loginfo("*******************")
|
|
|
|
+
|
|
rospy.loginfo("All of The trajectory Plan successfully")
|
|
rospy.loginfo("All of The trajectory Plan successfully")
|
|
rospy.loginfo("*******************")
|
|
rospy.loginfo("*******************")
|
|
if gohome:
|
|
if gohome:
|
|
@@ -455,6 +463,7 @@ def ROS2PY_msgs(msgs, m_sr):
|
|
py_msgs.fail = m_sr.hf_fail.copy()
|
|
py_msgs.fail = m_sr.hf_fail.copy()
|
|
py_msgs.shun_xv = msgs.points[0].sequence.copy()
|
|
py_msgs.shun_xv = msgs.points[0].sequence.copy()
|
|
|
|
|
|
|
|
+ # 打印规划信息
|
|
# for i in range(len(py_msgs.point.type)):
|
|
# for i in range(len(py_msgs.point.type)):
|
|
# print(py_msgs.point.xyz_list[i])
|
|
# print(py_msgs.point.xyz_list[i])
|
|
# print(py_msgs.point.type[i])
|
|
# print(py_msgs.point.type[i])
|
|
@@ -499,7 +508,17 @@ def get_user_input():
|
|
#rospy.loginfo(f"用户输入的速度缩放因子为{vv}")
|
|
#rospy.loginfo(f"用户输入的速度缩放因子为{vv}")
|
|
return vv
|
|
return vv
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- rospy.logerr(f"发生错误:{e}")
|
|
|
|
|
|
+ rospy.logerr(f"发生错误:{e}")
|
|
|
|
+
|
|
|
|
+#TODO 获取规划路径点结果,写入outtt.txt
|
|
|
|
+def ROS2_msgs_write(msgs, m_sr):
|
|
|
|
+ for i in range(len(msgs.points)):
|
|
|
|
+ py_msgs.point.xyz_list.append(msgs.points[i].positions)
|
|
|
|
+
|
|
|
|
+ f_p = os.path.join(folder_path, 'outtt.txt')
|
|
|
|
+ with open(f_p,'w') as file:
|
|
|
|
+ for point in py_msgs.point.xyz_list:
|
|
|
|
+ file.write(' '.join(str(value) for value in point)+ "\n")
|
|
|
|
|
|
|
|
|
|
if __name__ =="__main__":
|
|
if __name__ =="__main__":
|
|
@@ -517,9 +536,10 @@ if __name__ =="__main__":
|
|
|
|
|
|
trajectory,trajectory_merge,trajectory_with_type_merge = moveit_server.path_planning(folder_path)
|
|
trajectory,trajectory_merge,trajectory_with_type_merge = moveit_server.path_planning(folder_path)
|
|
|
|
|
|
- #moveit_server.go_ready()
|
|
|
|
|
|
+ #moveit_server.go_ready() #合并后的轨迹也需要从ready点开始执行
|
|
rospy.loginfo("开始执行合并后轨迹")
|
|
rospy.loginfo("开始执行合并后轨迹")
|
|
moveit_server.arm.execute(trajectory_merge)
|
|
moveit_server.arm.execute(trajectory_merge)
|
|
|
|
+ #ROS2_msgs_write(trajectory_with_type_merge,moveit_server)
|
|
rospy.loginfo("合并后轨迹执行完毕")
|
|
rospy.loginfo("合并后轨迹执行完毕")
|
|
|
|
|
|
rospy.set_param("sign_control",0)
|
|
rospy.set_param("sign_control",0)
|