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

Add check for valid world pose cmd values #2640

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
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 @@
<< 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;

Check warning on line 2413 in src/systems/physics/Physics.cc

View check run for this annotation

Codecov / codecov/patch

src/systems/physics/Physics.cc#L2411-L2413

Added lines #L2411 - L2413 were not covered by tests
}

// TODO(addisu) Store the free group instead of searching for it at
// every iteration
Expand All @@ -2423,7 +2431,7 @@
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 @@
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
Loading