Skip to content

Commit

Permalink
Add check for valid world pose cmd values (#2640)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <ichen@openrobotics.org>
  • Loading branch information
iche033 authored Oct 4, 2024
1 parent a167312 commit 63b210a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/systems/physics/Physics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2404,6 +2404,14 @@ void PhysicsPrivate::UpdatePhysics(EntityComponentManager &_ecm)
<< std::endl;
return true;
}
math::Pose3d worldPoseCmd = _poseCmd->Data();
if (!worldPoseCmd.Pos().IsFinite() || !worldPoseCmd.Rot().IsFinite() ||
worldPoseCmd.Rot() == math::Quaterniond::Zero)
{
gzerr << "Unable to set world pose. Invalid pose value: "
<< worldPoseCmd << std::endl;
return true;
}

// TODO(addisu) Store the free group instead of searching for it at
// every iteration
Expand All @@ -2423,7 +2431,7 @@ void PhysicsPrivate::UpdatePhysics(EntityComponentManager &_ecm)
math::Pose3d linkPose =
this->RelativePose(_entity, linkEntity, _ecm);

freeGroup->SetWorldPose(math::eigen3::convert(_poseCmd->Data() *
freeGroup->SetWorldPose(math::eigen3::convert(worldPoseCmd *
linkPose));

// Process pose commands for static models here, as one-time changes
Expand All @@ -2432,7 +2440,7 @@ void PhysicsPrivate::UpdatePhysics(EntityComponentManager &_ecm)
auto worldPoseComp = _ecm.Component<components::Pose>(_entity);
if (worldPoseComp)
{
auto state = worldPoseComp->SetData(_poseCmd->Data(),
auto state = worldPoseComp->SetData(worldPoseCmd,
this->pose3Eql) ?
ComponentState::OneTimeChange :
ComponentState::NoChange;
Expand Down

0 comments on commit 63b210a

Please sign in to comment.