diff --git a/sw/airborne/test/math/compare_utm_enu.py b/sw/airborne/test/math/compare_utm_enu.py index 249f05864b..2d4c79e442 100755 --- a/sw/airborne/test/math/compare_utm_enu.py +++ b/sw/airborne/test/math/compare_utm_enu.py @@ -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 diff --git a/sw/lib/python/math/.gitignore b/sw/lib/python/math/.gitignore deleted file mode 100644 index 391a60a8c1..0000000000 --- a/sw/lib/python/math/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -build -*.c -pprz_geodetic.py diff --git a/sw/lib/python/math/Makefile b/sw/lib/python/math/Makefile deleted file mode 100644 index a0c966a86c..0000000000 --- a/sw/lib/python/math/Makefile +++ /dev/null @@ -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 diff --git a/sw/lib/python/math/__init__.py b/sw/lib/python/math/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/sw/lib/python/math/setup.py b/sw/lib/python/math/setup.py deleted file mode 100644 index 90a971ff3c..0000000000 --- a/sw/lib/python/math/setup.py +++ /dev/null @@ -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"], - ) diff --git a/sw/lib/python/pprz_math/.gitignore b/sw/lib/python/pprz_math/.gitignore new file mode 100644 index 0000000000..94803ce577 --- /dev/null +++ b/sw/lib/python/pprz_math/.gitignore @@ -0,0 +1,4 @@ +build +*.c +geodetic.py +algebra.py diff --git a/sw/lib/python/pprz_math/Makefile b/sw/lib/python/pprz_math/Makefile new file mode 100644 index 0000000000..968b483503 --- /dev/null +++ b/sw/lib/python/pprz_math/Makefile @@ -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 diff --git a/sw/lib/python/pprz_math/__init__.py b/sw/lib/python/pprz_math/__init__.py new file mode 100644 index 0000000000..83a33e4a8f --- /dev/null +++ b/sw/lib/python/pprz_math/__init__.py @@ -0,0 +1 @@ +__all__ = ["geodetic", "algebra"] diff --git a/sw/lib/python/pprz_math/algebra.i b/sw/lib/python/pprz_math/algebra.i new file mode 100644 index 0000000000..7fb5641d22 --- /dev/null +++ b/sw/lib/python/pprz_math/algebra.i @@ -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 +%} diff --git a/sw/lib/python/math/pprz_geodetic.i b/sw/lib/python/pprz_math/geodetic.i similarity index 77% rename from sw/lib/python/math/pprz_geodetic.i rename to sw/lib/python/pprz_math/geodetic.i index af337fc36c..f999b7495f 100644 --- a/sw/lib/python/math/pprz_geodetic.i +++ b/sw/lib/python/pprz_math/geodetic.i @@ -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 diff --git a/sw/lib/python/pprz_math/pprz_algebra_double.i b/sw/lib/python/pprz_math/pprz_algebra_double.i new file mode 100644 index 0000000000..d99fd9a4bc --- /dev/null +++ b/sw/lib/python/pprz_math/pprz_algebra_double.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" diff --git a/sw/lib/python/pprz_math/pprz_algebra_float.i b/sw/lib/python/pprz_math/pprz_algebra_float.i new file mode 100644 index 0000000000..77cee3ec81 --- /dev/null +++ b/sw/lib/python/pprz_math/pprz_algebra_float.i @@ -0,0 +1,7 @@ +/* File : pprz_algebra_float.i */ +%module algebra_float +%{ +#include "math/pprz_algebra_float.h" +%} + +%include "math/pprz_algebra_float.h" diff --git a/sw/lib/python/pprz_math/pprz_algebra_int.i b/sw/lib/python/pprz_math/pprz_algebra_int.i new file mode 100644 index 0000000000..708458296f --- /dev/null +++ b/sw/lib/python/pprz_math/pprz_algebra_int.i @@ -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" diff --git a/sw/lib/python/math/pprz_geodetic_double.i b/sw/lib/python/pprz_math/pprz_geodetic_double.i similarity index 100% rename from sw/lib/python/math/pprz_geodetic_double.i rename to sw/lib/python/pprz_math/pprz_geodetic_double.i diff --git a/sw/lib/python/math/pprz_geodetic_float.i b/sw/lib/python/pprz_math/pprz_geodetic_float.i similarity index 100% rename from sw/lib/python/math/pprz_geodetic_float.i rename to sw/lib/python/pprz_math/pprz_geodetic_float.i diff --git a/sw/lib/python/math/pprz_geodetic_int.i b/sw/lib/python/pprz_math/pprz_geodetic_int.i similarity index 100% rename from sw/lib/python/math/pprz_geodetic_int.i rename to sw/lib/python/pprz_math/pprz_geodetic_int.i diff --git a/sw/lib/python/pprz_math/setup.py b/sw/lib/python/pprz_math/setup.py new file mode 100644 index 0000000000..330c81d49c --- /dev/null +++ b/sw/lib/python/pprz_math/setup.py @@ -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"], + )