svo
Semi-Direct Visual Odometry
|
00001 // This file is part of SVO - Semi-direct Visual Odometry. 00002 // 00003 // Copyright (C) 2014 Christian Forster <forster at ifi dot uzh dot ch> 00004 // (Robotics and Perception Group, University of Zurich, Switzerland). 00005 // 00006 // SVO is free software: you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the Free Software 00008 // Foundation, either version 3 of the License, or any later version. 00009 // 00010 // SVO is distributed in the hope that it will be useful, but WITHOUT ANY 00011 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 #ifndef SVO_GLOBAL_H_ 00018 #define SVO_GLOBAL_H_ 00019 00020 #include <list> 00021 #include <vector> 00022 #include <string> 00023 #include <stdint.h> 00024 #include <stdio.h> 00025 #include <math.h> 00026 00027 #include <Eigen/Core> 00028 #include <opencv2/opencv.hpp> 00029 #include <sophus/se3.h> 00030 #include <vikit/performance_monitor.h> 00031 #include <boost/shared_ptr.hpp> 00032 00033 #ifdef SVO_USE_ROS 00034 #include <ros/console.h> 00035 #define SVO_DEBUG_STREAM(x) ROS_DEBUG_STREAM(x) 00036 #define SVO_INFO_STREAM(x) ROS_INFO_STREAM(x) 00037 #define SVO_WARN_STREAM(x) ROS_WARN_STREAM(x) 00038 #define SVO_WARN_STREAM_THROTTLE(rate, x) ROS_WARN_STREAM_THROTTLE(rate, x) 00039 #define SVO_ERROR_STREAM(x) ROS_ERROR_STREAM(x) 00040 #else 00041 #define SVO_INFO_STREAM(x) std::cerr<<"\033[0;0m[INFO] "<<x<<"\033[0;0m"<<std::endl; 00042 #define SVO_DEBUG_STREAM(x) SVO_INFO_STREAM(x) 00043 #define SVO_WARN_STREAM(x) std::cerr<<"\033[0;33m[WARN] "<<x<<"\033[0;0m"<<std::endl; 00044 #define SVO_ERROR_STREAM(x) std::cerr<<"\033[1;31m[ERROR] "<<x<<"\033[0;0m"<<std::endl; 00045 #include <chrono> // Adapted from rosconsole. Copyright (c) 2008, Willow Garage, Inc. 00046 #define SVO_WARN_STREAM_THROTTLE(rate, x) \ 00047 do { \ 00048 static double __log_stream_throttle__last_hit__ = 0.0; \ 00049 std::chrono::time_point<std::chrono::system_clock> __log_stream_throttle__now__ = \ 00050 std::chrono::system_clock::now(); \ 00051 if (__log_stream_throttle__last_hit__ + rate <= \ 00052 std::chrono::duration_cast<std::chrono::seconds>( \ 00053 __log_stream_throttle__now__.time_since_epoch()).count()) { \ 00054 __log_stream_throttle__last_hit__ = \ 00055 std::chrono::duration_cast<std::chrono::seconds>( \ 00056 __log_stream_throttle__now__.time_since_epoch()).count(); \ 00057 SVO_WARN_STREAM(x); \ 00058 } \ 00059 } while(0) 00060 #endif 00061 00062 namespace svo 00063 { 00064 using namespace Eigen; 00065 using namespace Sophus; 00066 00067 const double EPS = 0.0000000001; 00068 const double PI = 3.14159265; 00069 00070 #ifdef SVO_TRACE 00071 extern vk::PerformanceMonitor* g_permon; 00072 #define SVO_LOG(value) g_permon->log(std::string((#value)),(value)) 00073 #define SVO_LOG2(value1, value2) SVO_LOG(value1); SVO_LOG(value2) 00074 #define SVO_LOG3(value1, value2, value3) SVO_LOG2(value1, value2); SVO_LOG(value3) 00075 #define SVO_LOG4(value1, value2, value3, value4) SVO_LOG2(value1, value2); SVO_LOG2(value3, value4) 00076 #define SVO_START_TIMER(name) g_permon->startTimer((name)) 00077 #define SVO_STOP_TIMER(name) g_permon->stopTimer((name)) 00078 #else 00079 #define SVO_LOG(v) 00080 #define SVO_LOG2(v1, v2) 00081 #define SVO_LOG3(v1, v2, v3) 00082 #define SVO_LOG4(v1, v2, v3, v4) 00083 #define SVO_START_TIMER(name) 00084 #define SVO_STOP_TIMER(name) 00085 #endif 00086 00087 class Frame; 00088 typedef boost::shared_ptr<Frame> FramePtr; 00089 } // namespace svo 00090 00091 #endif // SVO_GLOBAL_H_