|
@@ -60,7 +60,7 @@ class MoveIt_Control:
|
|
|
|
|
|
self.arm.set_num_planning_attempts(10)
|
|
|
# 机械臂初始姿态
|
|
|
- #self.move_j()
|
|
|
+ #self.move_j() #备注,是否可以用move_j代替go_home来节省时间(待测试)
|
|
|
self.go_home()
|
|
|
self.home_pose=self.get_now_pose()
|
|
|
|
|
@@ -197,7 +197,7 @@ class MoveIt_Control:
|
|
|
self.arm.clear_path_constraints()
|
|
|
|
|
|
return points,trajectory,trajectory_with_type,er
|
|
|
-
|
|
|
+
|
|
|
#TODO move_pl
|
|
|
def move_pl(self,point,points,trajectory,trajectory_with_type,a=1,v=1):#焊缝的规划 只规划当前的点到上一个点
|
|
|
|
|
@@ -213,7 +213,7 @@ class MoveIt_Control:
|
|
|
|
|
|
self.arm.set_pose_target(point, self.end_effector_link)#设定目标点为传入的点
|
|
|
|
|
|
- # 创建路径约束
|
|
|
+ #创建路径约束
|
|
|
path_constraints = self.create_path_constraints(points[-1],point)#将最后一个点和输入的点(焊缝的起始点)做圆柱轨迹约束
|
|
|
self.arm.set_path_constraints(path_constraints)#设定约束
|
|
|
|
|
@@ -545,6 +545,7 @@ def ROS2PY_msgs(msgs, m_sr):
|
|
|
# moveit_server.move_j(py_msgs.point.xyz_list[i])
|
|
|
# #input("任意键继续")
|
|
|
|
|
|
+#TODO get_valid_input
|
|
|
def get_valid_input(factor, default):
|
|
|
while True:
|
|
|
user_input=input(factor)
|
|
@@ -585,30 +586,6 @@ def ROS2_msgs(msgs, m_sr):
|
|
|
for point in py_msgs.point.xyz_list:
|
|
|
file.write(' '.join(str(value) for value in point)+ "\n")
|
|
|
|
|
|
-# def write_ee(msgs, m_sr):
|
|
|
-# for i in range(len(msgs.points)):
|
|
|
-# py_msgs.point.xyz_list.append(msgs.points[i].positions)
|
|
|
-
|
|
|
-# f_p1 = os.path.join(folder_path, 'ee_pos.txt')
|
|
|
-# with open(f_p1,'w') as file:
|
|
|
-# for point in py_msgs.point.xyz_list:
|
|
|
-# #更新机械臂状态
|
|
|
-# state=m_sr.arm.get_current_state()
|
|
|
-# #state.joint_state.position=point
|
|
|
-
|
|
|
-# #获取末端执行器的位姿
|
|
|
-# fk_result=m_sr.arm.get_current_pose(moveit_server.end_effector_link)
|
|
|
-
|
|
|
-# #获取位置信息
|
|
|
-# position=fk_result.pose.position
|
|
|
-# orientation=fk_result.pose.orientation
|
|
|
-
|
|
|
-# #格式化数据
|
|
|
-# pose_data = f"Position: x={position.x}, y={position.y}, z={position.z}\n"
|
|
|
-# pose_data += f"Orientation (Quaternion): x={orientation.x}, y={orientation.y}, z={orientation.z}, w={orientation.w}\n"
|
|
|
-# pose_data += "-" * 50 + "\n"
|
|
|
-
|
|
|
-# file.write(pose_data)
|
|
|
|
|
|
if __name__ =="__main__":
|
|
|
# from redis_publisher import Publisher
|
|
@@ -619,14 +596,14 @@ if __name__ =="__main__":
|
|
|
moveit_server = MoveIt_Control(is_use_gripper=False)
|
|
|
welding_sequence = rospy.get_param('welding_sequence')
|
|
|
|
|
|
-
|
|
|
- speed_v=get_user_input()
|
|
|
- rospy.loginfo(f"用户输入的速度缩放因子为{speed_v}")
|
|
|
+ speed_v=1.0
|
|
|
+ # speed_v=get_user_input()
|
|
|
+ # rospy.loginfo(f"用户输入的速度缩放因子为{speed_v}")
|
|
|
|
|
|
trajectory,trajectory_merge,trajectory_with_type_merge = moveit_server.path_planning(folder_path)
|
|
|
- ROS2_msgs(trajectory_with_type_merge,moveit_server)
|
|
|
+ #ROS2_msgs(trajectory_with_type_merge,moveit_server)
|
|
|
#write_ee(trajectory_with_type_merge, moveit_server)
|
|
|
|
|
|
moveit_server.arm.execute(trajectory_merge)
|
|
|
|
|
|
- rospy.set_param("sign_control",0)
|
|
|
+ rospy.set_param("sign_control",0)
|