|
@@ -63,18 +63,19 @@ class MoveIt_Control:
|
|
|
|
|
|
self.go_home()
|
|
|
self.home_pose=self.get_now_pose()
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
def plan_cartesian_path_LLL(self,point_s,point_e,waypoints,trajectory,trajectory_with_type,a=1,v=1):
|
|
|
fraction = 0.0
|
|
|
maxtries = 50
|
|
|
attempts = 0
|
|
|
|
|
|
|
|
|
- pose = self.arm.get_current_pose(self.end_effector_link).pose
|
|
|
- wpose = deepcopy(pose)
|
|
|
+ start_pose = self.arm.get_current_pose(self.end_effector_link).pose
|
|
|
+ wpose = deepcopy(start_pose)
|
|
|
waypoint=[]
|
|
|
- print(waypoint)
|
|
|
+
|
|
|
if waypoints:
|
|
|
wpose.position.x=waypoints[-1].position.x
|
|
|
wpose.position.y=waypoints[-1].position.y
|
|
@@ -84,16 +85,6 @@ class MoveIt_Control:
|
|
|
wpose.orientation.z=waypoints[-1].orientation.z
|
|
|
wpose.orientation.w=waypoints[-1].orientation.w
|
|
|
waypoint.append(deepcopy(wpose))
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
wpose.position.x=point_s[0]
|
|
@@ -121,19 +112,23 @@ class MoveIt_Control:
|
|
|
(plan, fraction) = self.arm.compute_cartesian_path(
|
|
|
waypoint,
|
|
|
0.001,
|
|
|
- 0.0,
|
|
|
- True)
|
|
|
+
|
|
|
+ True,
|
|
|
+ None)
|
|
|
attempts += 1
|
|
|
|
|
|
if fraction == 1.0 :
|
|
|
rospy.loginfo("Path computed successfully.")
|
|
|
|
|
|
trajj = plan
|
|
|
+ retimed_planed=self.retime_plan(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)
|
|
|
- moveit_server.arm.execute(trajj)
|
|
|
+ rospy.loginfo("开始执行")
|
|
|
+ moveit_server.arm.execute(retimed_planed)
|
|
|
+ rospy.loginfo("执行结束")
|
|
|
trajectory_with_type.append(trajj_with_type)
|
|
|
else:
|
|
|
rospy.loginfo(
|
|
@@ -147,7 +142,18 @@ class MoveIt_Control:
|
|
|
|
|
|
return waypoints,trajectory,trajectory_with_type
|
|
|
|
|
|
+ def retime_plan(self,traj):
|
|
|
+ current_state = self.arm.get_current_state()
|
|
|
+
|
|
|
+ retimed_traj = self.arm.retime_trajectory(
|
|
|
+ current_state,
|
|
|
+ traj,
|
|
|
+ velocity_scaling_factor=0.3,
|
|
|
+ acceleration_scaling_factor=1)
|
|
|
+
|
|
|
+ return retimed_traj
|
|
|
|
|
|
+
|
|
|
def get_now_pose(self):
|
|
|
|
|
|
current_pose = self.arm.get_current_pose(self.end_effector_link).pose
|
|
@@ -272,8 +278,6 @@ class MoveIt_Control:
|
|
|
return points,trajectory,trajectory_with_type,er
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
|
|
|
@decorator_time
|
|
|
def go_home(self,a=1,v=1):
|
|
@@ -285,9 +289,20 @@ class MoveIt_Control:
|
|
|
self.arm.go()
|
|
|
rospy.loginfo("go_home end")
|
|
|
|
|
|
+
|
|
|
+ def go_ready(self,a=1,v=1):
|
|
|
+ rospy.loginfo("go_ready start")
|
|
|
+ self.arm.set_max_acceleration_scaling_factor(a)
|
|
|
+ self.arm.set_max_velocity_scaling_factor(v)
|
|
|
+ self.arm.set_named_target('ready')
|
|
|
+ rospy.loginfo("get_ready end")
|
|
|
+ self.arm.go()
|
|
|
+ rospy.loginfo("go_ready end")
|
|
|
|
|
|
|
|
|
+ @decorator_time
|
|
|
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()
|
|
@@ -296,6 +311,8 @@ class MoveIt_Control:
|
|
|
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)
|
|
@@ -321,13 +338,14 @@ class MoveIt_Control:
|
|
|
|
|
|
rospy.loginfo("第%d条焊缝规划完毕",i+1)
|
|
|
rospy.loginfo("*******************")
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ rospy.loginfo("All of The trajectory Plan successfully")
|
|
|
+ rospy.loginfo("*******************")
|
|
|
+ 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)
|
|
|
- rospy.loginfo("All of The trajectory Plan successfully")
|
|
|
return trajectory,traj_merge,trajectory_with_type_merge
|
|
|
|
|
|
|
|
@@ -365,7 +383,6 @@ def mark_the_traj(traj,TYPE,SEQUENCE):
|
|
|
]
|
|
|
return traj_with_type
|
|
|
|
|
|
-
|
|
|
def merge_trajectories(trajectories):
|
|
|
if not trajectories:
|
|
|
return None
|
|
@@ -482,12 +499,9 @@ def get_user_input():
|
|
|
|
|
|
return vv
|
|
|
except Exception as e:
|
|
|
- rospy.logerr(f"发生错误:{e}")
|
|
|
+ rospy.logerr(f"发生错误:{e}")
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
if __name__ =="__main__":
|
|
|
|
|
|
|
|
@@ -502,9 +516,10 @@ if __name__ =="__main__":
|
|
|
|
|
|
|
|
|
trajectory,trajectory_merge,trajectory_with_type_merge = moveit_server.path_planning(folder_path)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ rospy.loginfo("开始执行合并后轨迹")
|
|
|
+ moveit_server.arm.execute(trajectory_merge)
|
|
|
+ rospy.loginfo("合并后轨迹执行完毕")
|
|
|
|
|
|
rospy.set_param("sign_control",0)
|