micro-ROS-Agent icon indicating copy to clipboard operation
micro-ROS-Agent copied to clipboard

Add namespace override

Open pablogs9 opened this issue 3 years ago • 7 comments

Signed-off-by: Pablo Garrido [email protected]

pablogs9 avatar May 30 '22 10:05 pablogs9

Hey, I have this a go. Looks like it prefixes the dds topic, eg rt/imu_data and becomes remapped_ns/rt/imu_data, but should be rt/remapped_ns/imu_data. Also add_datareader needs to be remapped for Subscriber support I believe

cmraaron avatar Jul 06 '22 08:07 cmraaron

In which version of ROS 2 did you test?

pablogs9 avatar Jul 06 '22 09:07 pablogs9

ah, yes, I should have said, sorry. I applied your commit to galactic branch

cmraaron avatar Jul 06 '22 10:07 cmraaron

Can you test it on humble? I remember that when I tested it it was working properly... But probably it needs a rework.

pablogs9 avatar Jul 06 '22 10:07 pablogs9

Can you test it on humble? I remember that when I tested it it was working properly... But probably it needs a rework.

ok, I just built on humble. same behaviour. It places nodes nicely in namespaces, but not the topics. Publishers, seemingly because of the rt/ prefix, and Subscribers remain un-namespaced

cmraaron avatar Jul 06 '22 10:07 cmraaron

I just tested it on humble. The node name is properly prefixed, but all the topics and services remain without a namespace. When I try to do ros2 node info /ns/firmware, it crashes:

Traceback (most recent call last):
  File "/opt/ros/humble/bin/ros2", line 33, in <module>
    sys.exit(load_entry_point('ros2cli==0.18.3', 'console_scripts', 'ros2')())
  File "/opt/ros/humble/lib/python3.10/site-packages/ros2cli/cli.py", line 89, in main
    rc = extension.main(parser=parser, args=args)
  File "/opt/ros/humble/lib/python3.10/site-packages/ros2node/command/node.py", line 37, in main
    return extension.main(args=args)
  File "/opt/ros/humble/lib/python3.10/site-packages/ros2node/verb/info.py", line 59, in main
    subscribers = get_subscriber_info(
  File "/opt/ros/humble/lib/python3.10/site-packages/ros2node/api/__init__.py", line 85, in get_subscriber_info
    return get_topics(
  File "/opt/ros/humble/lib/python3.10/site-packages/ros2node/api/__init__.py", line 76, in get_topics
    names_and_types = func(node.name, node.namespace)
  File "/usr/lib/python3.10/xmlrpc/client.py", line 1122, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.10/xmlrpc/client.py", line 1464, in __request
    response = self.__transport.request(
  File "/usr/lib/python3.10/xmlrpc/client.py", line 1166, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.10/xmlrpc/client.py", line 1182, in single_request
    return self.parse_response(resp)
  File "/usr/lib/python3.10/xmlrpc/client.py", line 1354, in parse_response
    return u.close()
  File "/usr/lib/python3.10/xmlrpc/client.py", line 668, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 1: "<class 'rclpy._rclpy_pybind11.NodeNameNonExistentError'>:cannot get subscriber names and types for nonexistent node: error not set">

bjsowa avatar Jul 25 '22 10:07 bjsowa

hmm, even with the /rt/ prefix the topic still appears as original. Looks like this is coming from the running xrce_dds_agent_instance_ as even with all callbacks turned off ros2 topic list still shows this topic. Probably I dont understand enough about the the dds to ros mapping and the roles of each component in the agent.

I'm happy to look further into it if someone wants to point me in the right direction. The code I was using is here https://github.com/cmraaron/micro-ROS-Agent/tree/namespaces

cmraaron avatar Jul 31 '22 10:07 cmraaron