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

Backport #3039 - Apply Force/Torque for nested models #3053

Merged
merged 1 commit into from
Aug 6, 2021
Merged
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
31 changes: 28 additions & 3 deletions gazebo/gui/ApplyWrenchDialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,29 @@ bool ApplyWrenchDialog::SetModel(const std::string &_modelName)
for (unsigned int i = 0; i < vis->GetChildCount(); ++i)
{
rendering::VisualPtr childVis = vis->GetChild(i);

// Skip all children that aren't links
if (childVis->GetType() != rendering::Visual::VT_LINK)
{
continue;
}

std::string linkName = childVis->Name();

// Issue #1553: This is failing to get real links sometimes:
// uint32_t flags = childVis->GetVisibilityFlags();
// if (!((flags != GZ_VISIBILITY_ALL) && (flags & GZ_VISIBILITY_GUI)))
if (linkName.find("_GL_MANIP_") == std::string::npos)
{
std::string unscopedLinkName = linkName.substr(linkName.find("::") + 2);
size_t modelNamePos = linkName.find(_modelName);
// Skip if the model name isn't in the scoped link name
if (modelNamePos == std::string::npos)
{
continue;
}
std::string unscopedLinkName = linkName.substr(modelNamePos +
+ _modelName.size() + 2);

this->dataPtr->linksComboBox->addItem(
QString::fromStdString(unscopedLinkName));

Expand Down Expand Up @@ -538,8 +553,18 @@ bool ApplyWrenchDialog::SetLink(const std::string &_linkName)
if (!gui::get_active_camera() || !gui::get_active_camera()->GetScene())
return false;

// Select on combo box
std::string unscopedLinkName = _linkName.substr(_linkName.find("::") + 2);
size_t modelNamePos = _linkName.find(this->dataPtr->modelName);
std::string unscopedLinkName;

// Leave unscopedLinkName empty if model name cannot be found
// in the scoped link name
if (modelNamePos != std::string::npos)
{
// Select on combo box
unscopedLinkName = _linkName.substr(modelNamePos +
this->dataPtr->modelName.size() + 2);
}

int index = -1;
for (int i = 0; i < this->dataPtr->linksComboBox->count(); ++i)
{
Expand Down
Loading