neka-nat / cupoch

Robotics with GPU computing
MIT License
918 stars 107 forks source link

OccupancyGrid.voxels not returning a Python type #92

Closed Geurto closed 2 years ago

Geurto commented 2 years ago

Hello,

First of all, thank you very much for your hard work on this amazing library.

I'm having issues accessing the voxels member of an OccupancyGrid object. Every time I try to access it, the interpreter returns {TypeError}Unable to convert function return value to a Python type! The signature was (arg0: cupoch.cupoch.geometry.OccupancyGrid) -> thrust::device_vector<cupoch::geometry::OccupancyVoxel, rmm::mr::thrust_allocator<cupoch::geometry::OccupancyVoxel> >

This happens in my own code, but also when trying to access data in the OccupancyGrid created in this test example (in the example I had to scale down the OccupancyGrid call from OccupancyGrid() to OccupancyGrid(0.1, 256) due to memory constraints).

It this known behaviour? Am I supposed to extract the voxels in a different way? For instance, converting the OccupancyGrid to a VoxelGrid and accessing the voxels by using vg = cph.geometry.VoxelGrid.create_from_occupancy_grid(self.ocg) voxels = vg.voxels.cpu() does work, even though it seem the VoxelGrid data is slightly different from the original voxels (i.e. in the example linked above, the original OccupancyGrid has 506 voxels and the VoxelGrid has 55). Furthermore, does this conversion also not lose the probability information associated with each OccupancyGrid voxel?

For added context, I'm using Python 3.6.9 and cupoch 0.2.4.0.

Warm regards and thank you in advance, Peter

neka-nat commented 2 years ago

Sorry for the delay, but I have corrected the problem with the latest master. https://github.com/neka-nat/cupoch/blob/master/examples/python/robotics/occupancygrid.py#L17

Geurto commented 2 years ago

Thank you for the fix!