Ask Your Question
2

get_fk works but get_ik doesn't from same service node

asked 2013-02-12 10:17:48 -0500

MartinW gravatar image

updated 2013-02-12 10:20:52 -0500

Hello all,

I am trying to access my rosservice node made by the warehouse arm navigation wizard. The service is running but when I try to execute a simple ik calculation (through the get_ik tutorial) my code crashes here:

  if(ik_client.call(gpik_req, gpik_res))

with a console error:

martin@ubuntu:~# rosrun H20_robot_arm_navigation get_left_ik 
[ INFO] [1360706997.070270979]:  1 
[ INFO] [1360706997.070335100]:  2 
[ INFO] [1360706997.070358093]:  3 
[ INFO] [1360706997.070378924]:  4 
[ERROR] [1360706997.071244382]: Inverse kinematics service call failed

I put some ROS_INFO lines for the purposes of debugging: Here is the full code that I used from the tutorials:

#include <ros/ros.h>
#include <kinematics_msgs/GetKinematicSolverInfo.h>
#include <kinematics_msgs/GetPositionIK.h>

int main(int argc, char **argv){
  ros::init (argc, argv, "get_ik");
  ros::NodeHandle rh;



  ros::service::waitForService("H20_robot_left_arm_kinematics/get_ik_solver_info");
  ros::service::waitForService("H20_robot_left_arm_kinematics/get_ik");

  ros::ServiceClient query_client = rh.serviceClient<kinematics_msgs::GetKinematicSolverInfo>("H20_robot_left_arm_kinematics/get_ik_solver_info");
  ros::ServiceClient ik_client = rh.serviceClient<kinematics_msgs::GetPositionIK>("H20_robot_left_arm_kinematics/get_ik");

  // define the service message
  kinematics_msgs::GetKinematicSolverInfo::Request request;
  kinematics_msgs::GetKinematicSolverInfo::Response response;

  if(query_client.call(request,response))
  {
    for(unsigned int i=0; i< response.kinematic_solver_info.joint_names.size(); i++)
    {
      ROS_DEBUG("Joint: %d %s",i,response.kinematic_solver_info.joint_names[i].c_str());
    }
  }
  else
  {
    ROS_ERROR("Could not call query service");
    ros::shutdown();
    exit(1);
  }
  // define the service messages
  kinematics_msgs::GetPositionIK::Request  gpik_req;
  kinematics_msgs::GetPositionIK::Response gpik_res;
  gpik_req.timeout = ros::Duration(5.0);
  gpik_req.ik_request.ik_link_name = "left_hand_link";
ROS_INFO(" 1 ");
  gpik_req.ik_request.pose_stamped.header.frame_id = "base_link";
  gpik_req.ik_request.pose_stamped.pose.position.x = 0.235;
  gpik_req.ik_request.pose_stamped.pose.position.y = -0.04445;
  gpik_req.ik_request.pose_stamped.pose.position.z = -0.609;
ROS_INFO(" 2 ");
  gpik_req.ik_request.pose_stamped.pose.orientation.x = 0.99;
  gpik_req.ik_request.pose_stamped.pose.orientation.y = -0.0782;
  gpik_req.ik_request.pose_stamped.pose.orientation.z = 0.0;
  gpik_req.ik_request.pose_stamped.pose.orientation.w = 1.0;
  gpik_req.ik_request.ik_seed_state.joint_state.position.resize(response.kinematic_solver_info.joint_names.size());
  gpik_req.ik_request.ik_seed_state.joint_state.name = response.kinematic_solver_info.joint_names;
ROS_INFO(" 3 ");
 for(unsigned int i=0; i< response.kinematic_solver_info.joint_names.size(); i++)
  {
    gpik_req.ik_request.ik_seed_state.joint_state.position[i] = (response.kinematic_solver_info.limits[i].min_position + response.kinematic_solver_info.limits[i].max_position)/2.0;

  }
ROS_INFO(" 4 ");
  if(ik_client.call(gpik_req, gpik_res))
  {


ROS_INFO(" 5 ");
    if(gpik_res.error_code.val == gpik_res.error_code.SUCCESS)
      for(unsigned int i=0; i < gpik_res.solution.joint_state.name.size(); i ++)
        ROS_INFO("Joint: %s %f",gpik_res.solution.joint_state.name[i].c_str(),gpik_res.solution.joint_state.position[i]);
    else
      ROS_ERROR("Inverse kinematics failed");
  }
  else
    ROS_ERROR("Inverse kinematics service call failed");
  ros::shutdown();
}

Does anyone know what is going wrong? I used the get_fk tutorial.

Kind Regards, Martin

edit retag flag offensive close merge delete

Comments

I'm dealing with the same issue now Martin and I have no idea about what to do. Did you find a workaround? Regards, Carlos

Carlos gravatar image Carlos  ( 2013-04-22 17:49:00 -0500 )edit

It does work that way! Thank you! But it also means that the warehouse viewer is doing something that we're not and I can't figure out what is it! Could it be it's not properly instantiating ArmKinematicsConstraintAware with the custom robot parameters? or something about TF? I'll keep looking!

Carlos gravatar image Carlos  ( 2013-04-24 06:11:24 -0500 )edit

I believe it is instantiating a planning scene, but I haven't looked into it further yet. I believe you have to set a blank (or saved) planning scene and it's a fairly simple call! If you find out how please let me know, I'm taking a break from coding to write my thesis these days. Best of luck!

MartinW gravatar image MartinW  ( 2013-04-25 07:44:07 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-04-23 18:51:40 -0500

MartinW gravatar image

Yes Carlos, to get the ik services to work it required that I run the warehouse planner and setup a new motion plan request (or at least click on an old one). Once I did this all the services worked but not until I clicked on the MPRs. Hope this helps, cheers!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-02-12 10:17:48 -0500

Seen: 264 times

Last updated: Feb 12 '13