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

Fix crash in the follow_actor example #958

Merged
merged 9 commits into from
Aug 12, 2021
23 changes: 15 additions & 8 deletions src/rendering/RenderUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ class ignition::gazebo::RenderUtilPrivate
/// data.
/// \sa actorManualSkeletonUpdate
public: void UpdateAnimation(const std::unordered_map<Entity,
AnimationUpdateData> &_actorAnimationData);
AnimationUpdateData> &_actorAnimationData,
const std::unordered_map<Entity, math::Pose3d> &_entityPoses,
const std::unordered_map<Entity, math::Pose3d> &_trajectoryPoses);
adlarkin marked this conversation as resolved.
Show resolved Hide resolved
};

//////////////////////////////////////////////////
Expand Down Expand Up @@ -804,7 +806,8 @@ void RenderUtil::Update()
}
else
{
this->dataPtr->UpdateAnimation(actorAnimationData);
this->dataPtr->UpdateAnimation(actorAnimationData, entityPoses,
trajectoryPoses);
}
}

Expand Down Expand Up @@ -2028,8 +2031,10 @@ void RenderUtilPrivate::UpdateThermalCamera(const std::unordered_map<Entity,
}

/////////////////////////////////////////////////
void RenderUtilPrivate::UpdateAnimation(
const std::unordered_map<Entity, AnimationUpdateData> &_actorAnimationData)
void RenderUtilPrivate::UpdateAnimation(const std::unordered_map<Entity,
AnimationUpdateData> &_actorAnimationData,
const std::unordered_map<Entity, math::Pose3d> &_entityPoses,
const std::unordered_map<Entity, math::Pose3d> &_trajectoryPoses)
{
for (auto &it : _actorAnimationData)
{
Expand Down Expand Up @@ -2098,16 +2103,18 @@ void RenderUtilPrivate::UpdateAnimation(

// update actor trajectory animation
math::Pose3d globalPose;
if (entityPoses.find(it.first) != entityPoses.end())
auto entityPosesIt = _entityPoses.find(it.first);
if (entityPosesIt != _entityPoses.end())
{
globalPose = entityPoses[it.first];
globalPose = entityPosesIt->second;
}

math::Pose3d trajPose;
// Trajectory from the ECS
if (trajectoryPoses.find(it.first) != trajectoryPoses.end())
auto trajectoryPosesIt = _trajectoryPoses.find(it.first);
if (trajectoryPosesIt != _trajectoryPoses.end())
{
trajPose = trajectoryPoses[it.first];
trajPose = trajectoryPosesIt->second;
}
else
{
Expand Down