Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GouthamG14 opened this issue Mar 12, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@GouthamG14
Copy link

#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)
}

@GouthamG14 GouthamG14 added the bug Something isn't working label Mar 12, 2024
@scpeters
Copy link
Member

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants