util.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00028 #ifndef UTIL_H_
00029 #define UTIL_H_
00030 
00031 
00032 #include <android/log.h>
00033 #include <rtabmap/utilite/UEventsHandler.h>
00034 #include <rtabmap/utilite/ULogger.h>
00035 #include <tango-gl/util.h>
00036 
00037 class LogHandler : public UEventsHandler
00038 {
00039 public:
00040         LogHandler()
00041         {
00042                 registerToEventsManager();
00043         }
00044 protected:
00045         virtual void handleEvent(UEvent * event)
00046         {
00047                 if(event->getClassName().compare("ULogEvent") == 0)
00048                 {
00049                         ULogEvent * logEvent = (ULogEvent*)event;
00050                         if(logEvent->getCode() == ULogger::kDebug)
00051                         {
00052                                 LOGD(logEvent->getMsg().c_str());
00053                         }
00054                         else if(logEvent->getCode() == ULogger::kInfo)
00055                         {
00056                                 LOGI(logEvent->getMsg().c_str());
00057                         }
00058                         else if(logEvent->getCode() == ULogger::kWarning)
00059                         {
00060                                 LOGW(logEvent->getMsg().c_str());
00061                         }
00062                         else if(logEvent->getCode() >= ULogger::kError)
00063                         {
00064                                 LOGE(logEvent->getMsg().c_str());
00065                         }
00066 
00067                 }
00068         }
00069 };
00070 
00071 static const rtabmap::Transform opengl_world_T_tango_world(
00072                 1.0f, 0.0f,  0.0f, 0.0f,
00073                 0.0f, 0.0f, 1.0f, 0.0f,
00074                 0.0f, -1.0f,  0.0f, 0.0f);
00075 
00076 static const rtabmap::Transform depth_camera_T_opengl_camera(
00077                 1.0f, 0.0f, 0.0f, 0.0f,
00078                 0.0f, -1.0f, 0.0f, 0.0f,
00079                 0.0f, 0.0f, -1.0f, 0.0f);
00080 
00081 static const rtabmap::Transform opengl_world_T_rtabmap_world(
00082                 0.0f, -1.0f,  0.0f, 0.0f,
00083                 0.0f, 0.0f, 1.0f, 0.0f,
00084                 -1.0f, 0.0f,  0.0f, 0.0f);
00085 
00086 static const rtabmap::Transform rtabmap_world_T_opengl_world(
00087                  0.0f, 0.0f, -1.0f, 0.0f,
00088                 -1.0f, 0.0f,  0.0f, 0.0f,
00089                  0.0f, 1.0f,  0.0f, 0.0f);
00090 
00091 inline glm::mat4 glmFromTransform(const rtabmap::Transform & transform)
00092 {
00093         glm::mat4 mat(1.0f);
00094         // gl is column wise
00095         mat[0][0] = transform(0,0);
00096         mat[1][0] = transform(0,1);
00097         mat[2][0] = transform(0,2);
00098         mat[0][1] = transform(1,0);
00099         mat[1][1] = transform(1,1);
00100         mat[2][1] = transform(1,2);
00101         mat[0][2] = transform(2,0);
00102         mat[1][2] = transform(2,1);
00103         mat[2][2] = transform(2,2);
00104 
00105         mat[3][0] = transform(0,3);
00106         mat[3][1] = transform(1,3);
00107         mat[3][2] = transform(2,3);
00108         return mat;
00109 }
00110 
00111 inline rtabmap::Transform glmToTransform(const glm::mat4 & mat)
00112 {
00113         rtabmap::Transform transform;
00114         // gl is column wise
00115         transform(0,0) = mat[0][0];
00116         transform(0,1) = mat[1][0];
00117         transform(0,2) = mat[2][0];
00118         transform(1,0) = mat[0][1];
00119         transform(1,1) = mat[1][1];
00120         transform(1,2) = mat[2][1];
00121         transform(2,0) = mat[0][2];
00122         transform(2,1) = mat[1][2];
00123         transform(2,2) = mat[2][2];
00124 
00125         transform(0,3) = mat[3][0];
00126         transform(1,3) = mat[3][1];
00127         transform(2,3) = mat[3][2];
00128 
00129         return transform;
00130 }
00131 
00132 #endif /* UTIL_H_ */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:28