00001 #include "constrained_ik/constrained_ik.h" 00002 #include "constrained_ik/enum_types.h" 00003 #include "constrained_ik/constraints/avoid_singularities.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_singularities_example"); 00016 Constrained_IK ik; 00017 BasicKin kin; 00018 robot_model_loader::RobotModelLoaderPtr loader; 00019 00020 // Load example robot model 00021 getExampleRobotData(loader); 00022 00023 // Initialize kinematic model 00024 kin.init(loader->getModel()->getJointModelGroup("manipulator")); 00025 00026 // Create constraint 00027 constraints::AvoidSingularities *constraint = new constraints::AvoidSingularities; 00028 constraint->setDebug(false); 00029 constraint->setWeight(1.0); 00030 constraint->setEnableThreshold(0.01); 00031 constraint->setIgnoreThreshold(1e-5); 00032 00033 // Add constraint to solver 00034 ik.addConstraint(constraint, constraint_types::Primary); 00035 00036 // Initialize Solver 00037 ik.init(kin); 00038 00039 // Calculate IK for sample case 00040 evaluteExampleIK(kin, ik); 00041 00042 return 0; 00043 }