Hello, everyone ! I need your help ! Please !
I wrote a robotic arm opening a cabinet task modeled after the reinforcement learning task(franka_cabinet) inside OIGE. I used the PPO algorithm from the skrl library to train the model, the output of which is the joint position of the robotic arm. In the task python file, under the class UR5CabinetTask, there is a function pre_physics_step
that sets action (output of model) as the target value for the joint of the robotic arm.
def pre_physics_step(self, actions) -> None:
if not self.world.is_playing():
return
reset_env_ids = self.reset_buf.nonzero(as_tuple=False).squeeze(-1)
if len(reset_env_ids) > 0:
self.reset_idx(reset_env_ids)
self.actions = actions.clone().to(self._device)
targets = (self.actions + 1.0) / 2.0 * (self.ur5_dof_upper_limits - self.ur5_dof_lower_limits) + self.ur5_dof_lower_limits
self.ur5_dof_targets[:] = tensor_clamp(targets, self.ur5_dof_lower_limits, self.ur5_dof_upper_limits)
env_ids_int32 = torch.arange(self._ur5s.count, dtype=torch.int32, device=self._device)
self._ur5s.set_joint_position_targets(self.ur5_dof_targets, indices=env_ids_int32)
But I found that before it really reaches the set target value the robotic arm starts the next step :get the observation and the action through the model. Is there any way to get the arm to the target value (but not directly sets the joint position by function set_joint_positions
) before proceeding to the next step ?
I have tried to add time.sleep()
like below. But there is no difference between before and after time.sleep
. Two differences between the current joint position and set target value are the same.
# this part is just below the last line in function pre_physics_step
current_joint_position = self._ur5s.get_joint_positions(indices=env_ids_int32, clone=False)
print(f"Before{current_joint_position - self.ur5_dof_targets}")
time.sleep(1)
current_joint_position = self._ur5s.get_joint_positions(indices=env_ids_int32, clone=False)
print(f"After{current_joint_position - self.ur5_dof_targets}")
If you want more info, contact me.