gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.18k stars 479 forks source link

Gazebo Crashes when i try to detach a Screw Joint using plugin. Any one has a solution regarding this? #3377

Open GouthamG14 opened 7 months ago

GouthamG14 commented 7 months ago

include <gazebo/gazebo.hh>

include <gazebo/physics/physics.hh>

namespace gazebo { class DetachJoint : public ModelPlugin { public: void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) { // Make sure the model pointer is valid if (!_model) { gzerr << "Invalid model pointer.\n"; return; }

  // Make sure the joint name is provided in the plugin's SDF
  if (!_sdf->HasElement("joint_name"))
  {
    gzerr << "Missing <joint_name> element.\n";
    return;
  }

  // Get the joint name from the SDF
  std::string jointName = _sdf->Get<std::string>("joint_name");

  // Get the joint by name
  this->joint = _model->GetJoint(jointName);
  if (!this->joint)
  {
    gzerr << "Joint with name '" << jointName << "' not found.\n";
    return;
  }

  // Detach the joint
  this->joint->Detach();    //  To detach a screw joint
}

private:
  physics::JointPtr joint;

};

GZ_REGISTER_MODEL_PLUGIN(DetachJoint) }

scpeters commented 6 months ago

hm...I haven't tried detaching a screw joint before. Perhaps you could also test with the HarnessPlugin?

You can try replacing prismatic on the following line with screw and see what happens:

scpeters commented 6 months ago

but in order to debug a segmentation fault; we would need a backtrace from gdb to see which code was being executed when it failed