mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-27 17:06:31 +08:00
[python] minor updates to math wrappers
This commit is contained in:
@@ -28,7 +28,7 @@ OBJ= $(addprefix $(BUILDDIR)/,$(SRC:.c=.o))
|
|||||||
LIBNAME=libpprzmath
|
LIBNAME=libpprzmath
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@cat README
|
@cat README.md
|
||||||
|
|
||||||
shared_lib: $(OBJ)
|
shared_lib: $(OBJ)
|
||||||
@echo CREATE shared $(LIBNAME)
|
@echo CREATE shared $(LIBNAME)
|
||||||
|
|||||||
@@ -7,24 +7,25 @@ See also the @ref math docs.
|
|||||||
HOWTO install a shared library to use in other projects
|
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`
|
`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`
|
to change it: `BUILDDIR=<your_build_dir> make shared_lib`
|
||||||
|
|
||||||
2. Install library: in this folder, type
|
2. Install library: in this folder, type
|
||||||
make install_shared_lib
|
`make install_shared_lib`
|
||||||
|
|
||||||
the default install dir is /usr/local
|
the default install dir is /usr/local
|
||||||
and will install files in
|
and will install files in
|
||||||
/usr/local/lib
|
* /usr/local/lib
|
||||||
/usr/local/lib/pkgconfig
|
* /usr/local/lib/pkgconfig
|
||||||
/usr/local/include/pprz
|
* /usr/local/include/pprz
|
||||||
|
|
||||||
to change the install dir: `PREFIX=<your_install_dir> make install_shared_lib`
|
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
|
HOWTO use the shared library
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ struct FloatEulers {
|
|||||||
float psi; ///< in radians
|
float psi; ///< in radians
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FloatRates {
|
||||||
|
float p; ///< in rad/s
|
||||||
|
float q; ///< in rad/s
|
||||||
|
float r; ///< in rad/s
|
||||||
|
};
|
||||||
|
|
||||||
%extend FloatVect2 {
|
%extend FloatVect2 {
|
||||||
char *__str__() {
|
char *__str__() {
|
||||||
@@ -265,3 +270,32 @@ struct FloatEulers {
|
|||||||
return r;
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ algebra_module = Extension('_algebra',
|
|||||||
],
|
],
|
||||||
include_dirs=common_inc_dirs)
|
include_dirs=common_inc_dirs)
|
||||||
|
|
||||||
setup(name='geodetic',
|
setup(name='pprz_math',
|
||||||
version='0.1',
|
version='0.1',
|
||||||
author="Felix Ruess",
|
author="Felix Ruess",
|
||||||
description="""Pprz math wrappers""",
|
description="""Pprz math wrappers""",
|
||||||
|
|||||||
Reference in New Issue
Block a user