-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Math functions #819
Math functions #819
Conversation
headers, extern C, etc...
There are still a few more macro that should be changed to functions and more cleanup and doxygen docs (like putting into appropriate groups, etc) would also be nice... But main further questions are
|
Here my 22c:
|
@gautierhattenberger @dewagter any comments on these open questions? |
no strong opinion on either one, although I lightly prefer the shorter -Christophe On Wed, Sep 10, 2014 at 6:35 PM, Felix Ruess [email protected]
|
No, a style checker can not check if you should be using struct or typedef... |
find sw -path sw/airborne/math -prune -o -name "*.[ch]" -exec sed -ri 's/FLOAT_(VECT[23]_(ASSIGN|COPY|SMUL|DIFF|SUM|ADD|SUB|DOT_PRODUCT|CROSS_PRODUCT))/\1/g' {} +
Some discussion about pure struct vs. typedef: http://stackoverflow.com/questions/1675351/typedef-struct-vs-struct-definitions |
Quoting the coding style from kernel.org:
I'm in favor of keeping the Concerning macros, I think we can drop the type specific macros, especially when they are already mapped to the generic version |
OK, let's keep the struct keyword... |
- norm functions/macros return the scalar value, don't take norm as arg - remove some type specific macros where the generic ones can be used
for consistency always call the fuctions x_rmat_[transp]_vmult, FLOAT_RMAT_VECT3_MUL and FLOAT_RMAT_VECT3_TRANSP_MUL are removed.
sed to the rescue: find sw -path sw/airborne/math -prune -o -name "*.[ch]" -exec sed -i 's/\([ ]*[A-Z0-9_]*QUAT_OF[A-Z0-9_]*(\)\([a-zA-Z0-9_]*,[ ]*\)\([a-zA-Z0-9_]*)\)/\L\1\E\&\2\&\3/g' {} + and so on...
- use float_quat_vmult instead of FLOAT_QUAT_RMAT_B2N|N2B - use float_quat_derivative instead of float_quat_vmul_left
Convert most type specific macros to functions and general cleanup. This should make the code easier to use, debug and wrap externally. Additionally code size probably reduces since it's not all inline anymore... Also cleaned up all the headers and added extern "C" to all the header files the math lib can easier be used in C++ applications. So far the macros still exist and call the respective functions for backwards compatibility. Merging pull request #819 * math_functions: (32 commits) [math][ins] rewrite/move some math to ins_float_invariant [airborne] use math functions instead of macros [math] some dox updates [math] more cleanup, e.g. rmat_[transp]_vmult [math] rmat|quat_identity functions [math] add double versions for vect3/quat norm [math] VECTx_NORM updates [math] int32_rmat_*mult functions [math] algebra: remove some more type specific macros [math] more x_integrate_fi functions [math] fix code style [math] geodetic: RMat instead of Mat33 for ltp_of_ecef [math] remove some unused or type specifc VECTx macros [math] add float_quat_integrate_fi [math] set default PAPARAZZI_SRC [test] add math c files [math] add missing alias [math] wgs84_ellipsoid_to_geoid as function [math] use math functions in orientation conversion [misc] fix natnet2ivy compilation ...
This pull requests contains errors in the calculation of the int32_vect2_norm function, which leads to unexpected heading behaviour. And maybe even more problems! But the current code is unsafe to fly at least! |
A really big 👍 to add a unit test suite for the math libraries! We should have had them for a long time. :) |
If someone can make a simple setup for the tests, me and @EwoudSmeur are willing to write the test cases. |
I have started a very basic skeleton using check. It obviously needs more than just half an hour of work, but it is a start. :) https://github.com/esden/paparazzi/tree/math_tests |
For reference:
|
I have to say I like the way tap is being written. The only question that I did not see an answer to is if libtap is using forking to make sure that the tests are being caught if they lead to a core dump. This is one of the best features of libcheck. If libtap does the same thing I am all for it. |
Convert quite a few math macros to functions.
This should make the code easier to use, debug and wrap externally. Additionally code size probably reduces since it's not all inline anymore...
Also cleaned up all the headers and added
extern "C"
to all the header files the math lib can easier be used in C++ applications.So far the macros all still exist and call the respective functions for backwards compatibility.