duaro_demo_line.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 
5 from moveit_commander import MoveGroupCommander
6 
7 #from tork_moveit_tutorial import *
8 
9 def line_move(name, jbase):
10  group = MoveGroupCommander(name)
11  exec_vel = 1.0
12  diff = 0.1
13 
14  print(name + "do line_move")
15 
16  pos = group.get_current_pose()
17  print("pos")
18  print(pos.pose.position)
19  group.set_joint_value_target(jbase)
20  group.go()
21 
22  pos = group.get_current_pose()
23  print("pos init")
24  print(pos.pose.position)
25 
26  # x
27  lpos = pos
28  lpos.pose.position.x = pos.pose.position.x - diff
29  group.set_pose_target(lpos)
30  group.go()
31  lpos = group.get_current_pose()
32  print("pos -x")
33  print(lpos.pose.position)
34  lpos = pos
35  lpos.pose.position.x = pos.pose.position.x + diff
36  group.set_pose_target(lpos)
37  group.go()
38  lpos = group.get_current_pose()
39  print("pos +x")
40  print(lpos.pose.position)
41 
42  # y
43  lpos = pos
44  lpos.pose.position.y = pos.pose.position.y - diff
45  group.set_pose_target(lpos)
46  group.go()
47  lpos = group.get_current_pose()
48  print("pos -y")
49  print(lpos.pose.position)
50  lpos = pos
51  lpos.pose.position.y = pos.pose.position.y + diff
52  group.set_pose_target(lpos)
53  group.go()
54  lpos = group.get_current_pose()
55  print("pos +y")
56  print(lpos.pose.position)
57 
58  # z
59  lpos = pos
60  lpos.pose.position.z = pos.pose.position.z - diff*0.2
61  group.set_pose_target(lpos)
62  group.go()
63  lpos = group.get_current_pose()
64  print("pos -z")
65  print(lpos.pose.position)
66  lpos = pos
67  lpos.pose.position.z = pos.pose.position.z + diff*0.2
68  group.set_pose_target(lpos)
69  group.go()
70  lpos = group.get_current_pose()
71  print("pos +z")
72  print(lpos.pose.position)
73 
74 def both_line_move(name, eef1, eef2, jbase):
75  group = MoveGroupCommander(name)
76  exec_vel = 1.0
77  diff = 0.1
78 
79  print(name + "do line_move")
80 
81  pos1 = group.get_current_pose(eef1)
82  print("pos1")
83  print(pos1.pose.position)
84  pos2 = group.get_current_pose(eef2)
85  print("pos2")
86  print(pos2.pose.position)
87  group.set_joint_value_target(jbase)
88  group.go()
89 
90  pos1 = group.get_current_pose(eef1)
91  print("pos1 init")
92  print(pos1.pose.position)
93  pos2 = group.get_current_pose(eef2)
94  print("pos2 init")
95  print(pos2.pose.position)
96 
97  # x
98  lpos1 = pos1
99  lpos1.pose.position.x = pos1.pose.position.x - diff
100  group.set_pose_target(lpos1,eef1)
101  lpos2 = pos2
102  lpos2.pose.position.x = pos2.pose.position.x - diff
103  group.set_pose_target(lpos2,eef2)
104  group.go()
105  pos1 = group.get_current_pose(eef1)
106  print("pos1 -x")
107  print(pos1.pose.position)
108  pos2 = group.get_current_pose(eef2)
109  print("pos2 -x")
110  print(pos2.pose.position)
111  lpos1 = pos1
112  lpos1.pose.position.x = pos1.pose.position.x + diff
113  group.set_pose_target(lpos1,eef1)
114  lpos2 = pos2
115  lpos2.pose.position.x = pos2.pose.position.x + diff
116  group.set_pose_target(lpos2,eef2)
117  group.go()
118  pos1 = group.get_current_pose(eef1)
119  print("pos1 +x")
120  print(pos1.pose.position)
121  pos2 = group.get_current_pose(eef2)
122  print("pos2 +x")
123  print(pos2.pose.position)
124 
125  # y
126  lpos1 = pos1
127  lpos1.pose.position.y = pos1.pose.position.y - diff
128  group.set_pose_target(lpos1,eef1)
129  lpos2 = pos2
130  lpos2.pose.position.y = pos2.pose.position.y - diff
131  group.set_pose_target(lpos2,eef2)
132  group.go()
133  pos1 = group.get_current_pose(eef1)
134  print("pos1 -y")
135  print(pos1.pose.position)
136  pos2 = group.get_current_pose(eef2)
137  print("pos2 -y")
138  print(pos2.pose.position)
139  lpos1 = pos1
140  lpos1.pose.position.y = pos1.pose.position.y + diff
141  group.set_pose_target(lpos1,eef1)
142  lpos2 = pos2
143  lpos2.pose.position.y = pos2.pose.position.y + diff
144  group.set_pose_target(lpos2,eef2)
145  group.go()
146  pos1 = group.get_current_pose(eef1)
147  print("pos1 +y")
148  print(pos1.pose.position)
149  pos2 = group.get_current_pose(eef2)
150  print("pos2 +y")
151  print(pos2.pose.position)
152 
153  # z
154  lpos1 = pos1
155  lpos1.pose.position.z = pos1.pose.position.z - diff*0.2
156  group.set_pose_target(lpos1,eef1)
157  lpos2 = pos2
158  lpos2.pose.position.z = pos2.pose.position.z - diff*0.2
159  group.set_pose_target(lpos2,eef2)
160  group.go()
161  pos1 = group.get_current_pose(eef1)
162  print("pos1 -z")
163  print(pos1.pose.position)
164  pos2 = group.get_current_pose(eef2)
165  print("pos2 -z")
166  print(pos2.pose.position)
167  lpos1 = pos1
168  lpos1.pose.position.z = pos1.pose.position.z + diff*0.2
169  group.set_pose_target(lpos1,eef1)
170  lpos2 = pos2
171  lpos2.pose.position.z = pos2.pose.position.z + diff*0.2
172  group.set_pose_target(lpos2,eef2)
173  group.go()
174  pos1 = group.get_current_pose(eef1)
175  print("pos1 +z")
176  print(pos1.pose.position)
177  pos2 = group.get_current_pose(eef2)
178  print("pos2 +z")
179  print(pos2.pose.position)
180 
181 if __name__ == '__main__':
182 
183  rospy.init_node("duaro_line")
184 
185  line_move("lower_arm", [-1.6, 1.9, 0.045, 0.0])
186  line_move("upper_arm", [1.6, -1.9, 0.045, 0.0])
187  both_line_move("botharms", "lower_link_j4", "upper_link_j4", [-1.6, 1.9, 0.045, 0.0, 1.6, -1.9, 0.045, 0.0])
def line_move(name, jbase)
def both_line_move(name, eef1, eef2, jbase)


khi_duaro_moveit_config
Author(s): matsui_hiro
autogenerated on Fri Mar 26 2021 02:34:19