Skip to content

use rmw implementation - #66

Merged
dirk-thomas merged 3 commits into
masterfrom
use_rmw_impl
Jan 9, 2017
Merged

dirk-thomas merged 3 commits into
masterfrom
use_rmw_impl

Conversation

@dirk-thomas

Copy link
Copy Markdown
Member

Connect to ros2/rcl#106

The patch explicitly selects rmw_implementation. As a follow up a lot of the logic to handle rmw implementations as well as the RCLPY_IMPLEMENTATION environment variable can be removed from rclpy.

@dirk-thomas dirk-thomas added the in progress Actively being worked on (Kanban column) label Jan 5, 2017
@dirk-thomas dirk-thomas self-assigned this Jan 5, 2017

@wjwwood wjwwood left a comment

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.

I know it is still "in progress", but I wanted to comment on a few lines in the mean time.

Comment thread rclpy/src/rclpy/_rclpy.c Outdated

rcl_node_t * node = (rcl_node_t *)PyCapsule_GetPointer(pynode, NULL);
rcl_ret_t ret;
rcl_ret_t ret = RCL_RET_ERROR;

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.

This initial value is never used, why did you add it throughout the file? My static linter complains about this ("value assigned but never used").

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.

When I run the tests locally cpplint flags all the lines modified in commit 3bd4aff as warnings without the change (use of unitialized variable in the condition a few lines later). That is why I did the separate commit. While the logic is safe as it is the linter seems to be unable to come to the same conclusion (all if blocks set the variable and the else blocks returns from the function).

What static linter are you using?

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.

I think I'm using cppcheck (under the hood), but it might be using my include path to expand the macros and see that it is actually a return statement.

A compromise would be to set it in the else case, which would be correct in both checks.

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.

I have removed the commit from this PR and will handle my local linter somehow. So nothing needs to change here.

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.

It looks like the current linter doesn't like the even unchanged code anymore. I initialized the value in the else block in c15271b

module_name = '._rclpy__{rmw_implementation}'.format(
rmw_implementation=__selected_rmw_implementation,
)
__selected_rmw_implementation = 'rmw_implementation'

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.

I guess this is temporary? (pr is still "in progress") You will need to do something with the select_rmw_implementation() function. I don't know if you can preserve the functionality here that has to do with selecting the rmw implementation after launching Python but before running rclpy.init without also requiring the meta rmw implementation you just made. It might be better to continue to build a Python module for each rmw implementation (since it doesn't really affect user code anyways).

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.

The PRs are "in progress" because they haven't been CI tested yet and that can only happen after all packages have been converted to not require rmw specific libraries of rcl / rclcpp. Other then that the patches are in the state they will be in for review.

We don't need to build separate Python modules anymore. You will be able to select the rmw implementation the same way as for C++ by setting the environment variable RMW_IMPLEMENTATION. There is certainly more cleanup possible since all this rmw impl. selection logic in Python can be removed. But I will very likely leave that to a follow up PR since the complexity of the current set of PRs is already pretty high.

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.

You will be able to select the rmw implementation the same way as for C++ by setting the environment variable RMW_IMPLEMENTATION.

That ignores the current use case which allows you to query the available ones, and then decide in Python code which one to use. I think that's actually pretty useful, that's why I suggested you look at whether or not the env variable mechanism can be used to preserve that functionality or that we just continue to build one for each. You didn't address this point at all and simply stated "We don't need to build separate Python modules anymore." which ignores the issue.

There is certainly more cleanup possible since all this rmw impl. selection logic in Python can be removed. But I will very likely leave that to a follow up PR since the complexity of the current set of PRs is already pretty high.

-1. Sorry, I don't support merging this while creating dead code and leaving tests disabled.

In my opinion this pr needs to either justify why the existing functionality is no longer required and remove the dead code and tests related to the removed feature or fix the existing code so the feature continues to work with the new mechanism.

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.

