rohanpsingh / mc_mujoco

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

Initial robot pose not configured from the controller #32

Closed mmurooka closed 1 year ago

mmurooka commented 1 year ago

In my understanding, mc_mujoco reflects the initial root link pose of the controller's robot to the robot in the mujoco simulation (in the following line of the code). https://github.com/rohanpsingh/mc_mujoco/blob/edae2be05e7068c0847b5c60939e9c9183559ea1/src/mj_sim.cpp#L400-L407

This function worked in @rohanpsingh 's environment, but not in mine. In my environment, the initial position of the robot in the mujoco simulation did not change when the following configuration was added.

init_pos:
  translation: [0, 0, 1]

I suspect that the difference may be due to the version of mc_rtc (I am using the latest version of origin/master). For example, has the timing of when ctl().robot().posW() is initialized changed in recent versions of mc_rtc?

gergondet commented 1 year ago

Hi @mmurooka

The above commit should fix the issue. This is indeed a (not so recent) change in mc_rtc initialization of the robot's position as it makes more sense on hardware to set the initial position after getting the initial state of the robot (i.e. in reset) rather than in the constructor.