Skip to content

Commit

Permalink
Setter for sensor_position and sensor_orientation (strawlab#156)
Browse files Browse the repository at this point in the history
* add setter for PointCloud.sensor_origin

* add setter for PointCloud.sensor_orientation
  • Loading branch information
oroulet authored and Sirokujira committed Mar 2, 2018
1 parent 204cd39 commit 22820dc
Show file tree
Hide file tree
Showing 17 changed files with 245 additions and 17 deletions.
5 changes: 4 additions & 1 deletion pcl/eigen.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ cdef extern from "Eigen/Eigen" namespace "Eigen" nogil:
float& element "operator()"(int row, int col)
cdef cppclass Vector4f:
Vector4f() except +
Vector4f(float c0, float c1, float c2, float c3) except +
float *data()
float& element "operator()"(int row, int col)
cdef cppclass Vector3f:
Vector3f() except +
Vector3f(double c0, double c1, double c2) except +
Vector3f(float c0, float c1, float c2) except +
float *data()
float& element "operator()"(int row, int col)
cdef cppclass Vector3i:
Expand All @@ -75,6 +76,8 @@ cdef extern from "Eigen/Eigen" namespace "Eigen" nogil:
double coeff(int row, int col)
double& element "operator()"(int row, int col)
cdef cppclass Quaternionf:
Quaternionf()
Quaternionf(float, float, float, float)
float w()
float x()
float y()
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_FPFHSignature33.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,25 @@ cdef class PointCloud_FPFHSignature33:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PCLPointCloud2.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,25 @@ cdef class PCLPointCloud2:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PCLPointCloud2_180.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,25 @@ cdef class PCLPointCloud2:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PointCloud2.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,25 @@ cdef class PointCloud2:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PointXYZ.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,25 @@ cdef class PointCloud:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PointXYZI.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,25 @@ cdef class PointCloud_PointXYZI:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PointXYZI_172.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,25 @@ cdef class PointCloud_PointXYZI:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PointXYZI_180.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,25 @@ cdef class PointCloud_PointXYZI:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PointXYZRGB.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,25 @@ cdef class PointCloud_PointXYZRGB:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PointXYZRGBA.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,25 @@ cdef class PointCloud_PointXYZRGBA:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PointXYZRGBA_172.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,25 @@ cdef class PointCloud_PointXYZRGBA:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PointXYZRGBA_180.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,25 @@ cdef class PointCloud_PointXYZRGBA:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
16 changes: 15 additions & 1 deletion pcl/pxi/PointCloud_PointXYZRGB_172.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,25 @@ cdef class PointCloud_PointXYZRGB:
return np.array([data[0], data[1], data[2], data[3]],
dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_origin):
self.thisptr().sensor_origin_ = cpp.Vector4f(
new_origin[0],
new_origin[1],
new_origin[2],
0.0)

property sensor_orientation:
def __get__(self):
# NumPy doesn't have a quaternion type, so we return a 4-vector.
cdef cpp.Quaternionf o = self.thisptr().sensor_orientation_
return np.array([o.w(), o.x(), o.y(), o.z()])
return np.array([o.w(), o.x(), o.y(), o.z()], dtype=np.float32)

def __set__(self, cnp.ndarray[cnp.float32_t, ndim=1] new_orient):
self.thisptr().sensor_orientation_ = cpp.Quaternionf(
new_orient[0],
new_orient[1],
new_orient[2],
new_orient[3])

@cython.boundscheck(False)
def from_array(self, cnp.ndarray[cnp.float32_t, ndim=2] arr not None):
Expand Down
Loading

0 comments on commit 22820dc

Please sign in to comment.