Regarding the "dead code" and disabled tests. The idea as mentioned above is to remove those in a follow up PR. For sanity I wanted to separate these steps since the current PRs are already very invasive. The whole typesupport redesign has already been split over 8 independent changeset (which have all been reviewed and merged separately). I though that splitting changes up into more bite size pieces is desired (for the sanity of the programmer making the patches as well as the sanity of the reviewer). I will update this PR then to remove the "dead code" and disabled test as part of this PR since you prefer that.

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.

Imo we don't need two separate ways to select rmw implementation. The RMW_IMPLEMENTATION environment variable works across all languages. In C++ you don't have the option to choose the rmw implementation from within the running executable. Therefore I don't think this is a feature we need in Python - especially since it is not possible currently to use rmw A and then switch to rmw B within the same Python script.

I don't know if a running Python script can look at the environment variable, change the value and that change being reflected in the loaded library since I haven't tried it. But imo it is a not a use case worth supporting.

We should then make a decision on the question about selecting the rmw impl. within a running Python script in order to continue on this.

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.

You're right, though I suppose you mean rcl not rclcpp. You'll have to either remove the code and tests for the Python selection of rmw impl (as is proposed in this pr) or fix those functions/features to use the new mechanism, assuming that is possible.

I hadn't thought about it before, but that also means that you cannot build rmw implementation specific user executables at all anymore. Before I just assumed we were removing that logic because we could, not because we had too.

Doesn't it also mean that all of the get_X_information macros (where X is rcl, rclcpp, etc.) are no longer useful and should be removed? If that is the case, then that is another example of dead code that should be removed.

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.

You're right, though I suppose you mean rcl not rclcpp. You'll have to either remove the code and tests for the Python selection of rmw impl (as is proposed in this pr) or fix those functions/features to use the new mechanism, assuming that is possible.

As mentioned above I have already removed these in this PR in 9e05978.

Doesn't it also mean that all of the get_X_information macros (where X is rcl, rclcpp, etc.) are no longer useful and should be removed? If that is the case, then that is another example of dead code that should be removed.

Yes, various CMake function can be removed. All if this is being tracked in the parent ticket: ros2/ros2#302.

Again I don't see the point of squeezing as much changes as possible into this PR set. Especially since the previous rounds of PRs have moved very fast. It takes a lot of time to get these changes into the state to be "green". Imo this discussion is slowing the progress more down then if this would have been merged. Then the remaining tasks could have already been started / done by now.

I can remove the CMake functions in the corresponding PR if that makes a difference for you.

@dirk-thomas dirk-thomas Jan 6, 2017 •

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.

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.

As mentioned above I have already removed these in this PR in 9e05978.

I know I said that 😛:

remove the code and tests for the Python selection of rmw impl (as is proposed in this pr)

My point was that if someone else reviews and agrees with me then you'll need to do the other thing.

Again I don't see the point of squeezing as much changes as possible into this PR set.

It's not about squeezing as much as possible in, it is about making sure the master branch stays in the best state possible even between incremental pr's. When someone asks me to review a pr, I look for anything that smells bad like: failing test, failing style, logical inconsistency, dead code, broken features. I think it is acceptable to table any of those things by marking them with a TODO or tracking them in a ticket, but only if there is no plan to fix them in the immediate future. If you're just going to merge this pr and then do those things right afterwards, then I don't see much benefit to splitting them up. The only other reason to merge short of the goal like this is to prevent getting out of sync with others, but since you're the only one working in this part of the code right now, that's not an issue in my opinion. So from my perspective you're neither at risk of conflicts nor are you going to defer doing these things for very long and so I think you should do them in these current pr's.

I can't see a good reason to do it in two steps. In contrast, you may discover something important when removing these functions (like that they're still being used somewhere that you missed) which would be important to find and fix before putting it to master.

I appreciate that you're trying to keep the changes small and reviewable, but I just think they should also be cohesive and that splitting the pr's short of removing now vestigial functions just doesn't make sense.

Imo this discussion is slowing the progress more down then if this would have been merged. Then the remaining tasks could have already been started / done by now.

Imo if you just removed them and restarted CI when I mentioned it, then we'd also be done by now. The size of the pr doesn't affect the time it takes to run CI or anything. In fact the time it would take you to make new branches and pr's for the additional changes might make it take longer.

