38 #include <geometry_msgs/PoseStamped.h> 57 PR2ArmKinematics::PR2ArmKinematics(
bool create_tf_listener) : node_handle_(
"~"), dimension_(7)
64 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");
75 ROS_FATAL(
"PR2IK: No tip name found on parameter server");
85 if (create_tf_listener)
150 kinematics_msgs::GetPositionIK::Response& response)
161 geometry_msgs::PoseStamped pose_msg_in = request.ik_request.pose_stamped;
162 geometry_msgs::PoseStamped pose_msg_out;
168 response.error_code.val = response.error_code.FRAME_TRANSFORM_FAILURE;
175 response.error_code.val = response.error_code.FRAME_TRANSFORM_FAILURE;
178 request.ik_request.pose_stamped = pose_msg_out;
184 kinematics_msgs::GetPositionIK::Response& response)
198 jnt_pos_in(tmp_index) = request.ik_request.ik_seed_state.joint_state.position[i];
202 ROS_ERROR(
"i: %d, No joint index for %s", i, request.ik_request.ik_seed_state.joint_state.name[i].c_str());
206 int ik_valid =
pr2_arm_ik_solver_->CartToJntSearch(jnt_pos_in, pose_desired, jnt_pos_out, request.timeout.toSec());
208 response.error_code.val = response.error_code.TIMED_OUT;
210 response.error_code.val = response.error_code.NO_IK_SOLUTION;
212 response.solution.joint_state.header = request.ik_request.pose_stamped.header;
217 response.solution.joint_state.position.resize(dimension_);
220 response.solution.joint_state.position[i] = jnt_pos_out(i);
221 ROS_DEBUG(
"IK Solution: %s %d: %f", response.solution.joint_state.name[i].c_str(), i, jnt_pos_out(i));
223 response.error_code.val = response.error_code.SUCCESS;
228 ROS_DEBUG(
"An IK solution could not be found");
234 kinematics_msgs::GetKinematicSolverInfo::Response& response)
246 kinematics_msgs::GetKinematicSolverInfo::Response& response)
258 kinematics_msgs::GetPositionFK::Response& response)
271 geometry_msgs::PoseStamped pose;
275 for (
int i = 0; i < (int)request.robot_state.joint_state.position.size(); i++)
279 jnt_pos_in(tmp_index) = request.robot_state.joint_state.position[i];
282 response.pose_stamped.
resize(request.fk_link_names.size());
283 response.fk_link_names.resize(request.fk_link_names.size());
285 for (
unsigned int i = 0; i < request.fk_link_names.size(); i++)
296 if (!
transformPose(request.header.frame_id, pose, response.pose_stamped[i]))
298 response.error_code.val = response.error_code.FRAME_TRANSFORM_FAILURE;
301 response.fk_link_names[i] = request.fk_link_names[i];
302 response.error_code.val = response.error_code.SUCCESS;
306 ROS_ERROR(
"Could not compute FK for %s", request.fk_link_names[i].c_str());
307 response.error_code.val = response.error_code.NO_FK_SOLUTION;
314 geometry_msgs::PoseStamped& pose_out)
324 ROS_ERROR(
"Could not transform FK pose to frame: %s", des_frame.c_str());
330 ROS_WARN_STREAM(
"No tf listener, can't transform to frame " << des_frame);
ROS_DEPRECATED void PoseKDLToTF(const KDL::Frame &k, tf::Pose &t)
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.
unsigned int getNrOfSegments() const
bool getKDLChain(const urdf::ModelInterface &model, const std::string &root_name, const std::string &tip_name, KDL::Chain &kdl_chain)
ROS_DEPRECATED void PoseMsgToKDL(const geometry_msgs::Pose &m, KDL::Frame &k)
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 param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
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 getParam(const std::string &key, std::string &s) 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)
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)