Returns the 6D velocity (linear, angular) of a MuJoCo object. Args: object_id: Object identifier. Can be either integer ID or String name. object_type: The type of the object. Can be either a lowercase string (e.g. 'body', 'geom') or an `mjtObj` enum value. local_frame
(self, object_id, object_type, local_frame=False)
| 483 | return self.__copy__() |
| 484 | |
| 485 | def object_velocity(self, object_id, object_type, local_frame=False): |
| 486 | """Returns the 6D velocity (linear, angular) of a MuJoCo object. |
| 487 | |
| 488 | Args: |
| 489 | object_id: Object identifier. Can be either integer ID or String name. |
| 490 | object_type: The type of the object. Can be either a lowercase string |
| 491 | (e.g. 'body', 'geom') or an `mjtObj` enum value. |
| 492 | local_frame: Boolean specifiying whether the velocity is given in the |
| 493 | global (worldbody), or local (object) frame. |
| 494 | |
| 495 | Returns: |
| 496 | 2x3 array with stacked (linear_velocity, angular_velocity) |
| 497 | |
| 498 | Raises: |
| 499 | Error: If `object_type` is not a valid MuJoCo object type, or if no object |
| 500 | with the corresponding name and type was found. |
| 501 | """ |
| 502 | if not isinstance(object_type, int): |
| 503 | object_type = _str2type(object_type) |
| 504 | velocity = np.empty(6, dtype=np.float64) |
| 505 | if not isinstance(object_id, int): |
| 506 | object_id = self.model.name2id(object_id, object_type) |
| 507 | mujoco.mj_objectVelocity(self._model.ptr, self._data, object_type, |
| 508 | object_id, velocity, local_frame) |
| 509 | # MuJoCo returns velocities in (angular, linear) order, which we flip here. |
| 510 | return velocity.reshape(2, 3)[::-1] |
| 511 | |
| 512 | def contact_force(self, contact_id): |
| 513 | """Returns the wrench of a contact as a 2 x 3 array of (forces, torques). |