kinematics_base.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002 *
00003 * Software License Agreement (BSD License)
00004 *
00005 *  Copyright (c) 2008, Willow Garage, Inc.
00006 *  All rights reserved.
00007 *
00008 *  Redistribution and use in source and binary forms, with or without
00009 *  modification, are permitted provided that the following conditions
00010 *  are met:
00011 *
00012 *   * Redistributions of source code must retain the above copyright
00013 *     notice, this list of conditions and the following disclaimer.
00014 *   * Redistributions in binary form must reproduce the above
00015 *     copyright notice, this list of conditions and the following
00016 *     disclaimer in the documentation and/or other materials provided
00017 *     with the distribution.
00018 *   * Neither the name of Willow Garage, Inc. nor the names of its
00019 *     contributors may be used to endorse or promote products derived
00020 *     from this software without specific prior written permission.
00021 *
00022 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 *  POSSIBILITY OF SUCH DAMAGE.
00034 *
00035 * Author: Sachin Chitta
00036 *********************************************************************/
00037 
00038 #include <moveit/kinematics_base/kinematics_base.h>
00039 
00040 const double kinematics::KinematicsBase::DEFAULT_SEARCH_DISCRETIZATION = 0.1;
00041 const double kinematics::KinematicsBase::DEFAULT_TIMEOUT = 1.0;
00042 
00043 void kinematics::KinematicsBase::setValues(const std::string& robot_description,
00044                        const std::string& group_name,
00045                        const std::string& base_frame,
00046                        const std::string& tip_frame,
00047                        double search_discretization)
00048 {
00049   robot_description_ = robot_description;
00050   group_name_ = group_name;
00051   base_frame_ = removeSlash(base_frame);
00052   tip_frame_ = removeSlash(tip_frame);
00053   search_discretization_ = search_discretization;
00054 }
00055 
00056 bool kinematics::KinematicsBase::setRedundantJoints(const std::vector<unsigned int> &redundant_joint_indices)
00057 {
00058   for(std::size_t i = 0; i < redundant_joint_indices.size(); ++i)
00059   {
00060     if(redundant_joint_indices[i] >= getJointNames().size())
00061     {
00062       return false;
00063     }
00064   }
00065   redundant_joint_indices_ = redundant_joint_indices;
00066   return true;
00067 }
00068 
00069 bool kinematics::KinematicsBase::setRedundantJoints(const std::vector<std::string> &redundant_joint_names)
00070 {
00071   const std::vector<std::string> &jnames = getJointNames();
00072   std::vector<unsigned int> redundant_joint_indices;
00073   for (std::size_t i = 0 ; i < redundant_joint_names.size() ; ++i)
00074     for (std::size_t j = 0 ; j < jnames.size() ; ++j)
00075       if (jnames[j] == redundant_joint_names[i])
00076       {
00077     redundant_joint_indices.push_back(j);
00078     break;
00079       }
00080   return redundant_joint_indices.size() == redundant_joint_names.size() ? setRedundantJoints(redundant_joint_indices) : false;
00081 }
00082 
00083 std::string kinematics::KinematicsBase::removeSlash(const std::string &str) const
00084 {
00085   return (!str.empty() && str[0] == '/') ? removeSlash(str.substr(1)) : str;
00086 }


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Mon Oct 6 2014 02:24:47