mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 03:27:33 +08:00
[python] wrap pprz_geodetic with swig
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
build
|
||||
*.c
|
||||
pprz_geodetic.py
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
all:
|
||||
swig2.0 -python pprz_geodetic.i
|
||||
python setup.py build_ext --inplace
|
||||
|
||||
clean:
|
||||
rm -rf build *.so *.c pprz_geodetic.py
|
||||
@@ -0,0 +1,10 @@
|
||||
/* File : pprz_geodetic.i */
|
||||
%module pprz_geodetic
|
||||
%feature("autodoc", "3");
|
||||
%include "typemaps.i"
|
||||
%include pprz_geodetic_int.i
|
||||
%include pprz_geodetic_float.i
|
||||
%include pprz_geodetic_double.i
|
||||
%{
|
||||
#define SWIG_FILE_WITH_INIT
|
||||
%}
|
||||
@@ -0,0 +1,65 @@
|
||||
/* File : pprz_geodetic_double.i */
|
||||
%module geodetic_double
|
||||
%{
|
||||
#include "math/pprz_geodetic_double.h"
|
||||
%}
|
||||
|
||||
struct EcefCoor_d {
|
||||
double x; ///< in meters
|
||||
double y; ///< in meters
|
||||
double z; ///< in meters
|
||||
};
|
||||
|
||||
struct LlaCoor_d {
|
||||
double lat; ///< in radians
|
||||
double lon; ///< in radians
|
||||
double alt; ///< in meters above WGS84 reference ellipsoid
|
||||
};
|
||||
|
||||
struct NedCoor_d {
|
||||
double x; ///< in meters
|
||||
double y; ///< in meters
|
||||
double z; ///< in meters
|
||||
};
|
||||
|
||||
struct EnuCoor_d {
|
||||
double x; ///< in meters
|
||||
double y; ///< in meters
|
||||
double z; ///< in meters
|
||||
};
|
||||
|
||||
struct UtmCoor_d {
|
||||
double north; ///< in meters
|
||||
double east; ///< in meters
|
||||
double alt; ///< in meters above WGS84 reference ellipsoid
|
||||
uint8_t zone; ///< UTM zone number
|
||||
};
|
||||
|
||||
struct LtpDef_d {
|
||||
struct EcefCoor_d ecef; ///< origin of local frame in ECEF
|
||||
struct LlaCoor_d lla; ///< origin of local frame in LLA
|
||||
struct DoubleRMat ltp_of_ecef; ///< rotation from ECEF to local frame
|
||||
double hmsl; ///< height in meters above mean sea level
|
||||
};
|
||||
|
||||
void lla_of_utm_d(struct LlaCoor_d *out, struct UtmCoor_d *in);
|
||||
void ltp_def_from_ecef_d(struct LtpDef_d *def, struct EcefCoor_d *ecef);
|
||||
void lla_of_ecef_d(struct LlaCoor_d *out, struct EcefCoor_d *in);
|
||||
void ecef_of_lla_d(struct EcefCoor_d *out, struct LlaCoor_d *in);
|
||||
|
||||
void enu_of_ecef_point_d(struct EnuCoor_d *ned, struct LtpDef_d *def, struct EcefCoor_d *ecef);
|
||||
void ned_of_ecef_point_d(struct NedCoor_d *ned, struct LtpDef_d *def, struct EcefCoor_d *ecef);
|
||||
|
||||
void enu_of_ecef_vect_d(struct EnuCoor_d *ned, struct LtpDef_d *def, struct EcefCoor_d *ecef);
|
||||
void ned_of_ecef_vect_d(struct NedCoor_d *ned, struct LtpDef_d *def, struct EcefCoor_d *ecef);
|
||||
|
||||
void ecef_of_enu_point_d(struct EcefCoor_d *ecef, struct LtpDef_d *def, struct EnuCoor_d *enu);
|
||||
void ecef_of_ned_point_d(struct EcefCoor_d *ecef, struct LtpDef_d *def, struct NedCoor_d *ned);
|
||||
|
||||
void ecef_of_enu_vect_d(struct EcefCoor_d *ecef, struct LtpDef_d *def, struct EnuCoor_d *enu);
|
||||
void ecef_of_ned_vect_d(struct EcefCoor_d *ecef, struct LtpDef_d *def, struct NedCoor_d *ned);
|
||||
|
||||
void enu_of_lla_point_d(struct EnuCoor_d *enu, struct LtpDef_d *def, struct LlaCoor_d *lla);
|
||||
void ned_of_lla_point_d(struct NedCoor_d *ned, struct LtpDef_d *def, struct LlaCoor_d *lla);
|
||||
|
||||
double gc_of_gd_lat_d(double gd_lat, double hmsl);
|
||||
@@ -0,0 +1,80 @@
|
||||
/* File : pprz_geodetic_float.i */
|
||||
%module geodetic_float
|
||||
%{
|
||||
#include "math/pprz_geodetic_float.h"
|
||||
%}
|
||||
|
||||
struct EcefCoor_f {
|
||||
float x; ///< in meters
|
||||
float y; ///< in meters
|
||||
float z; ///< in meters
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief vector in Latitude, Longitude and Altitude
|
||||
*/
|
||||
struct LlaCoor_f {
|
||||
float lat; ///< in radians
|
||||
float lon; ///< in radians
|
||||
float alt; ///< in meters above WGS84 reference ellipsoid
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief vector in North East Down coordinates
|
||||
* Units: meters */
|
||||
struct NedCoor_f {
|
||||
float x; ///< in meters
|
||||
float y; ///< in meters
|
||||
float z; ///< in meters
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief vector in East North Up coordinates
|
||||
* Units: meters */
|
||||
struct EnuCoor_f {
|
||||
float x; ///< in meters
|
||||
float y; ///< in meters
|
||||
float z; ///< in meters
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief position in UTM coordinates
|
||||
* Units: meters */
|
||||
struct UtmCoor_f {
|
||||
float north; ///< in meters
|
||||
float east; ///< in meters
|
||||
float alt; ///< in meters above WGS84 reference ellipsoid
|
||||
uint8_t zone; ///< UTM zone number
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief definition of the local (flat earth) coordinate system
|
||||
* @details Defines the origin of the local coordinate system
|
||||
* in ECEF and LLA coordinates and the roation matrix from
|
||||
* ECEF to local frame */
|
||||
struct LtpDef_f {
|
||||
struct EcefCoor_f ecef; ///< origin of local frame in ECEF
|
||||
struct LlaCoor_f lla; ///< origin of local frame in LLA
|
||||
struct FloatRMat ltp_of_ecef; ///< rotation from ECEF to local frame
|
||||
float hmsl; ///< Height above mean sea level in meters
|
||||
};
|
||||
|
||||
void lla_of_utm_f(struct LlaCoor_f *lla, struct UtmCoor_f *utm);
|
||||
void utm_of_lla_f(struct UtmCoor_f *utm, struct LlaCoor_f *lla);
|
||||
void ltp_def_from_ecef_f(struct LtpDef_f *def, struct EcefCoor_f *ecef);
|
||||
void ltp_def_from_lla_f(struct LtpDef_f *def, struct LlaCoor_f *lla);
|
||||
void lla_of_ecef_f(struct LlaCoor_f *out, struct EcefCoor_f *in);
|
||||
void ecef_of_lla_f(struct EcefCoor_f *out, struct LlaCoor_f *in);
|
||||
void enu_of_ecef_point_f(struct EnuCoor_f *enu, struct LtpDef_f *def, struct EcefCoor_f *ecef);
|
||||
void ned_of_ecef_point_f(struct NedCoor_f *ned, struct LtpDef_f *def, struct EcefCoor_f *ecef);
|
||||
void enu_of_ecef_vect_f(struct EnuCoor_f *enu, struct LtpDef_f *def, struct EcefCoor_f *ecef);
|
||||
void ned_of_ecef_vect_f(struct NedCoor_f *ned, struct LtpDef_f *def, struct EcefCoor_f *ecef);
|
||||
void enu_of_lla_point_f(struct EnuCoor_f *enu, struct LtpDef_f *def, struct LlaCoor_f *lla);
|
||||
void ned_of_lla_point_f(struct NedCoor_f *ned, struct LtpDef_f *def, struct LlaCoor_f *lla);
|
||||
|
||||
/* not enought precision with floats - used the double version */
|
||||
void ecef_of_enu_point_f(struct EcefCoor_f *ecef, struct LtpDef_f *def, struct EnuCoor_f *enu);
|
||||
void ecef_of_ned_point_f(struct EcefCoor_f *ecef, struct LtpDef_f *def, struct NedCoor_f *ned);
|
||||
void ecef_of_enu_vect_f(struct EcefCoor_f *ecef, struct LtpDef_f *def, struct EnuCoor_f *enu);
|
||||
void ecef_of_ned_vect_f(struct EcefCoor_f *ecef, struct LtpDef_f *def, struct NedCoor_f *ned);
|
||||
/* end use double versions */
|
||||
@@ -0,0 +1,90 @@
|
||||
/* File : pprz_geodetic_int.i */
|
||||
%module geodetic_int
|
||||
%include "stdint.i"
|
||||
%{
|
||||
#include "math/pprz_geodetic_int.h"
|
||||
%}
|
||||
|
||||
|
||||
/**
|
||||
* @brief vector in EarthCenteredEarthFixed coordinates
|
||||
* @details Origin at center of mass of the Earth. Z-axis is pointing north,
|
||||
* the x-axis intersects the sphere of the earth at 0° latitude (Equator)
|
||||
* and 0° longitude (Greenwich). Y-axis completes it to right-hand system.
|
||||
* Units: centimeters */
|
||||
struct EcefCoor_i {
|
||||
int32_t x; ///< in centimeters
|
||||
int32_t y; ///< in centimeters
|
||||
int32_t z; ///< in centimeters
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief vector in Latitude, Longitude and Altitude
|
||||
*/
|
||||
struct LlaCoor_i {
|
||||
int32_t lat; ///< in degrees*1e7
|
||||
int32_t lon; ///< in degrees*1e7
|
||||
int32_t alt; ///< in millimeters above WGS84 reference ellipsoid
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief vector in North East Down coordinates
|
||||
*/
|
||||
struct NedCoor_i {
|
||||
int32_t x; ///< North
|
||||
int32_t y; ///< East
|
||||
int32_t z; ///< Down
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief vector in East North Up coordinates
|
||||
*/
|
||||
struct EnuCoor_i {
|
||||
int32_t x; ///< East
|
||||
int32_t y; ///< North
|
||||
int32_t z; ///< Up
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief position in UTM coordinates
|
||||
*/
|
||||
struct UtmCoor_i {
|
||||
int32_t north; ///< in centimeters
|
||||
int32_t east; ///< in centimeters
|
||||
int32_t alt; ///< in millimeters above WGS84 reference ellipsoid
|
||||
uint8_t zone; ///< UTM zone number
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief definition of the local (flat earth) coordinate system
|
||||
* @details Defines the origin of the local coordinate system
|
||||
* in ECEF and LLA coordinates and the roation matrix from
|
||||
* ECEF to local frame */
|
||||
struct LtpDef_i {
|
||||
struct EcefCoor_i ecef; ///< Reference point in ecef
|
||||
struct LlaCoor_i lla; ///< Reference point in lla
|
||||
struct Int32RMat ltp_of_ecef; ///< Rotation matrix
|
||||
int32_t hmsl; ///< Height above mean sea level in mm
|
||||
};
|
||||
|
||||
extern void ltp_of_ecef_rmat_from_lla_i(struct Int32RMat *ltp_of_ecef, struct LlaCoor_i *lla);
|
||||
extern void ltp_def_from_ecef_i(struct LtpDef_i *def, struct EcefCoor_i *ecef);
|
||||
extern void ltp_def_from_lla_i(struct LtpDef_i *def, struct LlaCoor_i *lla);
|
||||
extern void lla_of_ecef_i(struct LlaCoor_i *out, struct EcefCoor_i *in);
|
||||
extern void ecef_of_lla_i(struct EcefCoor_i *out, struct LlaCoor_i *in);
|
||||
extern void enu_of_ecef_point_i(struct EnuCoor_i *enu, struct LtpDef_i *def, struct EcefCoor_i *ecef);
|
||||
extern void ned_of_ecef_point_i(struct NedCoor_i *ned, struct LtpDef_i *def, struct EcefCoor_i *ecef);
|
||||
extern void enu_of_ecef_pos_i(struct EnuCoor_i *enu, struct LtpDef_i *def, struct EcefCoor_i *ecef);
|
||||
extern void ned_of_ecef_pos_i(struct NedCoor_i *ned, struct LtpDef_i *def, struct EcefCoor_i *ecef);
|
||||
extern void enu_of_ecef_vect_i(struct EnuCoor_i *enu, struct LtpDef_i *def, struct EcefCoor_i *ecef);
|
||||
extern void ned_of_ecef_vect_i(struct NedCoor_i *ned, struct LtpDef_i *def, struct EcefCoor_i *ecef);
|
||||
extern void enu_of_lla_point_i(struct EnuCoor_i *enu, struct LtpDef_i *def, struct LlaCoor_i *lla);
|
||||
extern void ned_of_lla_point_i(struct NedCoor_i *ned, struct LtpDef_i *def, struct LlaCoor_i *lla);
|
||||
extern void enu_of_lla_vect_i(struct EnuCoor_i *enu, struct LtpDef_i *def, struct LlaCoor_i *lla);
|
||||
extern void ned_of_lla_vect_i(struct NedCoor_i *ned, struct LtpDef_i *def, struct LlaCoor_i *lla);
|
||||
extern void ecef_of_enu_point_i(struct EcefCoor_i *ecef, struct LtpDef_i *def, struct EnuCoor_i *enu);
|
||||
extern void ecef_of_ned_point_i(struct EcefCoor_i *ecef, struct LtpDef_i *def, struct NedCoor_i *ned);
|
||||
extern void ecef_of_enu_pos_i(struct EcefCoor_i *ecef, struct LtpDef_i *def, struct EnuCoor_i *enu);
|
||||
extern void ecef_of_ned_pos_i(struct EcefCoor_i *ecef, struct LtpDef_i *def, struct NedCoor_i *ned);
|
||||
extern void ecef_of_enu_vect_i(struct EcefCoor_i *ecef, struct LtpDef_i *def, struct EnuCoor_i *enu);
|
||||
extern void ecef_of_ned_vect_i(struct EcefCoor_i *ecef, struct LtpDef_i *def, struct NedCoor_i *ned);
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/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"],
|
||||
)
|
||||
Reference in New Issue
Block a user