I can remove the CMake functions in the corresponding PR if that makes a difference for you.

I think it is worthwhile to do that at the same time as these others changes, yes. I don't know what the rest of the @ros2/team is doing today (hint, hint -- nudge, nudge 😄), but they could override me and that would be fine.

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.

Please see my previous comment. That already referenced the requested changes. And the CI build links on the main ticket have been update with it.

@dirk-thomas dirk-thomas added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jan 6, 2017

@wjwwood wjwwood left a comment

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.

I'll concede on the point about the "select an rmw implementation from Python" feature and give this a +1. I appreciate @dirk-thomas iterating on this and the other pr's.

However, after you merge this I will create an issue (unless you'd like to) to remove more of the import machinery from rclpy which is no longer required. Specifically the delayed import of the CPython extension does not need to be delayed until rclpy.init() any longer and therefore the "implementation singleton" (described here:

The singleton is called ``rclpy_implementation`` and is in this module.
For example, you might use it like this:
.. code::
from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
_rclpy.rclpy_init()
while _rclpy.rclpy_ok():
# ...
Before you call :py:func:`rclpy.init` this singleton will point to an instance
of the :py:class:`ImplementationPlaceholder` class, which will raise a
:py:class:`rclpy.exceptions.NotInitializedException` when ever accessed.
After initialization it will point to the rclpy implementation C module.
) is no longer required.

To be clear, I feel this is different from the python and cmake functions I asked to be removed before merge of these pr's because while redundant this code is: a) still in use (i.e. it's not dead code yet) and b) not malfunctioning (as select_rmw_implementation() was before being removed in this pr).

@dirk-thomas

Copy link
Copy Markdown
Member Author

I added a bullet to the typesupport redesign ticket.

Does the approval only cover this PR or all other related PRs referenced from the parent ticket (ros2/rcl#106)?

@wjwwood

wjwwood commented Jan 7, 2017

Copy link
Copy Markdown
Member

Just this one, I'll review the others now.

@esteve

esteve commented Jan 7, 2017

Copy link
Copy Markdown
Member

I see @wjwwood already approved this PR, so I don't know if this is still open for discussion, but I'd rather not see this functionality go away (cleaned up yes, but not removed). There are certain cases where it's more convenient to pick the RMW implementation from Python, instead of relying on an environment variable.

For example, if you're developing a Django application that uses rclpy (yeah, a bit crazy, but it may be the case that you want to build a web frontend for ROS2), it's far easier to deploy if the RMW implementation is specified in the Django settings (DJANGO_SETTINGS_MODULE) and later loaded in Python, it's also more explicit, which is always better than implicit. Of course most people will just use whatever default RMW implementation is available, but in any case, I don't see any strong reason for removing this.

@dirk-thomas

Copy link
Copy Markdown
Member Author

We can't keep the current functionality as is - simple because it would require to continue to build separate libraries of rcl / rclcpp for each rmw implementation (which we want to get rid of). Currently rmw_implementation chooses only based on an environment variable which rmw implemenation to load. I mentioned in ros2/rcl#106 (comment) that a select function could be added to override that selection process. Maybe that would be useful for the described use case too.

@dirk-thomas
dirk-thomas merged commit f2db5c8 into master Jan 9, 2017
@dirk-thomas
dirk-thomas deleted the use_rmw_impl branch January 9, 2017 16:54
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Jan 9, 2017
@esteve

esteve commented Jan 9, 2017

Copy link
Copy Markdown
Member

@dirk-thomas We can't keep the current functionality as is

Exactly, that's what I meant with:

I'd rather not see this functionality go away (cleaned up yes, but not removed)

so as long as there's something else functionally equivalent (i.e. being able to select the RMW implementation explicitly without relying on an environment variable), that's fine, doesn't matter how it's implemented.

YuanYuYuan pushed a commit to YuanYuYuan/rclpy that referenced this pull request Nov 12, 2025
Initial Basic Support for ROS2 Message Generation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants