[python] minor updates to math wrappers

This commit is contained in:
Felix Ruess
2015-12-22 16:41:07 +01:00
parent 34e076e2f7
commit beeb698314
4 changed files with 44 additions and 9 deletions
+1 -1
View File
@@ -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)
+8 -7
View File
@@ -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=<your_build_dir> 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=<your_install_dir> 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
----------------------------
@@ -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;
}
};
+1 -1
View File
@@ -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""",