Skip to content
This repository was archived by the owner on Oct 7, 2021. It is now read-only.

Support changing the ROS_DOMAIN_ID in OpenSplice without changing the config file#81

Merged
wjwwood merged 1 commit intomasterfrom
opensplice_dynamic_ros_domain_id
Sep 17, 2015
Merged

Support changing the ROS_DOMAIN_ID in OpenSplice without changing the config file#81
wjwwood merged 1 commit intomasterfrom
opensplice_dynamic_ros_domain_id

Conversation

@wjwwood
Copy link
Copy Markdown
Member

@wjwwood wjwwood commented Sep 4, 2015

Currently you have to update the system installed OpenSplice config file, or override it using OSPL_URI in order to use a different ROS_DOMAIN_ID. This is out of sync with the other implementations and inconvenient.

So this pull request works around this issue by copying the default configuration for OpenSplice into the opensplice_cmake_module package, replacing the default domain id (0) with ${ROS_DOMAIN_ID}, installing it to the workspace, and changing the environment hooks to default to referencing this file rather than the built-in one. This means that when this config file is evaluated by OpenSplice it will substitute the ${ROS_DOMAIN_ID} in the config file with what ever is in the environment. This strategy is based on the feedback I got on their forum:

http://forums.opensplice.org/index.php?/topic/2591-programmatically-choosing-the-domain-id/#entry4471

The other thing we have to do is to ensure that the ROS_DOMAIN_ID is set before trying to use OpenSplice, and therefore forcing the configuration file to be evaluated. See ros2/rclcpp#102

Still testing, not quite ready for review.

@wjwwood wjwwood added the in progress Actively being worked on (Kanban column) label Sep 4, 2015
@wjwwood wjwwood self-assigned this Sep 4, 2015
@dirk-thomas
Copy link
Copy Markdown
Member

Instead of requiring rclcpp to handle this case opensplice_cmake_module could simply provide an environment hook which ensures that the domain id is set for OpenSplice.

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Sep 4, 2015

@dirk-thomas Someone could also unset ROS_DOMAIN_ID. In which case connext would work, defaulting to 0 and OpenSplice would not.

@dirk-thomas
Copy link
Copy Markdown
Member

Someone could also unset OSPL_URI after sourcing the environment and that would also break. I guess there is always a way to break the system if you try 😉

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Sep 4, 2015

That's OpenSplice specific, the ROS_DOMAIN_ID is ROS specific and having it set or not set should result in the same behavior, regardless of the implementation being used. So I think the argument that you can break the system if you try is not an argument which applies to this pr.

As to where we ensure the ROS_DOMAIN_ID is set for OpenSplice, I put it in rclcpp because we read the ROS_DOMAIN_ID in rclcpp. I can look at moving it to the rmw_opensplice implementation of create_node.

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Sep 4, 2015

I moved it to rmw_opensplice_cpp, the benefit being that I can scope the use of this more tightly. So now if the ROS_DOMAIN_ID is not set, it sets it, creates the participant factory, and then unsets it again. If the ROS_DOMAIN_ID is set, but different from the domain_id that was passed in (something we might want to expose through rclcpp in the future), then it sets it to what was passed in, storing the current value, and restores it after it finishes creating the domain participant factory.

I still need to test this locally.

@wjwwood wjwwood force-pushed the opensplice_dynamic_ros_domain_id branch 3 times, most recently from caa0558 to 366a792 Compare September 4, 2015 20:13
@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Sep 4, 2015

I also added a check to see if the OSPL_URI is set, and returns a relevant error message if it is not. Previously if OSPL_URI was not set you just get "failed to create participant".

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Sep 4, 2015

I've tested it locally:

william@farl ~
% bash
william@farl:~
$ source ./ros2/install/setup.bash
william@farl:~
$ talker__rmw_opensplice_cpp
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
Publishing: 'Hello World: 3'
Publishing: 'Hello World: 4'
Publishing: 'Hello World: 5'
^Csignal_handler(2)
william@farl:~
$ ROS_DOMAIN_ID=1 talker__rmw_opensplice_cpp
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
Publishing: 'Hello World: 3'
Publishing: 'Hello World: 4'
Publishing: 'Hello World: 5'
^Csignal_handler(2)
william@farl:~
$ exit
william@farl ~
% bash
william@farl:~
$ source ros2/install/setup.bash
william@farl:~
$ listener__rmw_opensplice_cpp
I heard: [Hello World: 1]
I heard: [Hello World: 2]
I heard: [Hello World: 3]
I heard: [Hello World: 4]
I heard: [Hello World: 5]
^Csignal_handler(2)
william@farl:~
$ ROS_DOMAIN_ID=2 listener__rmw_opensplice_cpp
^Csignal_handler(2)
william@farl:~
$ exit

I still need to test it manually on Windows, but the build is passing on Windows: http://ci.ros2.org/job/ros2_batch_ci_windows/377/

It has test failures, but I'll have to dig into them to know if that's expected or not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use CMAKE_INSTALL_PREFIX since it breaks the ability to relocate the install space. Use $AMENT_CURRENT_PREFIX instead.

Same below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, ad456f8

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Sep 8, 2015

This works on Linux, but is still not working correctly on Windows, I'll look into it today and make a decision about its feasibility as a fix on Windows.

@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Sep 16, 2015

I've given up on getting it to work around on Windows, as I do on the other platforms. So now the Windows env hook sets the ROS_DOMAIN_ID is not set to 0 and errors out if it is not set when you run the program.

I'll do uncrustify and squash after lunch, CI for now:

@wjwwood wjwwood added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Sep 16, 2015
@wjwwood
Copy link
Copy Markdown
Member Author

wjwwood commented Sep 16, 2015

CI looks good. The test failures on Windows seem to be unrelated. I just finished manually running the examples on Windows as well, setting, changing, and unsetting the ROS_DOMAIN_ID in turn.

I think this is ready for review. I'll squash after review.

@dirk-thomas
Copy link
Copy Markdown
Member

LGTM

…is set

this config file uses the ROS_DOMIAN_ID env var,
but other wise it is identical to the default
config file from OpenSplice
@wjwwood wjwwood force-pushed the opensplice_dynamic_ros_domain_id branch from 5a997dc to bdd82d2 Compare September 17, 2015 21:19
wjwwood added a commit that referenced this pull request Sep 17, 2015
Support changing the ROS_DOMAIN_ID in OpenSplice without changing the config file
@wjwwood wjwwood merged commit addc0e3 into master Sep 17, 2015
@wjwwood wjwwood deleted the opensplice_dynamic_ros_domain_id branch September 17, 2015 21:20
@wjwwood wjwwood removed the in review Waiting for review (Kanban column) label Sep 17, 2015
@dirk-thomas
Copy link
Copy Markdown
Member

I "fixed" the indentation level of the xml file from 3 to 4 spaces since that is the format osplconf uses when writing files: 44278bd

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants