Skip to content

Try all available implementations instead of hardcoding OpenSplice - #5

Merged
wjwwood merged 2 commits into
masterfrom
multiple-vendors
Apr 1, 2016
Merged

wjwwood merged 2 commits into
masterfrom
multiple-vendors

Conversation

@esteve

@esteve esteve commented Feb 25, 2016

Copy link
Copy Markdown
Member

No description provided.

@esteve esteve added the in progress Actively being worked on (Kanban column) label Feb 25, 2016
@dirk-thomas

Copy link
Copy Markdown
Member

Embedding a compile time hard coded list into the code is not necessary here. This should use the ament resource index instead.

@wjwwood

wjwwood commented Feb 25, 2016

Copy link
Copy Markdown
Member

@esteve the Python implementation of the ament index API is here: https://github.com/ament/ament_index/blob/master/ament_index_python/ament_index_python/__init__.py

However, there might be an issue with using the index since a new rmw impl could be added after this package is built and so the index may contain more implementations than existed when the C extensions were built. So long as the code is gracefully degrading that shouldn't be an issue though.

@esteve

esteve commented Feb 25, 2016

Copy link
Copy Markdown
Member Author

@dirk-thomas @wjwwood I've replaced the vendor.py.in file with a Python module that queries the index and retrieves all the rmw implementations at runtime.

Comment thread rclpy/CMakeLists.txt Outdated
macro(rmw_list)
set(RMW_IMPLEMENTATIONS "${RMW_IMPLEMENTATIONS} ${rmw_implementation}")
endmacro()
call_for_each_rmw_implementation(rmw_list)

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.

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.

Also what is this variable used for?

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.

This is a remnant of the old code, I just removed it.

@esteve

esteve commented Mar 4, 2016

Copy link
Copy Markdown
Member Author

@esteve esteve added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Mar 4, 2016
@esteve

esteve commented Mar 4, 2016

Copy link
Copy Markdown
Member Author

This is ready for review.

Comment thread rclpy/rclpy/__init__.py Outdated
if _rclpy is None:
for rmw_implementation in rmw_implementations:
rmw_module = _load_rmw(rmw_implementation)
if rmw_module is not None:

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.

In which cases does this return None?

@gerkey gerkey added in progress Actively being worked on (Kanban column) and removed in review Waiting for review (Kanban column) labels Mar 8, 2016
@gerkey gerkey removed the in progress Actively being worked on (Kanban column) label Mar 8, 2016
@esteve
esteve force-pushed the multiple-vendors branch from 82efeba to 0da8225 Compare March 9, 2016 18:32
@esteve esteve added the in review Waiting for review (Kanban column) label Mar 9, 2016
Comment thread rclpy/rclpy/__init__.py Outdated


def init(args):
global _rclpy

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.

It looks like the other functions do not use global _rclpy. Can you either remove it here or add it to the other functions?

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.

Or is that not necessary since this is the only one where you assign it?

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.

@wjwwood

wjwwood commented Mar 31, 2016

Copy link
Copy Markdown
Member

@wjwwood

wjwwood commented Mar 31, 2016

Copy link
Copy Markdown
Member

@wjwwood
wjwwood merged commit 65cefbc into master Apr 1, 2016
@wjwwood
wjwwood deleted the multiple-vendors branch April 1, 2016 18:39
@wjwwood wjwwood removed the in review Waiting for review (Kanban column) label Apr 1, 2016
@dirk-thomas

Copy link
Copy Markdown
Member

@wjwwood It looks like this PR broke the packaging jobs on Linux and OS X.

@wjwwood

wjwwood commented Apr 4, 2016

Copy link
Copy Markdown
Member

@dirk-thomas the bridge tries to import from std_msgs.msg import Header and gets the ROS 2 version when it was expecting the ROS 1 version. I don't know how you want to address that. I guess we can either change the import pattern for ROS 2 or the ros bridge can do something to make sure it gets the ROS 1 version?

I think the ros bridge has been broken since Python messages were introduced, this pr just exposed the problem.

@wjwwood

wjwwood commented Apr 4, 2016

Copy link
Copy Markdown
Member

This is the start of the problem:

From http://ci.ros2.org/view/packaging/job/packaging_linux/199/console:

11:29:03   File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/__init__.py", line 47, in <module>
11:29:03     from std_msgs.msg import Header
11:29:03   File "/home/rosbuild/ci_scripts/ws/install/lib/python3.4/site-packages/std_msgs/msg/__init__.py", line 1, in <module>
11:29:03     from std_msgs.msg._bool import Bool

@dirk-thomas

Copy link
Copy Markdown
Member

I don't know either what the best way to address this is. But I think the bridge is important and we should keep it working in the upcoming alpha.

@wjwwood

wjwwood commented Apr 4, 2016

Copy link
Copy Markdown
Member

