Skip to content

Split rclpy module for easier porting to pybind11#675

Merged
sloretz merged 13 commits intomasterfrom
split_rclpy_module
Feb 26, 2021
Merged

Split rclpy module for easier porting to pybind11#675
sloretz merged 13 commits intomasterfrom
split_rclpy_module

Conversation

@sloretz
Copy link
Copy Markdown
Contributor

@sloretz sloretz commented Jan 29, 2021

@cottsay specifically, here's a way to split the giant _rclpy module in pieces that can be ported a little at a time. This PR has split out exceptions (first commit) and rclpy_context_get_domain_id (second commit).

There are two modules: _rclpy and _rclpy_pybind11. Inside rclpy.impl.implementation_singleton the functions and exceptions on _rclpy_pybind11 gets set on _rclpy. _rclpy itself needs the exception objects to raise them in C code, so it also imports _rclpy_pybind11. To do that, I had to convert _rclpy to use Multi phase Initialization.

@azeey @IanTheEngineer @cottsay FYI

Part of #665

@sloretz sloretz requested a review from cottsay January 29, 2021 01:35
@sloretz sloretz self-assigned this Jan 29, 2021
@sloretz sloretz mentioned this pull request Jan 29, 2021
34 tasks
Comment on lines +26 to +32
std::string append_rcl_error(std::string prepend)
{
prepend += ": ";
prepend += rcl_get_error_string().str;
rcl_reset_error();
return prepend;
}
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.

Won't including this header in multiple *.cpp files that get compiled into the same binary cause a symbol collision?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I suppose so. It looks like inline would solve the issue (Explanation 2. 1.)

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.

Even if this gets inlined, I would assume the RCLError constructor would still have the issue. Any reason not to create a .cpp file for the implementation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No reason other than laziness 🙃

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

b802e7e + 49d5ec0 + d8182ad put made a cpp file for these and added them to rclpy_common - which does double duty of also introducing pybind11 to rclpy_common.

@sloretz sloretz force-pushed the add_pybind11_dependency branch from 850e84b to 531d36e Compare February 11, 2021 00:53
@sloretz sloretz force-pushed the add_pybind11_dependency branch from c04dc58 to 674b02c Compare February 12, 2021 17:06
@delete-merged-branch delete-merged-branch bot deleted the branch master February 12, 2021 17:07
@sloretz sloretz changed the base branch from add_pybind11_dependency to master February 12, 2021 17:09
@sloretz sloretz marked this pull request as ready for review February 12, 2021 17:10
Copy link
Copy Markdown
Member

@cottsay cottsay left a comment

Choose a reason for hiding this comment

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

A few comments that you should take a look at, but nothing blocking.

The stateful module change looks like it was a lot of work - well done.

Adds _rclpy_pybind11 module for incrementally converting to pybind11
Makes _rclpy use multiphase initialization so it can import
_rclpy_pybind11

Signed-off-by: Shane Loretz <sloretz@openrobotics.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@openrobotics.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Feb 26, 2021

CI (build: --packages-up-to rclpy test: --packages-select rclpy)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Feb 26, 2021

CI again after fixing warning on OSX

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Feb 26, 2021

CI (build: --packages-up-to rclpy test: --packages-select rclpy)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Copy link
Copy Markdown
Member

@cottsay cottsay left a comment

Choose a reason for hiding this comment

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

🎉

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.

2 participants