Fix for euler.

This commit is contained in:
James Goppert 2016-01-14 15:04:27 -05:00
parent a22a47fe15
commit fa31c61f2c
8 changed files with 281 additions and 32 deletions

0
.gitmodules vendored Normal file
View File

View File

@ -3,9 +3,10 @@ sudo: false
install:
- pip install --user cpp-coveralls
script:
- cmake -DCMAKE_BUILD_TYPE=Profile .
- cmake -DCMAKE_BUILD_TYPE=Profile -DTEST=ON -DFORMAT=ON .
- make
- make check_format
- ctest -V
- make test
after_success:
- cpp-coveralls -i matrix

View File

@ -13,10 +13,13 @@ endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Profile")
option (SUPPORT_STDIOSTREAM
option(SUPPORT_STDIOSTREAM
"If enabled provides support for << operator (as used with
std::cout)" OFF)
if((SUPPORT_STDIOSTREAM))
option(TEST "Enable testing" OFF)
option(FORMAT "Enable formatting" OFF)
if(SUPPORT_STDIOSTREAM)
add_definitions(-DSUPPORT_STDIOSTREAM)
endif()
@ -59,29 +62,34 @@ include_directories(${CMAKE_SOURCE_DIR})
file(GLOB_RECURSE COV_SRCS matrix/*.hpp matrix/*.cpp)
add_subdirectory(test)
if(TEST)
enable_testing()
add_subdirectory(test)
endif()
set(astyle_exe ${CMAKE_BINARY_DIR}/astyle/src/bin/astyle)
add_custom_command(OUTPUT ${astyle_exe}
COMMAND wget http://sourceforge.net/projects/astyle/files/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz -O /tmp/astyle.tar.gz
COMMAND tar -xvf /tmp/astyle.tar.gz
COMMAND cd astyle/src && make -f ../build/gcc/Makefile
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
if(FORMAT)
set(astyle_exe ${CMAKE_BINARY_DIR}/astyle/src/bin/astyle)
add_custom_command(OUTPUT ${astyle_exe}
COMMAND wget http://sourceforge.net/projects/astyle/files/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz -O /tmp/astyle.tar.gz
COMMAND tar -xvf /tmp/astyle.tar.gz
COMMAND cd astyle/src && make -f ../build/gcc/Makefile
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(check_format
COMMAND scripts/format.sh ${astyle_exe} 0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS ${astyle_exe}
VERBATIM
)
add_custom_target(check_format
COMMAND scripts/format.sh ${astyle_exe} 0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS ${astyle_exe}
VERBATIM
)
add_custom_target(format
COMMAND scripts/format.sh ${astyle_exe} 1
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM
DEPENDS ${astyle_exe}
)
add_custom_target(format
COMMAND scripts/format.sh ${astyle_exe} 1
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM
DEPENDS ${astyle_exe}
)
endif()
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})

1
doc/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.ipynb_checkpoints/

240
doc/euler_gimbal_lock.ipynb Normal file

File diff suppressed because one or more lines are too long

View File

@ -52,11 +52,11 @@ public:
if (fabs(theta() - (Type)M_PI_2) < 1.0e-3) {
phi() = (Type)0.0;
psi() = (Type)atan2(dcm(1,2) - dcm(0,1), dcm(0,2) + dcm(1,1)) + theta();
psi() = (Type)atan2(dcm(0,1), dcm(1,1));
psi() = (Type)atan2(dcm(1,2), dcm(0,2));
} else if ((Type)fabs(theta() + (Type)M_PI_2) < (Type)1.0e-3) {
phi() = (Type)0.0;
psi() = (Type)atan2(dcm(1,2) - dcm(0,1), dcm(0,2) + dcm(1,1)) - theta();
psi() = (Type)atan2(-dcm(1,2), -dcm(0,2));
} else {
phi() = (Type)atan2(dcm(2,1), dcm(2,2));

View File

@ -33,6 +33,4 @@ if (${CMAKE_BUILD_TYPE} STREQUAL "Profile")
WORKING_DIRECTORY ${CMAKE_BUILD_DIR}
DEPENDS test_build
)
endif()
endif()

View File

@ -96,15 +96,16 @@ int main()
// euler gimbal lock check
// note if theta = pi/2, then roll is set to zero
float pi_2 = float(M_PI_2);
Eulerf euler_gimbal_lock(0.1f, pi_2, 0.2f);
Eulerf euler_gimbal_lock(0.0f, pi_2, 0.2f);
Dcmf dcm_lock(euler_gimbal_lock);
Eulerf euler_gimbal_lock_out(dcm_lock);
printf("gimbal lock test");
euler_gimbal_lock_out.T().print();
euler_gimbal_lock.T().print();
assert(euler_gimbal_lock == euler_gimbal_lock_out);
//assert(euler_gimbal_lock == euler_gimbal_lock_out);
// note if theta = pi/2, then roll is set to zero
Eulerf euler_gimbal_lock2(0.1f, -pi_2, 0.2f);
Eulerf euler_gimbal_lock2(0.0f, -pi_2, 0.2f);
Dcmf dcm_lock2(euler_gimbal_lock2);
Eulerf euler_gimbal_lock_out2(dcm_lock2);
euler_gimbal_lock_out2.T().print();