yujinrobot / yujin_ocs

Yujin Robot's open-source control libraries
http://wiki.ros.org/yujin_ocs
235 stars 178 forks source link

[yocs_cmd_vel_mux] Topics are in private namespace #133

Open jacobperron opened 6 years ago

jacobperron commented 6 years ago

Topic names provided in a config file are prefixed with the name of the node. This is because a private NodeHandle is used to create the subscribers. The same is true for published topics. This is inconvenient for integration with other nodes because a remap is required for each topic listed in the config file, meaning any change to the input topics also requires a corresponding remap change in a launch file.

As an example, say I have a few nodes publishing velocities to the following topics:

    /cmd_vel_0
    /cmd_vel_1
    /my_node/cmd_vel

Then if I was to plug them into the mutex, it would be nice to simply provide the following config file:

subscribers:
  -
    name    : cmd_vel_0
    topic   : cmd_vel_0
    timeout : 0.5
    priority: 1
  -
    name    : cmd_vel_1
    topic   : cmd_vel_1
    timeout : 0.5
    priority: 2
  -
    name    : my_node_cmd_vel
    topic   : my_node/cmd_vel
    timeout : 0.5
    priority: 3

publisher: cmd_vel

But, currently, I also have to add some remaps, for example:

<remap from="yocs_cmdl_vel_mux/cmd_vel_0" to="cmd_vel_0" />
<remap from="yocs_cmdl_vel_mux/cmd_vel_1" to="cmd_vel_1" />
<remap from="yocs_cmdl_vel_mux/my_node/cmd_vel" to="my_node/cmd_vel" />

Of course we can put the topic names in a global namespace, but then we lose the nice feature of including all of our nodes (including yocs_cmd_vel_mux) in a common namespace at the launch level, for example:

<group ns="my_robot">
    <node pkg="nodelet" type="nodelet" name="yocs_cmd_vel_mux"
        args="load yocs_cmd_vel_mux/CmdVelMuxNodelet $(arg nodelet_manager_name)">
        <param name="yaml_cfg_file" value="path/to/my/config"/>
    </node>

    <node pkg="my_node" type="my_node" name="my_node" />

    ...

</group>

The same issue exists for yocs_velocity_smoother as well (and possibly other yocs packages?).

I believe it is a common practice to use a relative namespace for topics. This is mentioned for drivers specifically as part of REP-0135.