Skip to content

Commit

Permalink
Reviewer feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey committed Aug 5, 2020
1 parent d8dde16 commit af0cf95
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
22 changes: 14 additions & 8 deletions src/Model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,15 @@ Errors Model::Load(ElementPtr _sdf)
if (resolveErrors.empty())
{
// Before this update, i.e, as specified in the SDFormat, the model pose
// (X_MpPf) is the pose of the placement frame (Pf) relative to a frame in
// the parent scope of the model (Mp). However, when this model (M) is
// inserted into a pose graph of the parent scope, only the pose (X_MpM)
// (X_RPf) is the pose of the placement frame (Pf) relative to a frame (R)
// in the parent scope of the model. However, when this model (M) is
// inserted into a pose graph of the parent scope, only the pose (X_RM)
// of the __model__ frame can be used. Thus, the model pose has to be
// updated to X_MpM. And this is done by:
// X_MpM = X_MpPf * inv(X_MPf)
// updated to X_RM. And this is done by:
// X_RM = X_RPf * inv(X_MPf)
//
// Note that X_RPf is the raw pose specified in //model/pose before this
// update.
this->dataPtr->pose =
this->dataPtr->pose * placementFrameRelPose.Inverse();
}
Expand Down Expand Up @@ -417,8 +420,11 @@ Errors Model::Load(ElementPtr _sdf)
this->FrameByName(childModelName + "::__model__");
if (nullptr != childModelFrame)
{
// We assume that all model frames are specified relative to their
// parent frame, so using the RawPose should be okay.
// The RawPose of the child model frame is the desired pose of the
// placement frame relative to a frame (R) in the scope of the parent
// model. We don't need to resolve the pose because the relative_to
// frame remains unchanged after the pose update here. i.e, the updated
// pose of the child model frame will still be relative to R.
const auto &placementFramePose = childModelFrame->RawPose();

ignition::math::Pose3d placementFrameRelPose;
Expand All @@ -430,7 +436,7 @@ Errors Model::Load(ElementPtr _sdf)
// frame as well as the corresponding edge in the pose graph because
// just updating childModelFrame doesn't update the pose graph.
//
// X_MpM = X_MpPf * inv(X_MPf)
// X_RM = X_RPf * inv(X_MPf)
auto newModelPose =
placementFramePose * placementFrameRelPose.Inverse();
frame.SetRawPose(newModelPose);
Expand Down
4 changes: 2 additions & 2 deletions test/integration/nested_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ TEST_F(PlacementFrame, ModelInclude)
// Test that the pose of an included model with placement_frame can use the
// relative_to attribute
this->TestExpectedModelPose<sdf::Link>("parent_model_include",
"include_with_placement_frame_and_pose_relative_to::L4");
"nested_include_with_placement_frame_and_pose_relative_to::L4");
}

//////////////////////////////////////////////////
Expand All @@ -1007,7 +1007,7 @@ TEST_F(PlacementFrame, ModelPlacementFrameAttribute)
this->TestExpectedWorldPose<sdf::Joint>(
"model_with_joint_placement_frame", "J2");

// Test that the pose of an included model with placement_frame can use the
// Test that the pose of a model with a placement_frame attribute can use the
// relative_to attribute
this->TestExpectedWorldPose<sdf::Link>(
"model_with_placement_frame_and_pose_relative_to", "L4");
Expand Down
2 changes: 1 addition & 1 deletion test/sdf/placement_frame.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<pose>-1 10 0 1.570796326794895 0 0</pose>
</frame>
<include>
<name>include_with_placement_frame_and_pose_relative_to</name>
<name>nested_include_with_placement_frame_and_pose_relative_to</name>
<uri>test_model_with_frames</uri>
<pose relative_to='frame_1'>1 0 0 0 0 0</pose>
<placement_frame>L4</placement_frame>
Expand Down

0 comments on commit af0cf95

Please sign in to comment.