ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

actionlib sendgoal arguments

asked 2016-08-06 23:30:40 -0500

nico_lauda gravatar image

updated 2016-08-07 12:43:37 -0500

Hi everybody!

I'm following the ROS-I tutorial ( http://aeswiki.datasys.swri.edu/rosit... ), and I get stuck when I have to send a goal to the server using the sendGoal method. Reading the sendGoal reference ( http://docs.ros.org/hydro/api/actionl... ) I should provide the goal and three callback functions.

Do I have to manually define those callback functions?

However in line 32, I tried to insert those callback funcs as indicated in the reference but Eclipse says "Method 'sendGoal' could not be resolved". What should I do?

Thank you!

  #include <collision_avoidance_pick_and_place/pick_and_place.h>

/*    SET GRIPPER
  Goal:
      - Turn the vacuum gripper on or off.
  Hints:
      - Use the grasp action client to send an grasp request to the grasp server.
      - Confirm that the gripper was successfully opened or closed and exit on error
*/
void collision_avoidance_pick_and_place::PickAndPlace::set_gripper(bool do_grasp)
{
//  ROS_ERROR_STREAM("set_gripper is not implemented yet.  Aborting."); exit(1);

  // task variables
  object_manipulation_msgs::GraspHandPostureExecutionGoal grasp_goal;
  bool success;

  // set the corresponding gripper action in the "grasp_goal" object.
  if (do_grasp)
    grasp_goal.goal = object_manipulation_msgs::GraspHandPostureExecutionGoal::GRASP;
  else
    grasp_goal.goal = object_manipulation_msgs::GraspHandPostureExecutionGoal::RELEASE;

  /* Fill Code:
   * Goal:
   * - Send the grasp goal to the server.
   * Hints:
   * - Use the "sendGoal" method of the grasp client "grasp_action_client_ptr"
   * to make a call to the server.
   */
  /* ========  ENTER CODE HERE ======== */
  grasp_action_client_ptr.sendGoal(grasp_goal.goal, SimpleDoneCallback, SimpleActiveCallback, SimpleFeedbackCallback) ;


  /* Fill Code:
   * Goal:
   * - Confirm that client service call succeeded.
   * Hints:
   * - Use the "waitForResult" method of the client to wait for completion.
   * - Give "waitForResult" a timeout value of 4 seconds
   * - Timeouts in ros can be created using "ros::Duration(4.0f)".
   * - Save returned boolean from waitForResult() in the "success" variable.
   */
  /* ========  ENTER CODE HERE ======== */

  if(success)
  {
    if (do_grasp)
      ROS_INFO_STREAM("Gripper closed");
    else
      ROS_INFO_STREAM("Gripper opened");
  }
  else
  {
    ROS_ERROR_STREAM("Gripper failure");
    exit(1);
  }
}
edit retag flag offensive close merge delete

Comments

1

You have a thing named grasp_action_client_ptr, which is probably a pointer, but you're trying to use the dot operator on it. Perhaps you want the deference -> instead?

ahendrix gravatar image ahendrix  ( 2016-08-07 15:01:56 -0500 )edit

Thank you for your comment!. I changed the operator like you said, and now sendGoal is recognized, but I get "Invalid arguments" error. It seems that it doesn't recognize the callback functions. I don't care of the callback fcns, but if I don't put them in the sendGoal I get the error as well.

nico_lauda gravatar image nico_lauda  ( 2016-08-07 15:29:22 -0500 )edit

The API docs you link to show defaults for the callbacks, so I don't think you need to provide those arguments. It looks like you're following a tutorial that is mostly pre-filled code, so I'd recommend that you read the examples again.

ahendrix gravatar image ahendrix  ( 2016-08-07 17:03:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-08-08 18:28:03 -0500

nico_lauda gravatar image

I write this answer in order to help someone else in the future that will find similar difficulties.

I have found here the same code already solved. On line 38 just write grasp_action_client_ptr.sendGoal(grasp_goal); and It works.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-06 23:30:40 -0500

Seen: 701 times

Last updated: Aug 08 '16