toolsForObject.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 SoftBank Robotics Europe
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015 */
00016 
00017 #include "romeo_moveit_actions/toolsForObject.hpp"
00018 
00019 namespace moveit_simple_actions
00020 {
00021 
00022 void setPose(geometry_msgs::Pose *pose,
00023              const double &x,
00024              const double &y,
00025              const double &z,
00026              const double &ox,
00027              const double &oy,
00028              const double &oz,
00029              const double &ow)
00030 {
00031   pose->position.x = x;
00032   pose->position.y = y;
00033   pose->position.z = z;
00034   pose->orientation.x = ox;
00035   pose->orientation.y = oy;
00036   pose->orientation.z = oz;
00037   pose->orientation.w = ow;
00038 }
00039 
00040 void setPose(geometry_msgs::Pose *pose,
00041              const double &x,
00042              const double &y,
00043              const double &z)
00044 {
00045   pose->position.x = x;
00046   pose->position.y = y;
00047   pose->position.z = z;
00048 }
00049 
00050 int findObj(std::vector<MetaBlock> *blocks,
00051             const std::string name)
00052 {
00053   int idx = -1;
00054   for (int i=0; i<blocks->size(); ++i)
00055     if (blocks->at(i).name_ == name){
00056       idx = i;
00057       return idx;
00058     }
00059   return idx;
00060 }
00061 
00062 std::vector<std::string> getObjectsList(const std::vector<MetaBlock> &blocks)
00063 {
00064   std::vector<std::string> res;
00065   res.resize(blocks.size());
00066   if (blocks.size() > 0)
00067   {
00068     std::vector<MetaBlock>::const_iterator it=blocks.begin();
00069     for (int i=0; it!=blocks.end(); ++it, ++i)
00070       res[i] = it->name_;
00071   }
00072   return res;
00073 }
00074 
00075 //clean the object list based on the timestamp
00076 std::vector<std::string> getObjectsOldList(std::vector<MetaBlock> *objects)
00077 {
00078   std::vector<std::string> objects_id;
00079   if (objects->size()>0)
00080   {
00081     ros::Time now = ros::Time::now() - ros::Duration(5);
00082     std::vector<MetaBlock>::iterator block=objects->begin();
00083     for (; block != objects->end(); ++block)
00084     {
00085       if (block->timestamp_ < now)
00086         objects_id.push_back(block->name_);
00087         //resetBlock(&(*block));
00088     }
00089   }
00090   return objects_id;
00091 }
00092 
00093 void swapPoses(geometry_msgs::Pose *pose1,
00094                geometry_msgs::Pose *pose2)
00095 {
00096   geometry_msgs::Pose temp = *pose1;
00097   pose1 = pose2;
00098   *pose2 = temp;
00099 }
00100 
00101 }


romeo_moveit_actions
Author(s):
autogenerated on Thu Jun 6 2019 21:57:24