Skip to content

Commit

Permalink
Merged from sdf7
Browse files Browse the repository at this point in the history
  • Loading branch information
nkoenig committed Nov 4, 2019
2 parents 4d6c2c2 + 5a642bc commit f8617a2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
1. Build Utils_TEST with Utils.cc explicitly passed since its symbols are not visible.
* [Pull request 572](https://bitbucket.org/osrf/sdformat/pull-requests/572)

1. Parse urdf files to sdf 1.5 instead of 1.4 to avoid `use_parent_model_frame`.
* [Pull request 575](https://bitbucket.org/osrf/sdformat/pull-requests/575)

1. Set camera intrinsics axis skew (s) default value to 0
* [Pull request 504](https://bitbucket.org/osrf/sdformat/pull-requests/504)

Expand Down Expand Up @@ -72,6 +75,9 @@

### SDFormat 6.X.X (20XX-XX-XX)

1. Parse urdf files to sdf 1.5 instead of 1.4 to avoid `use_parent_model_frame`.
* [Pull request 575](https://bitbucket.org/osrf/sdformat/pull-requests/575)

1. Set camera intrinsics axis skew (s) default value to 0
* [Pull request 504](https://bitbucket.org/osrf/sdformat/pull-requests/504)

Expand Down
19 changes: 8 additions & 11 deletions src/parser_urdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,7 @@ void CreateInertial(TiXmlElement *_elem,
////////////////////////////////////////////////////////////////////////////////
void CreateJoint(TiXmlElement *_root,
urdf::LinkConstSharedPtr _link,
ignition::math::Pose3d &_currentTransform)
ignition::math::Pose3d &/*_currentTransform*/)
{
// compute the joint tag
std::string jtype;
Expand Down Expand Up @@ -2975,15 +2975,12 @@ void CreateJoint(TiXmlElement *_root,
}
else if (jtype != "fixed")
{
ignition::math::Vector3d rotatedJointAxis =
_currentTransform.Rot().RotateVector(
ignition::math::Vector3d(_link->parent_joint->axis.x,
_link->parent_joint->axis.y,
_link->parent_joint->axis.z));
double rotatedJointAxisArray[3] =
{ rotatedJointAxis.X(), rotatedJointAxis.Y(), rotatedJointAxis.Z() };
double jointAxisXyzArray[3] =
{ _link->parent_joint->axis.x,
_link->parent_joint->axis.y,
_link->parent_joint->axis.z};
AddKeyValue(jointAxis, "xyz",
Values2str(3, rotatedJointAxisArray));
Values2str(3, jointAxisXyzArray));
if (_link->parent_joint->dynamics)
{
AddKeyValue(jointAxisDynamics, "damping",
Expand Down Expand Up @@ -3237,9 +3234,9 @@ TiXmlDocument URDF2SDF::InitModelString(const std::string &_urdfStr,

try
{
// URDF is compatible with version 1.4. The automatic conversion script
// URDF is compatible with version 1.5. The automatic conversion script
// will up-convert URDF to SDF.
sdf->SetAttribute("version", "1.4");
sdf->SetAttribute("version", "1.5");
// add robot to sdf
sdf->LinkEndChild(robot);
}
Expand Down
7 changes: 2 additions & 5 deletions src/parser_urdf_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,8 @@ TEST(URDFParser, ParseResults_BasicModel_ParseEqualToModel)

// SDF -> SDF
std::ostringstream stream;
// Use hard-coded "1.4" for version string
// until parser_urdf.cc exports version "1.5"
// see `sdf->SetAttribute("version", "1.4");`
// in URDF2SDF::InitModelString()
stream << "<sdf version='" << "1.4" << "'>"
// parser_urdf.cc exports version "1.5"
stream << "<sdf version='" << "1.5" << "'>"
<< " <model name='test_robot' />"
<< "</sdf>";
TiXmlDocument sdf_doc;
Expand Down
18 changes: 18 additions & 0 deletions test/integration/urdf_joint_parameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,22 @@ TEST(SDFParser, JointAxisParameters)
EXPECT_DOUBLE_EQ(value, dynamics->Get<double>("friction"));
}
EXPECT_EQ(bitmask, 0x3u);

// check joint axis values
for (sdf::ElementPtr joint = model->GetElement("joint"); joint;
joint = joint->GetNextElement("joint"))
{
std::string jointName = joint->Get<std::string>("name");

ignition::math::Vector3d xyz(1, 0, 0);
if (jointName == "joint12" || jointName == "joint23")
{
xyz.Set(0, 1, 0);
}

ASSERT_TRUE(joint->HasElement("axis"));
sdf::ElementPtr axis = joint->GetElement("axis");
EXPECT_EQ(xyz, axis->Get<ignition::math::Vector3d>("xyz"));
EXPECT_FALSE(axis->Get<bool>("use_parent_model_frame"));
}
}

0 comments on commit f8617a2

Please sign in to comment.