Skip to content

Commit

Permalink
Clean and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
cmpute committed Jan 2, 2019
1 parent 47fcd29 commit 92f3539
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 108 deletions.
52 changes: 52 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
dist: trusty
language: python
matrix:
include:
- python: 3.4
env: NUMPY=1.10
- python: 3.5
env: NUMPY=1.11 RUN_COVERAGE=yes
- python: 3.6
env: NUMPY=1.13
# - os: osx
# python: 3.6
# env: NUMPY=1.12 BUILD_DOC=yes

branches:
only:
- master
# - travis

before_install:
#### Install Miniconda ####
- unamestr=`uname`
- if [[ "$unamestr" == 'Linux' ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
elif [[ "$unamestr" == 'Darwin' ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh;
else
echo Error;
fi
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=$HOME/miniconda3/bin:$PATH
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
- conda create -q -n travis python=$TRAVIS_PYTHON_VERSION numpy=$NUMPY pytest cython
- source activate travis
- if [ "$RUN_COVERAGE" == "yes" ]; then pip install coveralls pytest-cov -q; fi

install:
- pip install .

script:
- if [ "$RUN_COVERAGE" == "yes" ]; then
py.test test/ --cov;
else
py.test test/;
fi

after_success:
- if [ "$RUN_COVERAGE" == "yes" ]; then coveralls; fi
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2017, Jacob Zhong
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- [ ] Add unit tests and tests
- [ ] Implement official test codes
- [ ] Add conversion between numpy array and Eigen objects
- [x] Add conversion between numpy array and Eigen objects
- [ ] Migrate original implementations of pypcl
- [ ] Fix TODOs in the code
- [ ] Instantiate template classes to given point-type (e.g. PointXYZ)
Expand Down
2 changes: 1 addition & 1 deletion pcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ python_extension_module(PointField)
install(TARGETS PointField LIBRARY DESTINATION pcl)

add_cython_target(PointCloud CXX)
add_library(PointCloud MODULE ${PointCloud} PointCloud_Impl.cxx)
add_library(PointCloud MODULE ${PointCloud})
target_link_libraries(PointCloud ${PCL_LIBRARIES})
python_extension_module(PointCloud)
install(TARGETS PointCloud LIBRARY DESTINATION pcl)
Expand Down
38 changes: 0 additions & 38 deletions pcl/PointCloud.hpp

This file was deleted.

5 changes: 0 additions & 5 deletions pcl/PointCloud.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,3 @@ cdef public class PointCloud[object CyPointCloud, type CyPointCloud_py]:
cdef Quaternionf _orientation
cdef string _ptype
cdef PCLPointCloud2* ptr(self)

cdef extern from "PointCloud.hpp" namespace "pcl":
cdef cppclass PointCloudFused
void CyTemplatize(PointCloud input, const PointCloudFused &output)
void CyInstantiate(PointCloud output, PointCloudFused &input)
18 changes: 15 additions & 3 deletions pcl/PointCloud.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,23 @@ cdef public class PointCloud[object CyPointCloud, type CyPointCloud_py]:
def __get__(self):
return [field.name.decode('ascii') for field in self.ptr().fields]
property sensor_orientation:
''' Sensor acquisition pose (rotation). '''
''' Sensor acquisition pose (rotation) in quaternion (x,y,z,w). '''
def __get__(self):
raise NotImplementedError()
cdef float *mem_ptr = self._orientation.coeffs().data()
cdef float[:] mem_view = <float[:4]>mem_ptr
cdef np.ndarray arr_raw = np.asarray(mem_view)
return arr_raw
def __set__(self, value):
self._orientation = Quaternionf(value[3], value[0], value[1], value[2])
property sensor_origin:
''' Sensor acquisition pose (origin/translation). '''
def __get__(self):
raise NotImplementedError()
cdef float *mem_ptr = self._origin.data()
cdef float[:] mem_view = <float[:3]>mem_ptr
cdef np.ndarray arr_raw = np.asarray(mem_view)
return arr_raw
def __set__(self, value):
self._origin = Vector4f(value[0], value[1], value[2], 0)

property xyz:
'''
Expand Down Expand Up @@ -291,6 +301,8 @@ cdef public class PointCloud[object CyPointCloud, type CyPointCloud_py]:
'''
Get whether the point cloud is organized
'''
def __get__(self):
return self.height > 1

def __len__(self):
return self.ptr().width * self.ptr().height
Expand Down
45 changes: 0 additions & 45 deletions pcl/PointCloud_Impl.cxx

This file was deleted.

16 changes: 5 additions & 11 deletions pcl/_eigen.pxd
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
# bindings in the package will be finally combined into eigency
# from eigency.core cimport *
# bindings in the package could be finally combined into eigency

cdef extern from "Eigen/Eigen" namespace "Eigen" nogil:
cdef cppclass Vector4f:
Vector4f() except +
Vector4f(float c0, float c1, float c2, float c3) except +
Vector4f(float, float, float, float) except +
float *data()
float& element "operator()"(int row, int col)

float& element "operator()"(int index)
@staticmethod
Vector4f Zero()

cdef cppclass Quaternionf:
Quaternionf()
Quaternionf(float, float, float, float)
float w()
float x()
float y()
float z()

Quaternionf(float w, float x, float y, float z)
Vector4f& coeffs()
@staticmethod
Quaternionf Identity()

Expand Down
23 changes: 19 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@

setup(
name="PyPCL",
version="0.1.1",
description="Minial PCL Binding",
version="0.1.2",
description="Cython bindings of Point Cloud Library (PCL) ",
long_description='(see project homepage)',
author='Jacob Zhong',
license="MIT",
author_email='[email protected]',
url='https://github.com/cmpute/pypcl',
download_url='https://github.com/cmpute/pypcl/archive/master.zip',
license='BSD-3-Clause',
packages=['pcl'],
package_data={'pcl':['*.pxd', '*/*.pxd', '__init__.pxd']},
install_requires=['cython', 'eigency'],
install_requires=['cython', 'scikit-build'],
extras_require={'test': ['pytest']},
classifiers=[
'Programming Language :: C++',
'Programming Language :: Cython',
'Programming Language :: Python :: 3',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Development Status :: 2 - Pre-Alpha',
'Topic :: Scientific/Engineering'
],
keywords=['pcl', 'pointcloud', 'numpy', 'cython', 'binding'],
)
12 changes: 12 additions & 0 deletions test/test_pointcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ def test_point_type(self):
cloud = pcl.PointCloud([(1,2,3,255),(2,3,4,255)], 'xyzrgb')
assert len(cloud) == 2
assert cloud.names == ['x', 'y', 'z', 'rgb']

def test_origin(self):
cloud = pcl.PointCloud([(1,2,3),(2,3,4)])
assert np.all(cloud.sensor_origin == np.zeros(3))
cloud.sensor_origin = [1, 2, 3]
assert np.all(cloud.sensor_origin == np.array([1,2,3]))

def test_orientation(self):
cloud = pcl.PointCloud([(1,2,3),(2,3,4)])
assert np.all(cloud.sensor_orientation == np.array([0,0,0,1]))
cloud.sensor_orientation = [1, 2, 3, 1]
assert np.all(cloud.sensor_orientation == np.array([1,2,3,1]))
Empty file added test/test_visualizer.py
Empty file.

0 comments on commit 92f3539

Please sign in to comment.