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

expose the raw data (quaternion) of SO3 #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ If you require any functionality that is not currently in the wrapper, feel free

How to install
--------------
Install `cython` if you don't have already

First, setup `eigency`
```
pip install cython
```

Then, setup `eigency`

```
git clone https://github.com/wouterboomsma/eigency.git
cd eigency
python setup.py build_ext --inplace
python setup.py
# put in your bashrc
export PYTHONPATH="$PYTHONPATH:<path to eigency>"
```
Expand All @@ -56,6 +61,8 @@ git submodule update
python setup.py build_ext --inplace
# put in your bashrc
export PYTHONPATH="$PYTHONPATH:<path to PySophus>"
# alternately, install it to your default dist-packages
python setup.py install
```

Usage
Expand Down
23 changes: 22 additions & 1 deletion sophus.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ cdef class SO3:

def log(self):
return ndarray(self.thisptr.log())

def data(self):
ptr = self.thisptr.data()
return numpy.array((ptr[0], ptr[1], ptr[2], ptr[3]))

def setData(self, np.ndarray data):
data = data.reshape((4,))
ptr = self.thisptr.data()
ptr[0] = data[0]
ptr[1] = data[1]
ptr[2] = data[2]
ptr[3] = data[3]
self.normalize()

def inverse(self):
res = SO3()
Expand Down Expand Up @@ -139,7 +152,7 @@ cdef class SE3:
Returns the SO3 part (rotation)
"""
return SO3(ndarray(self.thisptr.so3().matrix()))

def log(self):
return ndarray(self.thisptr.log())

Expand All @@ -157,6 +170,14 @@ cdef class SE3:
def setRotationMatrix(self, np.ndarray matrix):
self.thisptr.setRotationMatrix(Map[Matrix3d](matrix))

def setQuaternion(self, np.ndarray quaternion):
quaternion = quaternion.reshape((4,))
ptr = self.thisptr.so3().data()
ptr[0] = quaternion[0]
ptr[1] = quaternion[1]
ptr[2] = quaternion[2]
ptr[3] = quaternion[3]

def __mul__(SE3 x, SE3 y):
"""
Group multiplication operator
Expand Down
3 changes: 1 addition & 2 deletions sophus_defs.pxd
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
from eigency.core cimport *



cdef extern from "<sophus/so3.hpp>" namespace "Sophus":
cdef cppclass SO3[Scalar]:
SO3() except +
Expand All @@ -13,6 +11,7 @@ cdef extern from "<sophus/so3.hpp>" namespace "Sophus":
Matrix3d& matrix()

Vector3d log()
Scalar* data()

SO3 inverse()
void normalize()
Expand Down