Skip to content

Commit

Permalink
Skip the actuator joint id mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu Fang committed Nov 22, 2024
1 parent 60d857e commit b076e8a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions robosuite/robots/legged_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,11 @@ def control(self, action, policy_step=False):

applied_action_dict = self.composite_controller.run_controller(self._enabled_parts)
for part_name, applied_action in applied_action_dict.items():
joint_id2action = {}
for i, joint_id in enumerate(self._ref_joints_indexes_dict[part_name]):
joint_id2action[joint_id] = applied_action[i]
for actuator_id in self._ref_actuators_indexes_dict[part_name]:
joint_id = self.sim.model.actuator_trnid[actuator_id][0]
action = joint_id2action[joint_id] / self.sim.model.actuator_gear[actuator_id][0]
low = self.sim.model.actuator_ctrlrange[actuator_id, 0]
high = self.sim.model.actuator_ctrlrange[actuator_id, 1]
self.sim.data.ctrl[actuator_id] = np.clip(action, low, high)
applied_action_low = self.sim.model.actuator_ctrlrange[self._ref_actuators_indexes_dict[part_name], 0]
applied_action_high = self.sim.model.actuator_ctrlrange[self._ref_actuators_indexes_dict[part_name], 1]
applied_action = np.clip(applied_action, applied_action_low, applied_action_high)

self.sim.data.ctrl[self._ref_actuators_indexes_dict[part_name]] = applied_action

# If this is a policy step, also update buffers holding recent values of interest
if policy_step:
Expand Down

0 comments on commit b076e8a

Please sign in to comment.