example.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002 *
00003 * Software License Agreement (BSD License)
00004 *
00005 *  Copyright (c) 2012, 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 <kinematics_cache_ros/kinematics_cache_ros.h>
00039 #include <ros/ros.h>
00040 
00041 int main(int argc, char** argv)
00042 {
00043   ros::init(argc, argv, "kinematics_cache");
00044   kinematics_cache::KinematicsCache::Options opt;
00045   opt.origin.x = 0.0;
00046   opt.origin.y = -1.0;
00047   opt.origin.z = -1.0;
00048 
00049   opt.workspace_size[0] = 2.0;
00050   opt.workspace_size[1] = 2.0;
00051   opt.workspace_size[2] = 2.0;
00052 
00053   opt.resolution[0] = 0.01;
00054   opt.resolution[1] = 0.01;
00055   opt.resolution[2] = 0.01;
00056   opt.max_solutions_per_grid_location = 2;
00057 
00058   kinematics_cache_ros::KinematicsCacheROS pr2_kinematics_cache;
00059   ros::NodeHandle private_handle("~");
00060 
00061   if (!pr2_kinematics_cache.init(opt, "pr2_arm_kinematics/PR2ArmKinematicsPlugin", "right_arm", "torso_lift_link",
00062                                  "r_wrist_roll_link", 0.01))
00063     return (0);
00064 
00065   pr2_kinematics_cache.generateCacheMap(10.0);
00066 
00067   geometry_msgs::Pose point;
00068   point.position.x = 0.0;
00069   point.position.y = -1.0;
00070   point.position.z = -1.0;
00071 
00072   unsigned int max_num = 200;
00073 
00074   for (unsigned int i = 0; i < max_num; ++i)
00075   {
00076     point.position.x = opt.origin.x + i / 100.0;
00077     for (unsigned int j = 0; j < max_num; ++j)
00078     {
00079       point.position.y = opt.origin.y + j / 100.0;
00080       for (unsigned int k = 0; k < max_num; ++k)
00081       {
00082         point.position.z = opt.origin.z + k / 100.0;
00083         unsigned int num_solutions(0);
00084         if (!pr2_kinematics_cache.getNumSolutions(point, num_solutions))
00085           ROS_ERROR("Outside grid");
00086         else if (num_solutions > 0)
00087           ROS_INFO("Num solutions: %d", num_solutions);
00088       }
00089     }
00090   }
00091   return (0);
00092 }


moveit_experimental
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley , Jorge Nicho
autogenerated on Wed Jun 19 2019 19:24:03