38 #include <geometry_msgs/PoseStamped.h> 58 PR2ArmKinematics::PR2ArmKinematics(
bool create_tf_listener): node_handle_(
"~"),dimension_(7)
65 ROS_ERROR(
"Could not load robot model. Are you sure the robot model is on the parameter server?");
70 ROS_FATAL(
"PR2IK: No root name found on parameter server");
74 ROS_FATAL(
"PR2IK: No tip name found on parameter server");
84 if(create_tf_listener) {
146 kinematics_msgs::GetPositionIK::Response &response)
157 geometry_msgs::PoseStamped pose_msg_in = request.ik_request.pose_stamped;
158 geometry_msgs::PoseStamped pose_msg_out;
163 response.error_code.val = response.error_code.FRAME_TRANSFORM_FAILURE;
168 response.error_code.val = response.error_code.FRAME_TRANSFORM_FAILURE;
171 request.ik_request.pose_stamped = pose_msg_out;
177 kinematics_msgs::GetPositionIK::Response &response)
191 jnt_pos_in(tmp_index) = request.ik_request.ik_seed_state.joint_state.position[i];
195 ROS_ERROR(
"i: %d, No joint index for %s",i,request.ik_request.ik_seed_state.joint_state.name[i].c_str());
202 request.timeout.toSec());
204 response.error_code.val = response.error_code.TIMED_OUT;
206 response.error_code.val = response.error_code.NO_IK_SOLUTION;
208 response.solution.joint_state.header = request.ik_request.pose_stamped.header;
213 response.solution.joint_state.position.resize(dimension_);
216 response.solution.joint_state.position[i] = jnt_pos_out(i);
217 ROS_DEBUG(
"IK Solution: %s %d: %f",response.solution.joint_state.name[i].c_str(),i,jnt_pos_out(i));
219 response.error_code.val = response.error_code.SUCCESS;
224 ROS_DEBUG(
"An IK solution could not be found");
230 kinematics_msgs::GetKinematicSolverInfo::Response &response)
242 kinematics_msgs::GetKinematicSolverInfo::Response &response)
254 kinematics_msgs::GetPositionFK::Response &response)
267 geometry_msgs::PoseStamped pose;
271 for(
int i=0; i < (int) request.robot_state.joint_state.position.size(); i++)
275 jnt_pos_in(tmp_index) = request.robot_state.joint_state.position[i];
278 response.pose_stamped.
resize(request.fk_link_names.size());
279 response.fk_link_names.resize(request.fk_link_names.size());
281 for(
unsigned int i=0; i < request.fk_link_names.size(); i++)
291 if(!
transformPose(request.header.frame_id, pose, response.pose_stamped[i])) {
292 response.error_code.val = response.error_code.FRAME_TRANSFORM_FAILURE;
295 response.fk_link_names[i] = request.fk_link_names[i];
296 response.error_code.val = response.error_code.SUCCESS;
300 ROS_ERROR(
"Could not compute FK for %s",request.fk_link_names[i].c_str());
301 response.error_code.val = response.error_code.NO_FK_SOLUTION;
308 const geometry_msgs::PoseStamped& pose_in,
309 geometry_msgs::PoseStamped& pose_out)
316 ROS_ERROR(
"Could not transform FK pose to frame: %s",des_frame.c_str());
320 ROS_WARN_STREAM(
"No tf listener, can't transform to frame " << des_frame);
boost::shared_ptr< pr2_arm_kinematics::PR2ArmIKSolver > pr2_arm_ik_solver_
bool getPositionFK(kinematics_msgs::GetPositionFK::Request &request, kinematics_msgs::GetPositionFK::Response &response)
This is the basic forward kinematics service that will return information about the kinematics node...
ros::ServiceServer fk_solver_info_service_
tf::TransformListener * tf_
ros::ServiceServer fk_service_
static void poseStampedTFToMsg(const Stamped< Pose > &bt, geometry_msgs::PoseStamped &msg)
Namespace for the PR2ArmKinematics.
bool getKDLChain(const urdf::ModelInterface &model, const std::string &root_name, const std::string &tip_name, KDL::Chain &kdl_chain)
unsigned int getNrOfSegments() const
void PoseKDLToTF(const KDL::Frame &k, tf::Pose &t) __attribute__((deprecated))
bool getIKSolverInfo(kinematics_msgs::GetKinematicSolverInfo::Request &request, kinematics_msgs::GetKinematicSolverInfo::Response &response)
This is the basic kinematics info service that will return information about the kinematics node...
boost::shared_ptr< KDL::ChainFkSolverPos_recursive > jnt_to_pose_solver_
ros::NodeHandle node_handle_
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
virtual ~PR2ArmKinematics()
static const int NO_IK_SOLUTION
kinematics_msgs::KinematicSolverInfo fk_solver_info_
void getKDLChainInfo(const KDL::Chain &chain, moveit_msgs::KinematicSolverInfo &chain_info)
ros::ServiceServer ik_solver_info_service_
bool getFKSolverInfo(kinematics_msgs::GetKinematicSolverInfo::Request &request, kinematics_msgs::GetKinematicSolverInfo::Response &response)
This is the basic kinematics info service that will return information about the kinematics node...
bool convertPoseToRootFrame(const geometry_msgs::PoseStamped &pose_msg, KDL::Frame &pose_kdl, const std::string &root_frame, tf::TransformListener &tf)
bool checkIKService(moveit_msgs::GetPositionIK::Request &request, moveit_msgs::GetPositionIK::Response &response, const moveit_msgs::KinematicSolverInfo &chain_info)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
int getJointIndex(const std::string &name, const moveit_msgs::KinematicSolverInfo &chain_info)
ros::ServiceServer ik_service_
def xml_string(rootXml, addHeader=True)
bool getPositionIKHelper(kinematics_msgs::GetPositionIK::Request &request, kinematics_msgs::GetPositionIK::Response &response)
#define ROS_WARN_STREAM(args)
double search_discretization_
static const std::string IK_SERVICE
static const std::string FK_INFO_SERVICE
void resize(unsigned int newSize)
static const std::string IK_INFO_SERVICE
kinematics_msgs::KinematicSolverInfo ik_solver_info_
virtual bool transformPose(const std::string &des_frame, const geometry_msgs::PoseStamped &pose_in, geometry_msgs::PoseStamped &pose_out)
bool getParam(const std::string &key, std::string &s) const
void PoseMsgToKDL(const geometry_msgs::Pose &m, KDL::Frame &k) __attribute__((deprecated))
static const int TIMED_OUT
bool checkFKService(moveit_msgs::GetPositionFK::Request &request, moveit_msgs::GetPositionFK::Response &response, const moveit_msgs::KinematicSolverInfo &chain_info)
virtual bool getPositionIK(kinematics_msgs::GetPositionIK::Request &request, kinematics_msgs::GetPositionIK::Response &response)
This is the basic IK service method that will compute and return an IK solution.
bool isActive()
Specifies if the node is active or not.
static const std::string FK_SERVICE
bool loadRobotModel(ros::NodeHandle node_handle, urdf::Model &robot_model, std::string &xml_string)
int getKDLSegmentIndex(const KDL::Chain &chain, const std::string &name)