jrl-umi3218 / mc_rtc

mc_rtc is an interface for simulated and real robotic systems suitable for real-time control
BSD 2-Clause "Simplified" License
122 stars 36 forks source link

[MCControler] Update main robot name #423

Closed antodld closed 10 months ago

antodld commented 10 months ago

This PR allows to rename the main robot declared in mc_rtc.yaml as the one named in a controller configuration in robots

gergondet commented 10 months ago

Hi @antodld

If I understand correctly, what you are trying to do is:

  1. If the value of MainRobot is a loadable module then you treat it as before
  2. Otherwise you look into every loaded controller configurations to find if it's configured under the robots entry and you use the module entry in there to load the robot

So for example:

MainRobot: MyJVRC
robots:
  MyJVRC:
    module: JVRC1

would load JVRC1 as the main robot but rename it MyJVRC instead of the default of jvrc1

This poses at least one problem, say you have a controller that supports multiple robots and you wish to rename a few, so you would have something like:

MainRobot: MyJVRC # sometimes you switch to MyHRP4CR
robots:
  MyJVRC:
    module: JVRC1
  MyHRP4CR:
    module: HRP4CR

with this configuration and your patch, both modules are always loaded

I would suggest to write a patch that allows this syntax:

MainRobot:
  name: MyName
  module: MyModule

To solve this I suggest to add a std::optional<std::string> main_robot_module_name entry into the global configuration and treat config("MainRobot")("module") as config("MainRobot")

antodld commented 10 months ago

Hello @gergondet

The behavior described in your multi-robot example is the desired one.

With this PR, whatever the main robot you chose in your mc_rtc.yaml configuration file (whether MyJVRC1 or MyHRP4CR), the controller will always have 2 robots loaded with the same name, in opposition to the current state where the robot loaded in MainRobot is always named after its robot module.

gergondet commented 10 months ago

the controller will always have 2 robots loaded with the same name

Just to clarify, that's two robots at the same time at all times right?

With the syntax I proposed you can get the same effect:

MainRobot:
  name: MyJVRC
  module: JVRC1
robots:
  MyJVRC:
    module: JVRC1
  MyHRP4CR
    module: HRP4CR

Would get you the same robots as:

MainRobot:
  name: MyHRP4CR
  module: HRP4CR
robots:
  MyJVRC:
    module: JVRC1
  MyHRP4CR
    module: HRP4CR