Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <kinematics_cache_ros/kinematics_cache_ros.h>
00039
00040
00041 #include <boost/shared_ptr.hpp>
00042
00043
00044 #include <planning_models/kinematic_state.h>
00045 #include <rdf_loader/rdf_loader.h>
00046 #include <urdf_interface/model.h>
00047 #include <urdf/model.h>
00048 #include <srdf/model.h>
00049
00050 namespace kinematics_cache_ros
00051 {
00052 bool KinematicsCacheROS::init(const kinematics_cache::KinematicsCache::Options& opt,
00053 const std::string& kinematics_solver_name, const std::string& group_name,
00054 const std::string& base_frame, const std::string& tip_frame, double search_discretization)
00055 {
00056 kinematics_loader_.reset(new pluginlib::ClassLoader<kinematics::KinematicsBase>("kinematics_base", "kinematics::"
00057 "KinematicsBase"));
00058
00059 try
00060 {
00061 kinematics_solver_ = kinematics_loader_->createClassInstance(kinematics_solver_name);
00062 }
00063 catch (pluginlib::PluginlibException& ex)
00064 {
00065 ROS_ERROR("The plugin failed to load. Error: %s", ex.what());
00066 return false;
00067 }
00068
00069 if (!kinematics_solver_->initialize(group_name, base_frame, tip_frame, search_discretization))
00070 {
00071 ROS_ERROR("Could not initialize solver");
00072 return false;
00073 }
00074
00075 rdf_loader::RDFLoader rdf_loader;
00076 const boost::shared_ptr<srdf::Model>& srdf = rdf_loader.getSRDF();
00077 const boost::shared_ptr<urdf::ModelInterface>& urdf_model = rdf_loader.getURDF();
00078 kinematic_model_.reset(new planning_models::RobotModel(urdf_model, srdf));
00079
00080 if (!initialize((kinematics::KinematicsBaseConstPtr&)kinematics_solver_,
00081 (planning_models::RobotModelConstPtr&)kinematic_model_, opt))
00082 {
00083 return false;
00084 }
00085
00086 return true;
00087 }
00088 }