Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

There's a problem when indexing robot.Pose()

#1
Hi,

There is something that's not right with the program. I am doing ONLINE PROGRAMMING with Kuka KRC 4.

If I do this:

            pose = self.robot.Pose()
            print(pose)
            a = pose[:3,:3]
            print(np.array(a))


where self.robot = self.robot = self.RDK.Item('KUKA KR 60-3', ITEM_TYPE_ROBOT) and np is for numpy.

The pose is this:

Pose(1718.216, 26.280, 1023.377,  -132.634, -31.332, -165.801):
[[ -0.828, 0.210, -0.520, 1718.216 ],
 [ -0.205, 0.750, 0.628, 26.280 ],
 [ 0.522, 0.627, -0.579, 1023.377 ],
 [ 0.000, 0.000, 0.000, 1.000 ]]

and a is this:

[[-0.82807276 -0.20474388  0.52189602]
 [ 0.20951249  0.75045489  0.62683489]
 [-0.52000002  0.62840863 -0.57853485]]

Why is it different? Note that there's a '-' sign on 0.210 when indexing and no negative sign on 0.520. These changes in the sign is messing with my program. Please let me know as soon as you can. Thanks.
#2
Hi Tharisata, 

I didn't use Numpy in a while but it seems to be your issue because everything looks fine without it. 

   

Jeremy
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel


#3
Hi Jeremy,

Apologies the previous post was wrong: the printed version is np.array(a) not a.

Yes, the Pose is fine when you index as you did. However, if you call np.array on it or even do a.tolist() it changes certain values into negative numbers.

I don't think this is a Numpy situation as it doesn't work for .tolist() either. A way around this was to do this, by indexing each row separately and calling numpy:

   def _get_rot33(self, pose):
       """
       there is a problem with pose matrix - it changes the sign when converted
       to numpy array. This method combats that.
       """
       rot_mat = pose[:3,:3]
       row0 = np.transpose(np.array(rot_mat[0])) # ndim 1x3
       row1 = np.transpose(np.array(rot_mat[1]))
       row2 = np.transpose(np.array(rot_mat[2]))

       rot33 = np.vstack((row0,row1,row2))
       return rot33

...but this shouldn't have been a problem in the first place. Perhaps it's in the way RoboDK defines Pose()?
  




Users browsing this thread:
1 Guest(s)