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

DetachableJoint plugin: Reattached model when world is resetted #2131

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/systems/detachable_joint/DetachableJoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ void DetachableJoint::Configure(const Entity &_entity,
this->validConfig = true;
}

void DetachableJoint::Reset(const gz::sim::UpdateInfo &/*_info*/,
gz::sim::EntityComponentManager &/*_ecm*/)
{
// When the physics engine is resetted the detachable joint is removed
// We need to reattach it
this->attachRequested = true;
this->isAttached = false;
}

//////////////////////////////////////////////////
void DetachableJoint::PreUpdate(
const UpdateInfo &/*_info*/,
Expand Down Expand Up @@ -314,9 +323,10 @@ void DetachableJoint::OnDetachRequest(const msgs::Empty &)
}

GZ_ADD_PLUGIN(DetachableJoint,
System,
DetachableJoint::ISystemConfigure,
DetachableJoint::ISystemPreUpdate)
System,
DetachableJoint::ISystemConfigure,
DetachableJoint::ISystemPreUpdate,
DetachableJoint::ISystemReset)

GZ_ADD_PLUGIN_ALIAS(DetachableJoint,
"gz::sim::systems::DetachableJoint")
7 changes: 6 additions & 1 deletion src/systems/detachable_joint/DetachableJoint.hh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ namespace systems
class DetachableJoint
: public System,
public ISystemConfigure,
public ISystemPreUpdate
public ISystemPreUpdate,
public ISystemReset
{
/// Documentation inherited
public: DetachableJoint() = default;
Expand All @@ -89,6 +90,10 @@ namespace systems
const gz::sim::UpdateInfo &_info,
gz::sim::EntityComponentManager &_ecm) final;

/// Documentation inherited
public: void Reset(const gz::sim::UpdateInfo &_info,
gz::sim::EntityComponentManager &_ecm) final;

/// \brief Gazebo communication node.
private: transport::Node node;

Expand Down