I don't know either how to address it but I think the bridge is important and we should keep it working in the upcoming alpha.

I don't think that was in question?

Do you want me to change the import style of the Python code or do you want to change how the bridge builds its code to avoid imported the ROS 2 messages (and other Python 3 stuff from within Python 2)?

@wjwwood

wjwwood commented Apr 4, 2016

Copy link
Copy Markdown
Member

@ros2/dev bump. Sorry I'm not there to discuss in person, but we need to fix this, can you guys look at the issue and weigh in on our short term solution? I'm happy to make the change to the Python import structure, but I'd like some ideas on what to change it to.

@jackieokay

Copy link
Copy Markdown
Contributor

I'm not an expert here; I think it will take me a little while to understand how the bridge works and how Python messages are imported before I can give you ideas about how to change it.

@dirk-thomas

Copy link
Copy Markdown
Member

I am going to build the bridge locally to see what can be done...

@wjwwood

wjwwood commented Apr 4, 2016

Copy link
Copy Markdown
Member

I was also setting up my local build to build it, let me know if you want me to test something.

@jacquelinekay I'm pretty sure @dirk-thomas could explain it better than me (at least on the ROS bridge side), but the fundamental problem here is that if you source ROS 1 and then ROS 2, and afterwards do from std_msgs.msg import Bool you'll get the generated message from ROS 2. That's because the import signature is the same between ROS 1 and ROS 2 at the moment. This has probably been the case since we introduced the Python message generation, but hasn't been exposed as an issue until I made it impossible to use ROS 2 python modules before calling rclpy.init().

We need to fix that so you can import ROS 2 messages without rclpy being involved, but that would actually just hide this issue again making it logically broken (maybe) instead of throwing an exception as it is now.

So the question to everyone else is should we change the import signature of ROS 2 so this is never a problem, even accidentally. And if so, how should we change it.

Short term we can either change how the ros bridge builds or we can change the import signature in ROS 2. If we choose not to change the import signature then we'll have to do the former, which I guess @dirk-thomas is looking into now. So, I don't think a deep understanding of the bridge is necessary to express an opinion on how we should proceed for this release. Hopefully that explanation helps with that.

@wjwwood

wjwwood commented Apr 4, 2016

Copy link
Copy Markdown
Member

I made a small edit to the previous comment to be more accurate.

@jackieokay

Copy link
Copy Markdown
Contributor

Yeah, I understood most of that from the previous comments, but I still have no idea what the best way to proceed is. Did you mean to say "We need to fix that so you can import ROS 2 messages without rclpy being involved"?

If I had to express an opinion, I would say that changing the import signature of ROS 2 messages doesn't feel like the right way to go, especially since the import signature matches in Python and C++ as it is right now (e.g. std_msgs.msg.Bool and std_msgs::msg::Bool).

@wjwwood

wjwwood commented Apr 4, 2016

Copy link
Copy Markdown
Member

Did you mean to say "We need to fix that so you can import ROS 2 messages without rclpy being involved"?

Yup, edited it again, thanks.

If I had to express an opinion, I would say that changing the import signature of ROS 2 messages doesn't feel like the right way to go, especially since the import signature matches in Python and C++ as it is right now (e.g. std_msgs.msg.Bool and std_msgs::msg::Bool).

I tend to agree with that sentiment, also because we have more flexibility with Python to "make it work" through dynamic behavior (:sparkles:magic:sparkles:). Which is not really an option in C++. So if we decide to stick with identical import statements, then I think we need to do some extra work to ensure the messages are being used in the right system. So, for example adding a "build for" marker in the generated code for both ROS 1 and ROS 2, and then we can add checks in common functions like publish which check that there isn't cross-talk. It isn't perfect, but at least it will give a more meaningful error in many cases.

ryantqiu pushed a commit to snorkel-marlin-repos/ros2_rclpy_pr_5_b6487de3-33a3-4d31-b1a1-ec1e27ca7674 that referenced this pull request Oct 1, 2025
ryantqiu added a commit to snorkel-marlin-repos/ros2_rclpy_pr_5_b6487de3-33a3-4d31-b1a1-ec1e27ca7674 that referenced this pull request Oct 1, 2025
…ardcoding OpenSplice

Merged from original PR #5
Original: ros2/rclpy#5
ryantqiu pushed a commit to snorkel-marlin-repos/ros2_rclpy_pr_5_becee960-e14d-46dc-8f7b-69ea59f099cd that referenced this pull request Oct 2, 2025
ryantqiu added a commit to snorkel-marlin-repos/ros2_rclpy_pr_5_becee960-e14d-46dc-8f7b-69ea59f099cd that referenced this pull request Oct 2, 2025
…ardcoding OpenSplice

Merged from original PR #5
Original: ros2/rclpy#5
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.

5 participants