micro-ROS / micro-ROS-Agent

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

Specifying domain-ID through agent reference #182

Closed iluetkeb closed 10 months ago

iluetkeb commented 1 year ago

We would like to configure the domain ID in the agent, so that we can use the same firmware image for all devices. This is, in principle, possible using a reference-based connection configuration.

However, the agent always takes the domain ID from the client, even if the connection is created by reference and the reference specification contains an ID (which is just ignored).

This could be solved by either always taking the ID from the reference instead, or by having a special client ID which tells the agent to use the reference ID.

What are your thoughts on this?

btw, we also noticed some discrepancy in the documentation related to this and the code. The function signature in the documentation does not contain a domain_id parameter (see https://micro-xrce-dds.docs.eprosima.com/en/latest/client_api.html#create-entities-by-reference), but the code actually does (see https://github.com/eProsima/Micro-XRCE-DDS-Client/blob/master/include/uxr/client/core/session/create_entities_ref.h#L50)

pablogs9 commented 1 year ago

Hello @iluetkeb,

I will fix the documentation ASAP: https://github.com/eProsima/Micro-XRCE-DDS-docs/pull/84

Regarding the feature, as you mention, is it not supported. I like the idea of having a special number (maybe the max DOMAIN_ID) that triggers the agent to determine the Domain ID from other sources. We are open to PR if you implement this feature.

mmigliavacca commented 1 year ago

Hello @pablogs9, we also would need to configure (or override) the DOMAIN_ID from the agent, so that we don't have to update the firmware on each robot.

By the way, in the past on the clint (firmware) side we were calling rclc_node_init_with_options() setting the domain_id into rcl_node_options_t (see https://github.com/micro-ROS/rcl/blob/e6307be0a017a8e9787b0c291ef881765212298b/rcl/include/rcl/node_options.h#L55), but this field disappeared starting from galactic (see https://github.com/micro-ROS/rcl/blob/ba7d67d770d8539665fff7a16994ccbbccd0e81d/rcl/include/rcl/node_options.h#L37).

How can we change the DOMAIN_ID in galactic / humble?

Thanks!

pablogs9 commented 1 year ago

AFAIK, this is the humble way of doing so: https://github.com/micro-ROS/micro-ROS-demos/blob/45f342d4ef887f6a2e9f2dfa45d1d3388d7f6dbd/rclc/configuration_example/configured_publisher/main.c#L49

mmigliavacca commented 1 year ago

Thank you, we missed that change.

delihus commented 1 year ago

Hello @pablogs9 Is it possible to send the frame to the micro ros client with the ROS_DOMAIN_ID after rmw_uros_ping_agent()?

For example the Agent could load environment variable ROS_DOMAIN_ID and it on firmware request after pinging.

I worked around this with sending ROS_DOMAIN_ID from linux command.

Here is the ROS_DOMAIN_ID sender from linux https://github.com/husarion/micro-ros-agent/pull/1 And here is the firmware which waits for the UART frame https://github.com/husarion/rosbot_ros2_firmware/pull/14

I could try to implement this to the micro ros agent but i need some tips for this.

iluetkeb commented 1 year ago

Just as a heads-up: We have a patch where, when initializing the client by reference, the domain id is passed from the agent. It is very minimal and works for us, but we need some internal clearing before releasing it. Should be soon now.

delihus commented 1 year ago

Hi @iluetkeb! Is the micro-ROS-agent with Micro-XRCE-DDS-agent with this change eProsima/Micro-XRCE-DDS-Agent#331 should change ROS_DOMAIN_ID in Micro-ROS nodes? Here i created workspace to build develop version https://github.com/delihus/micro_ros_setup.

DominikN commented 11 months ago

Hi, there is a Micro-XRCE-DDS-Agent v2.4.1 release already. I have tested it and it works great. We have even created a Docker image:

  micro-xrce-agent:
    image: husarion/micro-xrce-agent:v2.4.1
    ports:
      - "8888:8888/udp"
    environment:
      - FASTRTPS_DEFAULT_PROFILES_FILE   
      - XRCE_DOMAIN_ID_OVERRIDE=${ROS_DOMAIN_ID}
    command: MicroXRCEAgent udp4 --port 8888

Can you tell me when the new release of the Micro-ROS-Agent will be published based on the latest version of Micro-XRCE-DDS-Agent?

pablogs9 commented 11 months ago

CC @Acuadros95

DominikN commented 11 months ago

Hi guys, I'm just curious how things are going with porting the feature from micro-xrce-agent to micro-ros-agent. Please let me know. Thanks!

pablogs9 commented 11 months ago

Hello @DominikN It should be ready to be used in the micro-ROS Agent, the latest version is newer than https://github.com/eProsima/Micro-XRCE-DDS-Agent/pull/331.

BTW can we close this @iluetkeb ?

iluetkeb commented 10 months ago

Done :-)