Upload 2 files
Browse files- Player_ECM.py +22 -16
Player_ECM.py
CHANGED
|
@@ -225,10 +225,16 @@ class VisPlayer(nn.Module):
|
|
| 225 |
|
| 226 |
def _init_rcm(self):
|
| 227 |
# TODO check matrix
|
| 228 |
-
self.tool_T_tip=np.array([[
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
|
| 233 |
eul=np.array([np.deg2rad(-90), 0., 0.])
|
| 234 |
eul= self.get_matrix_from_euler(eul)
|
|
@@ -514,6 +520,7 @@ class VisPlayer(nn.Module):
|
|
| 514 |
return np.matmul(rcm_action, self.tool_T_tip)
|
| 515 |
|
| 516 |
def _set_action(self, action, robot_pos, rot):
|
|
|
|
| 517 |
'''
|
| 518 |
robot_pos in cam coodinate
|
| 519 |
robot_rot in rcm; matrix
|
|
@@ -756,30 +763,29 @@ class VisPlayer(nn.Module):
|
|
| 756 |
[transform_2[1,0], transform_2[1,1], transform_2[1,2]],
|
| 757 |
[transform_2[2,0], transform_2[2,1], transform_2[2,2]]])
|
| 758 |
|
| 759 |
-
|
| 760 |
|
| 761 |
-
|
| 762 |
-
|
| 763 |
-
|
| 764 |
#print('tip_psm_pose before: ',tip_psm_pose)
|
| 765 |
-
|
| 766 |
#print('tip_psm_pose aft: ',tip_psm_pose)
|
| 767 |
|
| 768 |
-
np_m=
|
| 769 |
-
robot_pos=
|
| 770 |
#print("pre action pos tip rcm: ",robot_pos)
|
| 771 |
|
| 772 |
|
| 773 |
#robot_rot=np_m
|
| 774 |
robot_rot=self.get_euler_from_matrix(np_m)
|
| 775 |
-
robot_rot=self.convert_rot(robot_rot, cam_T_basePSM)
|
| 776 |
-
robot_rot=self.get_euler_from_matrix(robot_rot)
|
| 777 |
-
robot_pos=self.convert_pos(robot_pos,cam_T_basePSM)
|
| 778 |
print("pre action pos tip ecm: ",robot_pos)
|
| 779 |
# end
|
| 780 |
|
| 781 |
-
|
| 782 |
-
action=self._get_action(seg, depth ,robot_pos, robot_rot, jaw, self.goal)
|
| 783 |
print("finish get action")
|
| 784 |
print("action: ",action)
|
| 785 |
#obtained_object_position=player.convert_pos(action, basePSM_T_cam)
|
|
|
|
| 225 |
|
| 226 |
def _init_rcm(self):
|
| 227 |
# TODO check matrix
|
| 228 |
+
self.tool_T_tip=np.array([[0.0, 1.0, 0.0, 0.0],
|
| 229 |
+
[-1.0, 0.0, 0.0, 0.0],
|
| 230 |
+
[0.0, 0.0, 1.0, 0.0],
|
| 231 |
+
[0.0, 0.0, 0.0, 1.0]])
|
| 232 |
+
|
| 233 |
+
### check this matrix, this matrix was the originally used one, which is used for PSM
|
| 234 |
+
# np.array([[ 0. ,-1. , 0. , 0.],
|
| 235 |
+
# [ 0. , 0. , 1. , 0.],
|
| 236 |
+
# [-1. , 0. , 0. , 0.],
|
| 237 |
+
# [ 0. , 0. , 0. , 1.]])
|
| 238 |
|
| 239 |
eul=np.array([np.deg2rad(-90), 0., 0.])
|
| 240 |
eul= self.get_matrix_from_euler(eul)
|
|
|
|
| 520 |
return np.matmul(rcm_action, self.tool_T_tip)
|
| 521 |
|
| 522 |
def _set_action(self, action, robot_pos, rot):
|
| 523 |
+
########## TODO
|
| 524 |
'''
|
| 525 |
robot_pos in cam coodinate
|
| 526 |
robot_rot in rcm; matrix
|
|
|
|
| 763 |
[transform_2[1,0], transform_2[1,1], transform_2[1,2]],
|
| 764 |
[transform_2[2,0], transform_2[2,1], transform_2[2,2]]])
|
| 765 |
|
| 766 |
+
tip_ecm_pose=np.zeros((4,4))
|
| 767 |
|
| 768 |
+
tip_ecm_pose[3,3]=1
|
| 769 |
+
tip_ecm_pose[:3,:3]=np_m
|
| 770 |
+
tip_ecm_pose[:3,3]=robot_pos
|
| 771 |
#print('tip_psm_pose before: ',tip_psm_pose)
|
| 772 |
+
tip_ecm_pose=self.rcm2tip(tip_ecm_pose)
|
| 773 |
#print('tip_psm_pose aft: ',tip_psm_pose)
|
| 774 |
|
| 775 |
+
np_m=tip_ecm_pose[:3,:3]
|
| 776 |
+
robot_pos=tip_ecm_pose[:3,3]
|
| 777 |
#print("pre action pos tip rcm: ",robot_pos)
|
| 778 |
|
| 779 |
|
| 780 |
#robot_rot=np_m
|
| 781 |
robot_rot=self.get_euler_from_matrix(np_m)
|
| 782 |
+
# robot_rot=self.convert_rot(robot_rot, cam_T_basePSM)
|
| 783 |
+
# robot_rot=self.get_euler_from_matrix(robot_rot)
|
| 784 |
+
# robot_pos=self.convert_pos(robot_pos,cam_T_basePSM)
|
| 785 |
print("pre action pos tip ecm: ",robot_pos)
|
| 786 |
# end
|
| 787 |
|
| 788 |
+
action=self._get_action(seg, depth ,robot_pos, robot_rot, self.goal)
|
|
|
|
| 789 |
print("finish get action")
|
| 790 |
print("action: ",action)
|
| 791 |
#obtained_object_position=player.convert_pos(action, basePSM_T_cam)
|