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

Create ordered point cloud (issue #126) #157

Open
wants to merge 3 commits into
base: jade-devel
Choose a base branch
from

Conversation

Hi-Zed
Copy link

@Hi-Zed Hi-Zed commented Jan 20, 2020

Small changes to create_cloud in point_cloud2.py to support ordered point clouds with specific height and width.
Mentioned in issue #126

@haudren
Copy link

haudren commented Jan 21, 2020

Thanks for the patch, it looks straightforward and a good addition. I hope this can get merged!

Copy link
Member

@tfoote tfoote left a comment

Choose a reason for hiding this comment

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

This looks reasonable. Though it needs a little bit more error handling. None times an int will except.

@return: The point cloud.
@rtype: L{sensor_msgs.msg.PointCloud2}
"""
if height == 1:
Copy link
Member

Choose a reason for hiding this comment

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

This looks like it will have problems if height is non unary but width is defaulted to None. Some other checks are going to be necessary.

Copy link
Author

Choose a reason for hiding this comment

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

I'll add a check on both height and width.
The original implementation didn't perform any check on header, fields and points, for example, if they are empty. Do you want me to add something like that?

Copy link
Member

Choose a reason for hiding this comment

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

I was mostly worried about the default values messing things up. Though a little bit of sanitizing would be valuable. But we need to be careful about what error response behavior is caused by invalid data.


cloud_struct = struct.Struct(_get_struct_fmt(False, fields))

buff = ctypes.create_string_buffer(cloud_struct.size * len(points))

point_step, pack_into = cloud_struct.size, cloud_struct.pack_into
point_step = cloud_struct.size
Copy link
Member

Choose a reason for hiding this comment

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

These intermediate values appear to only be used once so are probably not worth creating at all.

Copy link
Member

@tfoote tfoote left a comment

Choose a reason for hiding this comment

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

Thanks for the update that looks better. Could you also write some basic unit tests. It would be good to add some that assert the ordering that this implements stays valid. As well as can validate the error handling. And it appears that we don't have any python unit tests for this at all.

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