Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buffer interface for RosValue arrays #33

Merged
merged 14 commits into from
Dec 9, 2021

Conversation

liambenson
Copy link
Contributor

Fixes: DATA-516

Description of Changes

This adds a buffer protocol interface to the py bindings for the library.

One minor issue that I have with this is that we're exposing the underlying pointer to the data buffer via the pybind11::buffer_info, but without writing the interface ourselves rather than using pybind's helpers I'm not sure if theres any alternative.

Additionally, requiring that we build the embag library with pybind might not be the best idea, but I think exposing the buffer_info is better than just exposing the raw pointer.

Test Plan

Added a test to ensure that we can create a memoryview of array RosValues.

@liambenson liambenson force-pushed the liam/add_buffer_interface branch from f7a2739 to ad0cd71 Compare December 7, 2021 07:34
Copy link

@jaredjxyz jaredjxyz left a comment

Choose a reason for hiding this comment

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

Mostly just want more explanations and guiding code here - the code istels looks good, thanks for adding a unit test

lib/ros_value.h Outdated
@@ -320,6 +323,29 @@ class RosValue {
return values;
}

// Used for python bindings

Choose a reason for hiding this comment

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

I think very few people are going to be familiar with what pybind11::buffer_info does -
Could you write a better comment explaining what exactly this does and how one might properly use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@liambenson liambenson requested a review from jaredjxyz December 9, 2021 01:44
@liambenson liambenson merged commit 1d07069 into master Dec 9, 2021
@liambenson liambenson deleted the liam/add_buffer_interface branch December 9, 2021 01:59
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