mujoco_mpc icon indicating copy to clipboard operation
mujoco_mpc copied to clipboard

MJPC in a ROS node

Open cinogul opened this issue 10 months ago • 1 comments

Hi @yuvaltassa,

I'm trying to use MJPC in a ROS node to generate control inputs for a bipedal robot. I have tried to rewrite this code for my own needs with little success.

I have three questions:

  1. I have a working python implementation that uses logic similar to the python binding demos but for an undetermined time limit instead of the limit defined in these demos. Do you reckon rewriting this to C++ can help reduce computing times significantly?
  2. If so, are there C++ demos similar to the python binding demos? I'm most interested in the one mentioned in the first question, since it has everything I need.
  3. Is this a good approach? In another issue (running MJPC without rendering) you mentioned MJPC should be used either online-interactive with a GUI or offline via gRPC. This makes me think that what I'm trying to do (which I think is online gRPC) is perhaps just the wrong approach. Thank you for any tips you can give me!

cinogul avatar Mar 05 '25 17:03 cinogul

it is expected that the python api introduces additional overhead compared to directly running the c++ code. however, depending on the particular application this additional overhead might or might not be significant. it should be possible to benchmark python api calls and compare these results to the timing information available in the gui in order to evaluate potential overhead from the python api. this information should hopefully provide insight into whether or not the python api is a reasonable choice compared to calling the c++ code directly.

currently there are not c++ demos that are similar to the python api cartpole demos. reference c++ code that might be useful:

  • https://github.com/google-deepmind/mujoco_mpc/blob/main/mjpc/app.cc
  • https://github.com/google-deepmind/mujoco_mpc/tree/main/mjpc/test
    • https://github.com/google-deepmind/mujoco_mpc/blob/main/mjpc/test/agent/agent_test.cc

good luck with your project!

thowell avatar Mar 12 '25 13:03 thowell