[python] rename math to pprz_math and add algebra module

to use it e.g. in ipython:
PYTHONPATH=$PPRZ_SRC/sw/lib/python iypthon
$ from pprz_math.geodetic import *
or
$ import pprz_math.algebra
This commit is contained in:
Felix Ruess
2015-01-09 14:13:20 +01:00
parent cebe398b56
commit 0e529758c0
17 changed files with 89 additions and 47 deletions
+2 -3
View File
@@ -5,10 +5,9 @@ import sys
import os
PPRZ_SRC = os.getenv("PAPARAZZI_SRC", "../../../..")
sys.path.append(PPRZ_SRC + "/sw/lib/python/math")
sys.path.append(PPRZ_SRC + "/sw/lib/python")
from pprz_geodetic import *
from math import degrees
from pprz_math.geodetic import *
import matplotlib.pyplot as plt
import numpy as np
-3
View File
@@ -1,3 +0,0 @@
build
*.c
pprz_geodetic.py
-7
View File
@@ -1,7 +0,0 @@
all:
swig2.0 -python -keyword -I../../../airborne pprz_geodetic.i
python setup.py build_ext --inplace
clean:
rm -rf build *.so *.c pprz_geodetic.py
View File
-32
View File
@@ -1,32 +0,0 @@
#!/usr/bin/env python
"""
setup.py file for pprz_geodetic math wrapper
"""
from distutils.core import setup, Extension
from os import path, getenv
# if PAPARAZZI_SRC not set, then assume the tree containing this
# file is a reasonable substitute
pprz_src = getenv("PAPARAZZI_SRC", path.normpath(path.join(path.dirname(path.abspath(__file__)), '../../../../')))
pprz_airborne = path.join(pprz_src, "sw/airborne")
common_inc_dirs = ["./", path.join(pprz_src, "sw/include"), pprz_airborne]
pprz_geodetic_module = Extension('_pprz_geodetic',
sources=['pprz_geodetic_wrap.c',
path.join(pprz_airborne, 'math/pprz_geodetic_int.c'),
path.join(pprz_airborne, 'math/pprz_geodetic_double.c'),
path.join(pprz_airborne, 'math/pprz_geodetic_float.c')
],
include_dirs=common_inc_dirs)
setup(name='geodetic_double',
version='0.1',
author="Felix Ruess",
description="""Pprz geodetic math wrapper""",
ext_modules=[pprz_geodetic_module],
py_modules=["pprz_geodetic"],
)
+4
View File
@@ -0,0 +1,4 @@
build
*.c
geodetic.py
algebra.py
+8
View File
@@ -0,0 +1,8 @@
all:
swig2.0 -python -keyword -I../../../airborne geodetic.i
swig2.0 -python -keyword -I../../../airborne algebra.i
python setup.py build_ext --inplace
clean:
rm -rf build *.so *.c *.pyc geodetic.py algebra.py
+1
View File
@@ -0,0 +1 @@
__all__ = ["geodetic", "algebra"]
+10
View File
@@ -0,0 +1,10 @@
/* File : algebra.i */
%module algebra
%feature("autodoc", "3");
%include "typemaps.i"
%include pprz_algebra_int.i
%include pprz_algebra_float.i
%include pprz_algebra_double.i
%{
#define SWIG_FILE_WITH_INIT
%}
@@ -1,5 +1,5 @@
/* File : pprz_geodetic.i */
%module pprz_geodetic
/* File : geodetic.i */
%module geodetic
%feature("autodoc", "3");
%include "typemaps.i"
%include pprz_geodetic_int.i
@@ -0,0 +1,7 @@
/* File : pprz_algebra_double.i */
%module algebra_double
%{
#include "math/pprz_algebra_double.h"
%}
%include "math/pprz_algebra_double.h"
@@ -0,0 +1,7 @@
/* File : pprz_algebra_float.i */
%module algebra_float
%{
#include "math/pprz_algebra_float.h"
%}
%include "math/pprz_algebra_float.h"
@@ -0,0 +1,8 @@
/* File : pprz_algebra_int.i */
%module algebra_int
%include "stdint.i"
%{
#include "math/pprz_algebra_int.h"
%}
%include "math/pprz_algebra_int.h"
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env python
"""
setup.py file for pprz math wrappers
"""
from distutils.core import setup, Extension
from os import path, getenv
# if PAPARAZZI_SRC not set, then assume the tree containing this
# file is a reasonable substitute
pprz_src = getenv("PAPARAZZI_SRC", path.normpath(path.join(path.dirname(path.abspath(__file__)), '../../../../')))
pprz_airborne = path.join(pprz_src, "sw/airborne")
common_inc_dirs = [path.join(pprz_src, "sw/include"), pprz_airborne]
geodetic_module = Extension('_geodetic',
sources=['geodetic_wrap.c',
path.join(pprz_airborne, 'math/pprz_geodetic_int.c'),
path.join(pprz_airborne, 'math/pprz_geodetic_double.c'),
path.join(pprz_airborne, 'math/pprz_geodetic_float.c')
],
include_dirs=common_inc_dirs)
algebra_module = Extension('_algebra',
sources=['algebra_wrap.c',
path.join(pprz_airborne, 'math/pprz_algebra_int.c'),
path.join(pprz_airborne, 'math/pprz_algebra_double.c'),
path.join(pprz_airborne, 'math/pprz_algebra_float.c'),
path.join(pprz_airborne, 'math/pprz_trig_int.c'),
],
include_dirs=common_inc_dirs)
setup(name='geodetic',
version='0.1',
author="Felix Ruess",
description="""Pprz math wrappers""",
ext_modules=[geodetic_module, algebra_module],
py_modules=["geodetic", "algebra"],
)