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

confuse readme about trasform numpy to pointcloud2 #22

Open
lianghongzhuo opened this issue Sep 4, 2020 · 0 comments
Open

confuse readme about trasform numpy to pointcloud2 #22

lianghongzhuo opened this issue Sep 4, 2020 · 0 comments

Comments

@lianghongzhuo
Copy link

When I try to transform numpy to pointcloud2, the example on readme file is confusing me:

data = np.zeros(100, dtype=[
  ('x', np.float32),
  ('y', np.float32),
  ('vectors', np.float32, (3,))
])
data['x'] = np.arange(100)
data['y'] = data['x']*2
data['vectors'] = np.arange(100)[:,np.newaxis]

msg = ros_numpy.msgify(PointCloud2, data)

In this example, "x" filed and "y" filed has a size 100, and filed "vectors" has a size 100*3
This makes me thinking that filed "vectors" should put the points I want to transform to ros msg, and "x" filed and "y" filed is the indices of it on the depth image.
This is wrong.
I took some time to realize it. So, to avoid confusion to other users, I propose to update the readme file example as follows:

points = np.random.rand(100,3)  
data = np.zeros(100, dtype=[
  ('x', np.float32),
  ('y', np.float32),
  ('z', np.float32),
])
data['x'] = points[:, 0]
data['y'] = points[:, 1]
data['z'] = points[:, 2]
msg = ros_numpy.msgify(PointCloud2, data)
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

No branches or pull requests

1 participant