00001 #include "constrained_ik/constrained_ik.h"
00002 #include "constrained_ik/enum_types.h"
00003 #include "constrained_ik/constraints/avoid_obstacles.h"
00004 #include "example_utils.h"
00005 #include <moveit/robot_model_loader/robot_model_loader.h>
00006 #include <moveit/planning_scene/planning_scene.h>
00007
00008 using namespace constrained_ik;
00009 using namespace constrained_ik::basic_kin;
00010 using namespace Eigen;
00011
00013 int main(int argc, char *argv[])
00014 {
00015 ros::init(argc, argv, "avoid_obstacles_example");
00016 Constrained_IK ik;
00017 BasicKin kin;
00018 robot_model_loader::RobotModelLoaderPtr loader;
00019 planning_scene::PlanningScenePtr planning_scene;
00020
00021
00022 planning_scene = getExampleRobotData(loader);
00023
00024
00025 kin.init(loader->getModel()->getJointModelGroup("manipulator"));
00026
00027
00028 std::vector<std::string> link_names = boost::assign::list_of("upper_arm_link")("wrist_3_link");
00029 constraints::AvoidObstacles *constraint = new constraints::AvoidObstacles;
00030 constraint->setAvoidanceLinks(link_names);
00031 constraint->setAmplitude(link_names[0], 0.01);
00032 constraint->setAmplitude(link_names[1], 0.01);
00033 constraint->setMinDistance(link_names[0], 0.01);
00034 constraint->setMinDistance(link_names[1], 0.01);
00035 constraint->setAvoidanceDistance(link_names[0], 1.0);
00036 constraint->setAvoidanceDistance(link_names[1], 1.0);
00037 constraint->setWeight(link_names[0], 1.0);
00038 constraint->setWeight(link_names[1], 1.0);
00039 constraint->setDebug(false);
00040
00041
00042 ik.addConstraint(constraint, constraint_types::Primary);
00043
00044
00045 ik.init(kin);
00046
00047
00048 evaluteExampleIK(kin, ik, planning_scene);
00049
00050 return 0;
00051 }