Skip to content

Convert init/shutdown to pybind11#715

Merged
sloretz merged 13 commits intomasterfrom
pybind11_init
Mar 22, 2021
Merged

Convert init/shutdown to pybind11#715
sloretz merged 13 commits intomasterfrom
pybind11_init

Conversation

@sloretz
Copy link
Copy Markdown
Contributor

@sloretz sloretz commented Mar 16, 2021

Part of #665

@sloretz sloretz self-assigned this Mar 16, 2021
@sloretz sloretz mentioned this pull request Mar 16, 2021
34 tasks
Copy link
Copy Markdown
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

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

Looking good!

{
rcl_ret_t ret = rcl_init_options_fini(&rcl_options_);
if (RCL_RET_OK != ret) {
fprintf(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sloretz FYI there's RCUTILS_SAFE_FWRITE_TO_STDERR too.

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.

Using rcutils stderr macro in 66a7131

}
}

rcl_init_options_t rcl_options_;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sloretz same nits as for SerializedMessage in #712

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.

Made InitOptions a struct in 007b970

Comment on lines +84 to +85
rcl_allocator_t allocator = rcl_get_default_allocator();
InitOptions init_options(allocator);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sloretz nit:

Suggested change
rcl_allocator_t allocator = rcl_get_default_allocator();
InitOptions init_options(allocator);
InitOptions init_options(rcl_get_default_allocator());

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.

removed temporary allocator in 25e8e22

}

rcl_ret_t ret = rcl_shutdown(context);
if (ret != RCL_RET_OK) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sloretz nit: flip operands

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.

Flipped the operands in dc06621


if (unparsed_ros_args_count < 0) {
throw std::runtime_error("failed to count unparsed arguments");
} else if (0 == unparsed_ros_args_count) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sloretz nit^N: that else is redundant, the previous if clause will leave the scope if it ever evaluates to true.

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.

removed else in ec35c46

@sloretz sloretz force-pushed the pybind11_init branch 2 times, most recently from 66a7131 to 3dfce00 Compare March 18, 2021 16:11
@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Mar 18, 2021

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

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

private:
using std::runtime_error::runtime_error;

friend void throw_if_unparsed_ros_args(py::list, const rcl_arguments_t &);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sloretz uh, why the privacy?

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.

IIUC private with using std::runtime_error::runtime_error forces one to use throw_if_unused_ros_args() so the exception text is always formatted the same. The access specifier has no effect on the friend declaration.

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 ended up removing the friendship and pybind11 use from rclpy_common (with Windows Debug compatibility in mind) in d224f19

@hidmic
Copy link
Copy Markdown
Contributor

hidmic commented Mar 18, 2021

MacOS seems to be having issues with some tests.

@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Mar 18, 2021

Testing if adding visibility macro before friend declaration satifies windows: Build Status

@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Mar 18, 2021

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

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

@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Mar 22, 2021

CI OSX to see if test failures are fixed by d224f19
Build Status

CI Windows debug out of paranoia
Build Status

@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Mar 22, 2021

Ah, I'm more confident that 021e795 will fix the OSX test failure.

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

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

@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Mar 22, 2021

Windows debug again with 3df8fbc

  • Windows Debug Build Status

@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Mar 22, 2021

Windows debug warning should be fixed by #731

@hidmic
Copy link
Copy Markdown
Contributor

hidmic commented Mar 22, 2021

I'll get this one in. Oops, not mine.

sloretz added 13 commits March 22, 2021 14:49
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>
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 Mar 22, 2021

Rebased to fix conflicts - no changes

Copy link
Copy Markdown
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

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

LGTM!

"failed to fini rcl_init_options_t in destructor:");
RCUTILS_SAFE_FWRITE_TO_STDERR(rcl_get_error_string().str);
RCUTILS_SAFE_FWRITE_TO_STDERR("\n");
rcl_reset_error();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sloretz meta, nothing to do here: one cool alternative to printing to stderr I saw in the code base is to use Python warnings. pybind11 doesn't provide a nice wrapper though.

@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Mar 22, 2021

One last CI run

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

@sloretz sloretz merged commit a09ac14 into master Mar 22, 2021
@delete-merged-branch delete-merged-branch bot deleted the pybind11_init branch March 22, 2021 23:37
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