rohanpsingh / mc_mujoco

MuJoCo interface for mc-rtc
https://arxiv.org/abs/2209.00274
BSD 2-Clause "Simplified" License
77 stars 18 forks source link

Load plugins #48

Closed mmurooka closed 1 year ago

mmurooka commented 1 year ago

This change allows the use of plugins such as https://github.com/isri-aist/MujocoTactileSensorPlugin I just copied part of https://github.com/deepmind/mujoco/blob/main/simulate/main.cc, but it may be modified to fit this project if necessary.

mmurooka commented 1 year ago

Just as Choreonoid automatically loads plugin libraries in the directory of the environment variable CNOID_PLUGIN_PATH, I think it may be a good idea to introduce MUJOCO_PLUGIN_PATH.

rohanpsingh commented 1 year ago

Hi @mmurooka san! I'm unable to play the video file in the README. What does the tactile sensor do? Is it different from the touch sensor introduced recently?

mmurooka commented 1 year ago

Hi @rohanpsingh I've updated the video so you can play it now. My plugin (MujocoTactileSensorPlugin) is implemented based on the touch grid plugin in the MuJoCo repo, with the following differences.

Anyway, this PR is intended to allow general plugins, including those in the MuJoCo repo, to be used with mc_mujoco.

mmurooka commented 1 year ago

Just as Choreonoid automatically loads plugin libraries in the directory of the environment variable CNOID_PLUGIN_PATH, I think it may be a good idea to introduce MUJOCO_PLUGIN_PATH.

I've updated it in this way.

The following is a use case of this PR. By loading the MujocoRosUtils::PosePublisher plugin in mc_mujoco with this PR, when running LocomanipController in mc_mujoco, the pose of the cart model is obtained via ROS topics.

https://github.com/rohanpsingh/mc_mujoco/assets/6636600/7567c53a-d372-479d-b540-ce6e03a7c7e8

gergondet commented 1 year ago

Hi @mmurooka

This looks good to me. However, may I ask that you consider the following:

  1. Consider using a configuration entry in mc_mujoco.yaml to define the search path (that would complement the MUJOCO_PLUGIN_PATH environment variable)
  2. Maybe rename MUJOCO_PLUGIN_PATH to MC_MUJOCO_PLUGIN_PATH such that there's no confusion about it
  3. Add some information in the README about the functionality

Thanks

mmurooka commented 1 year ago

Hi @gergondet Thanks for your comment. I think I have addressed all of them. I have eliminated support for the environment variable because I began to feel that it fits better with the concept of mc_rtc. Feel free to modify the entry name, doc, etc.

mmurooka commented 1 year ago

I have rebased the commits to eliminate the changelog in main.cpp.