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

Python: raw_data + easier read_messages interface #50

Merged
merged 1 commit into from
Aug 26, 2022

Conversation

liambenson
Copy link
Contributor

Description of Changes

This adds the ability to get the raw data from a ROSMessage in python. In addition,

Test Plan

Added a test to compare the output of the raw_data property with what rosbag generates.

Copy link
Contributor

@brendangeck brendangeck left a comment

Choose a reason for hiding this comment

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

Alright I installed the wheel of this PR and tested locally. It looks like it works well. Just left a couple of comments

Comment on lines 22 to 24
const std::string& topic,
const RosValue::ros_time_t& timestamp,
const std::string& md5,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little worried that adding these args at the front could cause backwards compatibility issues. Is this a class that is only used internal to embag?

Copy link
Contributor Author

@liambenson liambenson Aug 26, 2022

Choose a reason for hiding this comment

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

Theoretically, it would be kind of weird to create the class externally since the msg_def field is private and theres no actual way to get the data without it. Thus, only View can actually interact with the class. I can remove this change though as its not necessary, thought it would just be good cleanup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just removed it!

Comment on lines +93 to +95
.def_property_readonly("raw_data", [](std::shared_ptr<Embag::RosMessage> &m) {
return py::bytes(&m->raw_buffer->at(m->raw_buffer_offset), m->raw_data_len);
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also want to add raw=True functionality to the read_messages interface in embag.Bag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could - but to do that (and maintain compatibility with rosbag) I would need to change the constructor of RosMessage and add a new field for the raw message definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going to leave this for potential future improvement!

@liambenson liambenson merged commit a128608 into master Aug 26, 2022
@liambenson liambenson deleted the liam/add_raw_data branch August 26, 2022 23:49
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