You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The configured rmw_implementation-extras.cmake is always setting the default rmw implementation to whatever the default was when it was configured.
I want to build the rclcpp_examples package with a specific rmw implementation as default, which is different to the default when I built rmw_implementation. If I change the part of 5eff3ff which affects rmw_implementation-extras.cmake back to how it was, I can set the default rmw implementation through either the environment variable or the cmake args as expected.
Should I be allowed to set the default rmw implementation for rclcpp_examples independently to the default used to build rmw_implementation? Since get_default_rmw_implementation is being used everywhere I thought the answer was yes, but maybe this is the expected behaviour. If so I'd like to add a message that explains why the requested defaults are being ignored.
You need to rebuild with the --force-cmake option. You can choose to only rebuild the rmw_implementation package with --force-cmake and that should work as well, at least I think it will.
The location you linked to is expanded each time cmake is run over that package. Since the CMake file for that package did not change, then cmake is not automatically re-run, and the file doesn't get updated.
Other tools like catkin_make* and catkin tools will watch your command line arguments, and force cmake when you change the cmake variables you are passing. It sounds like that's either not implemented in ament_tools or broken, not sure which.
You could also do --only rmw_implementation and then --only rclcpp_examples, but I think that would be dangerous and I wouldn't recommend it, since the intermediate packages would not be rebuilt with the new setting.
I am building in a standalone checkout of the ros2/examples repo, so rclcpp_examples is the basepath.
From what I understand, the answer to my question is essentially "no, you cannot set the default rmw implementation for rclcpp_examples independently to the default used to build rmw_implementation" because in the invocation you just listed it is necessary to rebuild rmw_implementation first.
Could you explain what the reason behind the change was? because how the rmw_implementation-extras.cmake was before, I could just rebuild rclcpp_examples with a particular default rmw implementation without needing to rebuild rmw_implementation. And so for this case, at least, it was more convenient how it was before, but I suspect that there was a different use case in mind when the change was implemented?
"no, you cannot set the default rmw implementation for rclcpp_examples independently to the default used to build rmw_implementation"
Correct. Sorry, if that's what you were asking, I missed the distinction. The default rmw implementation is a build time decision that affects the rmw_implementation package and many packages above it.
I think if you were able to do it in the past that was in error. Not that I think the diff you linked to aimed to address this issue (I think it was an unintended side-effect of the refactor), but I think the current limitation is necessary.
Consider that you built rclcpp with default as "A" and then built rclcpp_examples as "B". rclcpp would install it's default library (i.e. <prefix>/lib/librclcpp.so) against "A", but when you build rclcpp_examples and it builds talker, it builds it for "B", but I think it would still link it against the "default rclcpp library", which was built for "A". So for what you've described to work correctly, you would need to ensure that when rclcpp_examples builds the "default" version of talker (i.e. just talker rather than talker__rmw_opensplice_cpp or whatever), that it doesn't link against the "default rclcpp library" but rather that it finds the specific rclcpp library for what it currently thinks is the default.
In general, changing the default across builds of different packages seems really dangerous to me, since there are a few subtle pitfalls that I can imagine.
Perhaps we should take a step back, why do you need to change the default for rclcpp_examples? Is it to test something about the building of rclcpp_examples or is it just so you can do talker rather than talker__<impl> every time?
I wanted to change the default for rclcpp_examples to check that what I am seeing for the tests of the linking of the default talker, for example, is correct in ros2/examples#105.
I think you're right that it was just by luck that it was working. As it stands, I think the system is between the two scenarios you describe. That is, the problem you mention with linking against defaults somehow only happens with the list_parameters(_async) and the set_and_get_parameters(_async) examples - the rest of the examples e.g. talker get away with it. But I better understand the reasoning behind it now, thank you. You've made me realise that I will have to make sure the tests for the default example executables check the dependencies deeper than one level, which wasn't necessary for the non-default tests.
Would you support adding documentation for this? something to make it clear that the RMW_IMPLEMENTATION environment variable and cmake argument essentially only affect the rmw_implementation package (if I've understood correctly)? perhaps somewhere in this tutorial is appropriate since otherwise someone might have an overlay for their own package and would run into the same issue of not re-building rmw_implementation. Or would the special under/overlay intelligence also take care of it in that case?
something to make it clear that the RMW_IMPLEMENTATION environment variable and cmake argument essentially only affect the rmw_implementation package (if I've understood correctly)?
That's correct (at least that's how I believe it should work).
perhaps somewhere in this tutorial is appropriate since otherwise someone might have an overlay for their own package and would run into the same issue of not re-building rmw_implementation.
For that particular tutorial I think it would fit in as a note, but strictly speaking that tutorial might not be the right place. If we had a "talker/listener tutorial" about how to create a package that uses rclcpp, then I think it would fit perfectly there. Since we don't have that, I'd support putting it in the ament tutorial.
Or would the special under/overlay intelligence also take care of it in that case?
Not sure I understand what you mean here. I'd say the RMW_IMPLEMENTATION option only works when applied to the rmw_implementation package and therefore only the workspace in which that package is built, and when changed all packages and workspaces which build on top of rmw_implementation need to be rebuilt (and reconfigured).
OK, I've opened #11 which will generate an error if someone gets into the same situation, for example in the ament tutorial. I agree that the documentation doesn't really belong in the ament tutorial - I think that that error will be sufficient now (it's pretty descriptive).
How about we add a section like the following to the build-from-source instructions? It doesn't explain anything about the python examples, and probably belongs in 'tutorial 0' once it exists, but might help people who are wondering which rmw implementation is being used to generate the default nodes, as I did when I first ran talker.
Managing multiple DDS vendors
In addition to the talker and listener nodes, a version of each C++ example node has been created using each of the ROS middleware (RMW) implementations found. Typically an RMW implementation is generated for each DDS vendor detected during the build step above. So, talker__rmw_opensplice_cpp, for example, should also be on your path if PrismTech's Opensplice was found. The talker node without a suffix uses the default RMW implementation, which will be the first in alphabetical order unless otherwise specified. If you wish to specify the RMW implementation used in the nodes without suffixes, the RMW_IMPLEMENTATION environment variable or CMake argument can be used. For example, by adding --cmake-args -DRMW_IMPLEMENTATION=rmw_opensplice_cpp to the above build command to pass the specification to the rmw_implementation package.
Regarding the --force-cmake-configure, it seems that it does trigger correctly, but the RMW_IMPLEMENTATION cmake var is stored in the cache, which doesn't seem to be cleared.
That is, if I run:
ament test rclcpp_examples --cmake-args -DRMW_IMPLEMENTATION=rmw_opensplice_cpp
to generate an error because the default implementation doesn't match, and then run
ament test rclcpp_examples
then I do see Running cmake because arguments have changed. but I still get the error message when I shouldn't. To make the error message go away I have to manually do rm build/rclcpp_examples/CMakeCache.txt before building without specifying the default implementation.
So my question is:
Should the CMakeCache.txt be cleared somewhere here (either all of it or just that value), or
Should the RMW_IMPLEMENTATION not end up in the CMakeCache in the first place?
@dhood I think the we should not remove the CMakeCache.txt at that point, but there are situations where it is appropriate.
I think the root of the issue is that this variable is set/updated during the find_package process. The result of the find_package process is being cached (I think) and so this file is never rerun, so the older value is used. I'm not sure how to address that off-hand. You can probably see what I mean by putting a message(...) print out at the point where you set the default. You would then expect to see that message every time you run cmake, but instead you only see it the first time (or after clearing the CMakeCache.txt).
There's already a printout where the default is set - it appears whenever cmake is called (either from removing the cache manually or using --force-cmake-configure)
I think this problem might not be ament-specific. The entry in the CMakeCache.txt looks like:
//No help, variable specified on the command line.
RMW_IMPLEMENTATION:UNINITIALIZED=rmw_opensplice_cpp
which I think is standard behaviour. Any command line cmake arguments specified with -D are added to the cache in this manner.
It seems like it would be possible to detect variables specified on the command line and only clear those values from the cache. Or, a note could be made of which arguments were parsed from the command line here and either clear them (by default or only on --force-cmake-configure) or prevent them from going in the cache in the first place (by removing the -D for example).
Having said this, while I was not expecting the command line variables to persist between invocations, since this is the standard behaviour of cmake it might not be a good idea to change it.
To correct something I said: I don't think anymore that this is necessarily a 'problem', I think it's behaving as it should be, it just wasn't what I expected. So, there's probably no need to change anything. People can use --cmake-args -URMW_IMPLEMENTATION to unset the value, or clear the cache themselves.
While I would support a temporary RMW_IMPLEMENTATION argument (a general ament argument that also happens to set the cmake variable (temporarily), for example), the environment variable can play that role for the moment
I cannot for the life of me get this to use anything other than the default rmw_cyclone_dds. I've exported the environment variable RMW_IMPLEMENTATION, and run several variations of the command
You need to export the environment variable in the terminal you use to run your application, not the one you use to build. This is a runtime parameter, not a buildtime parameter.
Activity
wjwwood commentedon Apr 14, 2016
You need to rebuild with the
--force-cmakeoption. You can choose to only rebuild thermw_implementationpackage with--force-cmakeand that should work as well, at least I think it will.The location you linked to is expanded each time cmake is run over that package. Since the CMake file for that package did not change, then cmake is not automatically re-run, and the file doesn't get updated.
Other tools like
catkin_make*andcatkin toolswill watch your command line arguments, and force cmake when you change the cmake variables you are passing. It sounds like that's either not implemented inament_toolsor broken, not sure which.dhood commentedon Apr 14, 2016
did I understand you correctly that you would expect me to be able to run:
(with
export RMW_IMPLEMENTATION=rmw_fastrtps_cppfor good measure) and see something other thanappear in the output?
Because I'm not seeing that (it finds
rmw_connext_cpp,rmw_connext_dynamic_cpp,rmw_fastrtps_cpp, andrmw_opensplice_cppi.e. fastrtps is installed)wjwwood commentedon Apr 14, 2016
No, I think the
ament buildyou gave is a bit strange in that it takesrclcpp_examples, which should be a folder name (basepath)? I'd do this:You could also do
--only rmw_implementationand then--only rclcpp_examples, but I think that would be dangerous and I wouldn't recommend it, since the intermediate packages would not be rebuilt with the new setting.dhood commentedon Apr 14, 2016
I am building in a standalone checkout of the ros2/examples repo, so
rclcpp_examplesis the basepath.From what I understand, the answer to my question is essentially "no, you cannot set the default rmw implementation for
rclcpp_examplesindependently to the default used to buildrmw_implementation" because in the invocation you just listed it is necessary to rebuildrmw_implementationfirst.Could you explain what the reason behind the change was? because how the
rmw_implementation-extras.cmakewas before, I could just rebuildrclcpp_exampleswith a particular default rmw implementation without needing to rebuildrmw_implementation. And so for this case, at least, it was more convenient how it was before, but I suspect that there was a different use case in mind when the change was implemented?wjwwood commentedon Apr 14, 2016
Correct. Sorry, if that's what you were asking, I missed the distinction. The default rmw implementation is a build time decision that affects the
rmw_implementationpackage and many packages above it.wjwwood commentedon Apr 14, 2016
I think if you were able to do it in the past that was in error. Not that I think the diff you linked to aimed to address this issue (I think it was an unintended side-effect of the refactor), but I think the current limitation is necessary.
Consider that you built
rclcppwith default as "A" and then builtrclcpp_examplesas "B".rclcppwould install it's default library (i.e.<prefix>/lib/librclcpp.so) against "A", but when you buildrclcpp_examplesand it buildstalker, it builds it for "B", but I think it would still link it against the "default rclcpp library", which was built for "A". So for what you've described to work correctly, you would need to ensure that whenrclcpp_examplesbuilds the "default" version of talker (i.e. justtalkerrather thantalker__rmw_opensplice_cppor whatever), that it doesn't link against the "default rclcpp library" but rather that it finds the specific rclcpp library for what it currently thinks is the default.In general, changing the default across builds of different packages seems really dangerous to me, since there are a few subtle pitfalls that I can imagine.
Perhaps we should take a step back, why do you need to change the default for
rclcpp_examples? Is it to test something about the building ofrclcpp_examplesor is it just so you can dotalkerrather thantalker__<impl>every time?dhood commentedon Apr 15, 2016
I wanted to change the default for
rclcpp_examplesto check that what I am seeing for the tests of the linking of the defaulttalker, for example, is correct in ros2/examples#105.I think you're right that it was just by luck that it was working. As it stands, I think the system is between the two scenarios you describe. That is, the problem you mention with linking against defaults somehow only happens with the
list_parameters(_async)and theset_and_get_parameters(_async)examples - the rest of the examples e.g.talkerget away with it. But I better understand the reasoning behind it now, thank you. You've made me realise that I will have to make sure the tests for the default example executables check the dependencies deeper than one level, which wasn't necessary for the non-default tests.Would you support adding documentation for this? something to make it clear that the
RMW_IMPLEMENTATIONenvironment variable and cmake argument essentially only affect thermw_implementationpackage (if I've understood correctly)? perhaps somewhere in this tutorial is appropriate since otherwise someone might have an overlay for their own package and would run into the same issue of not re-buildingrmw_implementation. Or would the special under/overlay intelligence also take care of it in that case?wjwwood commentedon Apr 15, 2016
Always 😄. Let me know if I can help you with it.
That's correct (at least that's how I believe it should work).
For that particular tutorial I think it would fit in as a note, but strictly speaking that tutorial might not be the right place. If we had a "talker/listener tutorial" about how to create a package that uses
rclcpp, then I think it would fit perfectly there. Since we don't have that, I'd support putting it in the ament tutorial.Not sure I understand what you mean here. I'd say the
RMW_IMPLEMENTATIONoption only works when applied to thermw_implementationpackage and therefore only the workspace in which that package is built, and when changed all packages and workspaces which build on top ofrmw_implementationneed to be rebuilt (and reconfigured).dhood commentedon Apr 15, 2016
OK, I've opened #11 which will generate an error if someone gets into the same situation, for example in the ament tutorial. I agree that the documentation doesn't really belong in the ament tutorial - I think that that error will be sufficient now (it's pretty descriptive).
How about we add a section like the following to the build-from-source instructions? It doesn't explain anything about the python examples, and probably belongs in 'tutorial 0' once it exists, but might help people who are wondering which rmw implementation is being used to generate the default nodes, as I did when I first ran
talker.Managing multiple DDS vendors
In addition to the
talkerandlistenernodes, a version of each C++ example node has been created using each of the ROS middleware (RMW) implementations found. Typically an RMW implementation is generated for each DDS vendor detected during the build step above. So,talker__rmw_opensplice_cpp, for example, should also be on your path if PrismTech's Opensplice was found. Thetalkernode without a suffix uses the default RMW implementation, which will be the first in alphabetical order unless otherwise specified. If you wish to specify the RMW implementation used in the nodes without suffixes, theRMW_IMPLEMENTATIONenvironment variable or CMake argument can be used. For example, by adding--cmake-args -DRMW_IMPLEMENTATION=rmw_opensplice_cppto the above build command to pass the specification to thermw_implementationpackage.Regarding the
--force-cmake-configure, it seems that it does trigger correctly, but theRMW_IMPLEMENTATIONcmake var is stored in the cache, which doesn't seem to be cleared.That is, if I run:
to generate an error because the default implementation doesn't match, and then run
then I do see
Running cmake because arguments have changed.but I still get the error message when I shouldn't. To make the error message go away I have to manually dorm build/rclcpp_examples/CMakeCache.txtbefore building without specifying the default implementation.So my question is:
Should the
CMakeCache.txtbe cleared somewhere here (either all of it or just that value), orShould the
RMW_IMPLEMENTATIONnot end up in the CMakeCache in the first place?wjwwood commentedon Apr 15, 2016
@dhood I think the we should not remove the
CMakeCache.txtat that point, but there are situations where it is appropriate.I think the root of the issue is that this variable is set/updated during the
find_packageprocess. The result of thefind_packageprocess is being cached (I think) and so this file is never rerun, so the older value is used. I'm not sure how to address that off-hand. You can probably see what I mean by putting amessage(...)print out at the point where you set the default. You would then expect to see that message every time you run cmake, but instead you only see it the first time (or after clearing theCMakeCache.txt).dhood commentedon Apr 16, 2016
There's already a printout where the default is set - it appears whenever cmake is called (either from removing the cache manually or using
--force-cmake-configure)I think this problem might not be ament-specific. The entry in the
CMakeCache.txtlooks like:which I think is standard behaviour. Any command line cmake arguments specified with
-Dare added to the cache in this manner.It seems like it would be possible to detect variables specified on the command line and only clear those values from the cache. Or, a note could be made of which arguments were parsed from the command line here and either clear them (by default or only on
--force-cmake-configure) or prevent them from going in the cache in the first place (by removing the-Dfor example).Having said this, while I was not expecting the command line variables to persist between invocations, since this is the standard behaviour of cmake it might not be a good idea to change it.
dhood commentedon Apr 16, 2016
To correct something I said: I don't think anymore that this is necessarily a 'problem', I think it's behaving as it should be, it just wasn't what I expected. So, there's probably no need to change anything. People can use
--cmake-args -URMW_IMPLEMENTATIONto unset the value, or clear the cache themselves.While I would support a temporary
RMW_IMPLEMENTATIONargument (a general ament argument that also happens to set the cmake variable (temporarily), for example), the environment variable can play that role for the momentwjwwood commentedon Apr 16, 2016
Ok, so can we close this then?
dhood commentedon Apr 16, 2016
Yeah
Merge pull request ros2#10 from mauropasse/mauro/clean-events-executor
nightduck commentedon Jul 26, 2022
I cannot for the life of me get this to use anything other than the default rmw_cyclone_dds. I've exported the environment variable RMW_IMPLEMENTATION, and run several variations of the command
Yet in doing some testing:
It always uses rmw_cyclonedds_cpp. I can't test any other rmws. What exactly is the command I need to build this?
Answered here
christophebedard commentedon Jul 26, 2022
You need to export the environment variable in the terminal you use to run your application, not the one you use to build. This is a runtime parameter, not a buildtime parameter.
If this still doesn't work, please ask a question on https://answers.ros.org/.