Gripper closing but not opening (Pr2/gazebo)

asked 2015-01-27 18:18:39 -0600

Fred Ferreira gravatar image

updated 2015-01-28 17:18:14 -0600

Hey Guys, I am following this tutorial: http://wiki.ros.org/pr2_controllers/T... I have everything set up and running. I am using Gazebo on Ubuntu 12.04 and Ros Hydro. My code looks exactly the same as the tutorial. The problem is the gripper always fails to open but looks like it closes (even though it was already closed and didn't open to close again)...

[ INFO] [1422403954.415261925, 433.873000000]: Sending open goal
[ INFO] [1422403955.782608686, 434.379000000]: The gripper failed to open.
[ INFO] [1422403955.782764580, 434.379000000]: Sending squeeze goal
[ INFO] [1422403955.807454463, 434.389000000]: The gripper closed!

Do anyone know what could be causing this?

I believe this tutorials is pretty old, isn't it? I can open the gripper publishing the following on a terminal:

rostopic pub r_gripper_controller/command pr2_controllers_msgs/Pr2GripperCommand "{position: 0.06, max_effort: 100.0}"

but not with the code provided in the tutorial...

UPDATE: (SOLVED)

Wrote my own code.

#include <ros/ros.h>
#include <pr2_controllers_msgs/Pr2GripperCommand.h>
#include <actionlib/client/simple_action_client.h>

class Gripper{
private:
  ros::NodeHandle nh_;
  ros::Publisher r_gripper_;

public:
  //Action client initialization
  Gripper(ros::NodeHandle &nh){
    nh_ = nh;
    r_gripper_ = nh_.advertise<pr2_controllers_msgs::Pr2GripperCommand>("/r_gripper_controller/command", 1);
  }

  ~Gripper(){
  }

  //Open the gripper
  void open(){
    pr2_controllers_msgs::Pr2GripperCommand gripper_cmd;
    gripper_cmd.position = 0.06;
    gripper_cmd.max_effort = 100.0;

    while (nh_.ok())
    {
      r_gripper_.publish(gripper_cmd);
    }
  }

  //Close the gripper
  void close(){
    pr2_controllers_msgs::Pr2GripperCommand gripper_cmd;
    gripper_cmd.position = 0.0;
    gripper_cmd.max_effort = 100.0;

    while (nh_.ok())
    {
      r_gripper_.publish(gripper_cmd);
    }
  }
};

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

  Gripper gripper(nh);

  gripper.open();
  gripper.close();

  return 0;
}
edit retag flag offensive close merge delete

Comments

Nice! I was going to do the same! and seems like i have no other choice left. However, i'd like to suggest that you publish appropriate messages to the "/r_gripper_controller/gripper_action/goal" topic so you can get feedback from "/r_gripper_controller/gripper_action/[result | feedback]" topics

mexomagno gravatar image mexomagno  ( 2015-10-20 19:07:37 -0600 )edit

@Fred Ferreira@mexomagno Does this answer solve the issue?

LSD gravatar image LSD  ( 2022-12-01 11:39:19 -0600 )edit