ubi-agni / franka_ros_mujoco

Run a Franka Panda simulation in MuJoCo with ROS
Other
8 stars 4 forks source link

How does the gripper speed command get passed to Mujoco? #2

Closed zichunxx closed 1 year ago

zichunxx commented 1 year ago

Hi! @DavidPL1

I'm trying to figure out how the gripper speed gets passed to Mujoco. Currently, what I know is the speed command is subscribed by the franka_gripper_mujoco controller and converted into the effort signal. Then, FrankaHWSim will writeSim to Mujoco at a certain frequency with

d_ptr_->qfrc_applied[m_ptr_->jnt_dofadr[joint->id]] = effort;

In other words, the opening/closing speed of the gripper is achieved by applying generalized force in Mujoco, right?

Thanks in advance.

DavidPL1 commented 1 year ago

What do you mean by speed command?

The gripper controller provides a set of actions (move, homing, grasp, stop, and gripper_action), which allow you to define a custom speed.

But yes, you are correct.

The controller takes in your command and computes an effort command based on the last joint state provided by the hardware interface's readSim, and through the registered joint handle this is passed to joint->command. https://github.com/ubi-agni/franka_ros_mujoco/blob/30aab87e870aa734b794460356a2be76ecdd7bd3/src/franka_hw_mujoco.cpp#L351-L354

The hardware interface in writeSim fetches the effort and applies it directly at the joint. This behavior is exactly mirroring what happens in the original simulated hardware interface by Franka.

zichunxx commented 1 year ago

Thank you for your reply, which makes me clearer.