@@ -287,39 +287,34 @@ def set_parent(self, parent_object: Union['Object', None],
287287 parent = - 1 if parent_object is None else parent_object .get_handle ()
288288 sim .simSetObjectParent (self ._handle , parent , keep_in_place )
289289
290- def get_matrix (self , relative_to = None ) -> List [ float ] :
290+ def get_matrix (self , relative_to = None ) -> np . ndarray :
291291 """Retrieves the transformation matrix of this object.
292292
293293 :param relative_to: Indicates relative to which reference frame we want
294294 the matrix. Specify None to retrieve the absolute transformation
295295 matrix, or an Object relative to whose reference frame we want the
296296 transformation matrix.
297- :return: A list of 12 float values (the last row of the 4x4 matrix (
298- 0,0,0,1) is not needed).
299- The x-axis of the orientation component is (m[0], m[4], m[8])
300- The y-axis of the orientation component is (m[1], m[5], m[9])
301- The z-axis of the orientation component is (m[2], m[6], m[10])
302- The translation component is (m[3], m[7], m[11])
297+ :return: A 4x4 transformation matrix.
303298 """
304299 relto = - 1 if relative_to is None else relative_to .get_handle ()
305- return sim .simGetObjectMatrix (self ._handle , relto )
300+ m = sim .simGetObjectMatrix (self ._handle , relto )
301+ m_np = np .array (m ).reshape ((3 , 4 ))
302+ return np .concatenate ([m_np , [np .array ([0 , 0 , 0 , 1 ])]])
306303
307- def set_matrix (self , matrix : List [ float ] , relative_to = None ) -> None :
304+ def set_matrix (self , matrix : np . ndarray , relative_to = None ) -> None :
308305 """Sets the transformation matrix of this object.
309306
310307 :param relative_to: Indicates relative to which reference frame the
311308 matrix is specified. Specify None to set the absolute transformation
312309 matrix, or an Object relative to whose reference frame the
313310 transformation matrix is specified.
314- :param matrix: A list of 12 float values (the last row of the 4x4 matrix
315- (0,0,0,1) is not needed).
316- The x-axis of the orientation component is (m[0], m[4], m[8])
317- The y-axis of the orientation component is (m[1], m[5], m[9])
318- The z-axis of the orientation component is (m[2], m[6], m[10])
319- The translation component is (m[3], m[7], m[11])
311+ :param matrix: A 4x4 transformation matrix.
320312 """
313+ if not isinstance (matrix , np .ndarray ):
314+ raise ValueError ('Expected Numpy 4x4 array.' )
321315 relto = - 1 if relative_to is None else relative_to .get_handle ()
322- sim .simSetObjectMatrix (self ._handle , relto , matrix )
316+ sim .simSetObjectMatrix (
317+ self ._handle , relto , matrix [:3 , :4 ].reshape ((12 )).tolist ())
323318
324319 def is_collidable (self ) -> bool :
325320 """Whether the object is collidable or not.
0 commit comments