micro-ROS / micro-ROS-Agent

ROS 2 package using Micro XRCE-DDS Agent.
Apache License 2.0
97 stars 51 forks source link

Add namespace override #145

Open pablogs9 opened 2 years ago

pablogs9 commented 2 years ago

Signed-off-by: Pablo Garrido pablogs9@gmail.com

cmraaron commented 2 years ago

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

pablogs9 commented 2 years ago

In which version of ROS 2 did you test?

cmraaron commented 2 years ago

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

pablogs9 commented 2 years ago

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

cmraaron commented 2 years ago

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

bjsowa commented 1 year ago

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">
cmraaron commented 1 year ago

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