Ask Your Question
0

How does remap work internally?

asked 2018-11-16 03:56:14 -0500

carlsaldanha gravatar image

I've been trying to understand what happens when a topic is remapped by a launch file. Any ideas on what the internal system is doing? Is it possible to directly have nodes run without wrapping them in launch files and still have topic remapping abilities?

edit retag flag offensive close merge delete

Comments

Can you expand your question a little by showing us what you've found already?

gvdhoorn gravatar image gvdhoorn  ( 2018-11-16 04:07:09 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-11-16 04:13:56 -0500

gvdhoorn gravatar image

updated 2018-11-16 04:17:08 -0500

At the very end, this is how remapping is implemented (in roscpp/libros/names.cpp):

std::string remap(const std::string& name)
{
  std::string resolved = resolve(name, false);

  M_string::const_iterator it = g_remappings.find(resolved);
  if (it != g_remappings.end())
  {
    return it->second;
  }

  return name;
}

In words: for a given name, lookup the mapping from name to some other string, and if there is such a mapping registered, return the "other string".

Otherwise, return the name we were given.

The Python implementation does something similar.

This function is used by other functions such as ros::names::resolve(..) (documentation) which are used throughout the ROS codebase to resolve local names to global ones.

Is it possible to directly have nodes run without wrapping them in launch files and still have topic remapping abilities?

Yes. See wiki/Remapping Arguments for information on that. Any argument to a rosrun invocation that is not prefixed with a _ or __ is assumed to be a remap argument.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-11-16 03:56:14 -0500

Seen: 47 times

Last updated: Nov 16 '18