Skip to content

Commit aab29bc

Browse files
XINJIANGMOiche033
andauthored
Fix crash when calling setPose service on static and nolink entity (#2988)
Gazebo allows loading static models without any links. However, if a /world/<world>/set_pose service call is made targeting such a model, the physics system crashes , because the underlying physics code assumes every model has at least one link. After Fix : Before executing set_pose, the code now checks whether the target model contains at least one link. --------- Signed-off-by: momo <[email protected]> Co-authored-by: Ian Chen <[email protected]>
1 parent ec0cac5 commit aab29bc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/systems/physics/Physics.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,6 +2485,14 @@ void PhysicsPrivate::UpdatePhysics(EntityComponentManager &_ecm)
24852485
<< std::endl;
24862486
return true;
24872487
}
2488+
sim::Model model(_entity);
2489+
if (model.Links(_ecm).empty())
2490+
{
2491+
gzerr << "SetPose is not supported for models without any link."
2492+
<< "Entity [" << _entity << "]."
2493+
<< "Request ignored" << std::endl;
2494+
return true;
2495+
}
24882496
auto modelPtrPhys = this->entityModelMap.Get(_entity);
24892497
if (nullptr == modelPtrPhys)
24902498
return true;

0 commit comments

Comments
 (0)