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

Implement modifiable PD gains with datastore call #21

Closed rohanpsingh closed 2 years ago

rohanpsingh commented 2 years ago

Hi @gergondet

I wanted to implement a datastore call to be able to set the PD gains for all joints from within any mc-rtc controller. Right now I'm doing works well with what is shown in the patch below.

Since later I want to implement the same call (with the exact same signature) in mc-openrtm too,
I would like to know your suggestions on whether this is the best way to implement it.

How to call ``` // set new pd gains bool mod_servo_success = false; if(ctl.datastore().has("set_pdgains::" + ctl.robot().name())) { mod_servo_success = ctl.datastore().call("set_pdgains::" + ctl.robot().name(), kp, kd); } if (!mod_servo_success) { mc_rtc::log::warning("[{}] Could not set PD gains through datastore call!!!", name()); } ```
gergondet commented 2 years ago

Hi Rohan,

I think it's fine, some remarks:

rohanpsingh commented 2 years ago

Thanks for the remarks! I implemented each of the points you mentioned :)