Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * utils.h - Fawkes tf utils 00004 * 00005 * Created: Fri Jun 1 14:07:00 2012 00006 * Copyright 2012 Tim Niemueller [www.niemueller.de] 00007 ****************************************************************************/ 00008 00009 /* This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. A runtime exception applies to 00013 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00021 */ 00022 00023 /* This code is based on ROS tf with the following copyright and license: 00024 * 00025 * Copyright (c) 2008, Willow Garage, Inc. 00026 * All rights reserved. 00027 * 00028 * Redistribution and use in source and binary forms, with or without 00029 * modification, are permitted provided that the following conditions are met: 00030 * 00031 * * Redistributions of source code must retain the above copyright 00032 * notice, this list of conditions and the following disclaimer. 00033 * * Redistributions in binary form must reproduce the above copyright 00034 * notice, this list of conditions and the following disclaimer in the 00035 * documentation and/or other materials provided with the distribution. 00036 * * Neither the name of the Willow Garage, Inc. nor the names of its 00037 * contributors may be used to endorse or promote products derived from 00038 * this software without specific prior written permission. 00039 * 00040 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00041 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00042 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00043 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00044 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00045 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00046 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00047 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00048 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00049 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00050 * POSSIBILITY OF SUCH DAMAGE. 00051 */ 00052 00053 #ifndef __LIBS_TF_TF_H_ 00054 #define __LIBS_TF_TF_H_ 00055 00056 #include <tf/types.h> 00057 00058 namespace fawkes { 00059 namespace tf { 00060 #if 0 /* just to make Emacs auto-indent happy */ 00061 } 00062 } 00063 #endif 00064 00065 /** Resolve transform name. 00066 * @param prefix prefix to prepend to frame name 00067 * @param frame_name frame name 00068 * @return resolved frame name 00069 */ 00070 std::string 00071 resolve(const std::string& prefix, const std::string& frame_name) 00072 { 00073 if (frame_name.size() > 0) { 00074 if (frame_name[0] == '/') { 00075 return frame_name; 00076 } 00077 } 00078 if (prefix.size() > 0) { 00079 if (prefix[0] == '/') { 00080 std::string composite = prefix; 00081 composite.append("/"); 00082 composite.append(frame_name); 00083 return composite; 00084 } else { 00085 std::string composite; 00086 composite = "/"; 00087 composite.append(prefix); 00088 composite.append("/"); 00089 composite.append(frame_name); 00090 return composite; 00091 } 00092 } else { 00093 std::string composite; 00094 composite = "/"; 00095 composite.append(frame_name); 00096 return composite; 00097 } 00098 } 00099 00100 } // end namespace tf 00101 } // end namespace fawkes 00102 00103 #endif