| 47 | """ |
| 48 | |
| 49 | def __init__( |
| 50 | self, |
| 51 | physics, |
| 52 | eef_site: str, |
| 53 | arm_joint_qvel_index, |
| 54 | arm_actuator_index, |
| 55 | *, |
| 56 | kp: float = 150.0, |
| 57 | damping_ratio: float = 1.0, |
| 58 | output_max=(0.05, 0.05, 0.05, 0.5, 0.5, 0.5), |
| 59 | output_min=(-0.05, -0.05, -0.05, -0.5, -0.5, -0.5), |
| 60 | input_max=1.0, |
| 61 | input_min=-1.0, |
| 62 | torque_limits=None, |
| 63 | initial_joint=None, |
| 64 | ): |
| 65 | self.physics = physics |
| 66 | self.model = physics.model.ptr |
| 67 | self.data = physics.data.ptr |
| 68 | self.site_id = mujoco.mj_name2id(self.model, mujoco.mjtObj.mjOBJ_SITE, eef_site) |
| 69 | self.qvel_index = np.asarray(arm_joint_qvel_index, dtype=int) |
| 70 | self.qpos_index = self.qvel_index # LIBERO arm: qpos and qvel indices coincide |
| 71 | self.act_index = np.asarray(arm_actuator_index, dtype=int) |
| 72 | |
| 73 | self.kp = np.full(6, kp, dtype=float) |
| 74 | self.kd = 2 * np.sqrt(self.kp) * damping_ratio |
| 75 | self.output_max = np.asarray(output_max, dtype=float) |
| 76 | self.output_min = np.asarray(output_min, dtype=float) |
| 77 | self.input_max = np.full(6, input_max, dtype=float) |
| 78 | self.input_min = np.full(6, input_min, dtype=float) |
| 79 | self._scale = np.abs(self.output_max - self.output_min) / np.abs(self.input_max - self.input_min) |
| 80 | self._out_t = (self.output_max + self.output_min) / 2.0 |
| 81 | self._in_t = (self.input_max + self.input_min) / 2.0 |
| 82 | self.torque_limits = torque_limits |
| 83 | |
| 84 | self._update() |
| 85 | # robosuite initializes the orientation goal to the current EE orientation |
| 86 | # (reset_goal); pos goal starts at current EE pos. |
| 87 | self.goal_pos = self.ee_pos.copy() |
| 88 | self.goal_ori = self.ee_ori_mat.copy() |
| 89 | self.initial_joint = np.array(initial_joint) if initial_joint is not None else self.joint_pos.copy() |
| 90 | |
| 91 | # --- sim-data access (the only sim-specific part) ------------------------- |
| 92 | def _update(self): |