diff --git a/sw/airborne/math/Makefile b/sw/airborne/math/Makefile index 3d7873a2c7..474adb25df 100644 --- a/sw/airborne/math/Makefile +++ b/sw/airborne/math/Makefile @@ -28,7 +28,7 @@ OBJ= $(addprefix $(BUILDDIR)/,$(SRC:.c=.o)) LIBNAME=libpprzmath all: - @cat README + @cat README.md shared_lib: $(OBJ) @echo CREATE shared $(LIBNAME) diff --git a/sw/airborne/math/README.md b/sw/airborne/math/README.md index 59ec0eb78d..e337f702c7 100644 --- a/sw/airborne/math/README.md +++ b/sw/airborne/math/README.md @@ -7,24 +7,25 @@ See also the @ref math docs. HOWTO install a shared library to use in other projects ------------------------------------------------------- -1. Build library: in this folder, type +1. Build library: in sw/airborne/math, type `make shared_lib` - the default build directory is var/build/math + The default build directory is var/build/math, to change it: `BUILDDIR= make shared_lib` 2. Install library: in this folder, type - make install_shared_lib + `make install_shared_lib` the default install dir is /usr/local and will install files in - /usr/local/lib - /usr/local/lib/pkgconfig - /usr/local/include/pprz + * /usr/local/lib + * /usr/local/lib/pkgconfig + * /usr/local/include/pprz to change the install dir: `PREFIX= make install_shared_lib` - note that the default install dir needs root privilege + note that the default install dir needs root privilege and is usually called via + `sudo make shared_lib` HOWTO use the shared library ---------------------------- diff --git a/sw/lib/python/pprz_math/pprz_algebra_float.i b/sw/lib/python/pprz_math/pprz_algebra_float.i index bb2073928b..4a648d513b 100644 --- a/sw/lib/python/pprz_math/pprz_algebra_float.i +++ b/sw/lib/python/pprz_math/pprz_algebra_float.i @@ -37,6 +37,11 @@ struct FloatEulers { float psi; ///< in radians }; +struct FloatRates { + float p; ///< in rad/s + float q; ///< in rad/s + float r; ///< in rad/s +}; %extend FloatVect2 { char *__str__() { @@ -265,3 +270,32 @@ struct FloatEulers { return r; } }; + +%extend FloatRates { + char *__str__() { + static char tmp[1024]; + sprintf(tmp,"Rates(%g, %g, %g)", $self->p ,$self->q, $self->r); + return tmp; + } + FloatRates(float p=0.0, float q=0.0, float r=0.0) { + struct FloatRates *fr = (struct FloatRates *) malloc(sizeof(struct FloatRates)); + fr->p = p; + fr->q = q; + fr->r = r; + return fr; + } + struct FloatRates __add__(struct FloatRates *other) { + struct FloatRates fr; + fr.p = $self->p + other->p; + fr.q = $self->q + other->q; + fr.r = $self->r + other->r; + return fr; + } + struct FloatRates __sub__(struct FloatRates *other) { + struct FloatRates fr; + fr.p = $self->p - other->p; + fr.q = $self->q - other->q; + fr.r = $self->r - other->r; + return fr; + } +}; diff --git a/sw/lib/python/pprz_math/setup.py b/sw/lib/python/pprz_math/setup.py index 330c81d49c..127cd28527 100644 --- a/sw/lib/python/pprz_math/setup.py +++ b/sw/lib/python/pprz_math/setup.py @@ -31,7 +31,7 @@ algebra_module = Extension('_algebra', ], include_dirs=common_inc_dirs) -setup(name='geodetic', +setup(name='pprz_math', version='0.1', author="Felix Ruess", description="""Pprz math wrappers""",