Browse Source

Fix for euler.

master
James Goppert 9 years ago
parent
commit
fa31c61f2c
  1. 0
      .gitmodules
  2. 3
      .travis.yml
  3. 52
      CMakeLists.txt
  4. 1
      doc/.gitignore
  5. 240
      doc/euler_gimbal_lock.ipynb
  6. 6
      matrix/Euler.hpp
  7. 4
      test/CMakeLists.txt
  8. 7
      test/attitude.cpp

0
.gitmodules vendored

3
.travis.yml

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

52
CMakeLists.txt

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

1
doc/.gitignore vendored

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

240
doc/euler_gimbal_lock.ipynb

File diff suppressed because one or more lines are too long

6
matrix/Euler.hpp

@ -52,11 +52,11 @@ public:
if (fabs(theta() - (Type)M_PI_2) < 1.0e-3) { if (fabs(theta() - (Type)M_PI_2) < 1.0e-3) {
phi() = (Type)0.0; 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) { } else if ((Type)fabs(theta() + (Type)M_PI_2) < (Type)1.0e-3) {
phi() = (Type)0.0; 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 { } else {
phi() = (Type)atan2(dcm(2,1), dcm(2,2)); phi() = (Type)atan2(dcm(2,1), dcm(2,2));

4
test/CMakeLists.txt

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

7
test/attitude.cpp

@ -96,15 +96,16 @@ int main()
// euler gimbal lock check // euler gimbal lock check
// note if theta = pi/2, then roll is set to zero // note if theta = pi/2, then roll is set to zero
float pi_2 = float(M_PI_2); 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); Dcmf dcm_lock(euler_gimbal_lock);
Eulerf euler_gimbal_lock_out(dcm_lock); Eulerf euler_gimbal_lock_out(dcm_lock);
printf("gimbal lock test");
euler_gimbal_lock_out.T().print(); euler_gimbal_lock_out.T().print();
euler_gimbal_lock.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 // 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); Dcmf dcm_lock2(euler_gimbal_lock2);
Eulerf euler_gimbal_lock_out2(dcm_lock2); Eulerf euler_gimbal_lock_out2(dcm_lock2);
euler_gimbal_lock_out2.T().print(); euler_gimbal_lock_out2.T().print();

Loading…
Cancel
Save