How to detach a joint or remove it dynamically

asked 2019-08-15 17:20:47 -0500

Fabs gravatar image

Hey

I'm trying to adapt Vacuum Gripper plugin for sdf. I got the Vacuum Gripper plugin from gazebo-ros-pkgs and I modified it in order to create a joint between the manipulator's link and the link from the object I wanna grasp. Furthermore, I apply force to the object so that it will not fall while moving the manipulator.

So, to create the joint I used Joint Gazebo class function Attach(), as shown below. link_ is the parent link and links is the child link.

 void GazeboRosVacuumGripper::AttachJoint(physics::LinkPtr link_,physics::LinkPtr links){
      cube_joint_ = this->world_->GetPhysicsEngine()->CreateJoint("revolute",parent_);
      cube_joint_->Load(link_,links,ignition::math::Pose3d(link_->GetWorldPose().Ign()));
      cube_joint_->Attach(link_,links);
      cube_joint_->SetAxis(0,math::Vector3(0,0,1));
      cube_joint_->SetEffortLimit(0,300);

      cube_joint_->SetVelocityLimit(0,4.15);
      cube_joint_->SetVelocity(0,0);
      cube_joint_->SetVelocityLimit(1,4.15);
      cube_joint_->SetVelocity(1,0);
      cube_joint_->SetVelocityLimit(2,4.15);
      cube_joint_->SetVelocity(2,0);

      cube_joint_->SetUpperLimit(0,3.14);
      cube_joint_->SetLowerLimit(0,-3.14);
      cube_joint_->SetUpperLimit(1,3.14);
      cube_joint_->SetLowerLimit(1,-3.14);
      cube_joint_->SetUpperLimit(2,3.14);
      cube_joint_->SetLowerLimit(2,-3.14); 
}

The problem is when I try to detach the joint.

void GazeboRosVacuumGripper::DetachJoint(){
  cube_joint_->Detach();
}

It returns this error and gazebo crashes right after.

gzserver: /usr/include/boost/smart_ptr/shared_ptr.hpp:648: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = gazebo::physics::Joint; typename boost::detail::sp_member_access<T>::type = gazebo::physics::Joint*]: Assertion `px != 0' failed.
Aborted (core dumped)
[gazebo-2] process has died [pid 7604, exit code 134, cmd /home/tamires/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/gzserver -e ode worlds/empty.world __name:=gazebo __log:=/home/tamires/.ros/log/24fe5070-bfa8-11e9-84c5-080027e717b6/gazebo-2.log].
log file: /home/tamires/.ros/log/24fe5070-bfa8-11e9-84c5-080027e717b6/gazebo-2*.log

I'm running Gazebo 7.15 on Ubuntu 16.04 and ROS Kinetic.

I also tried to remove the joint but it didn't work. Does anyone know how to solve it?

Thanks!

edit retag flag offensive close merge delete