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

Merge sdf9 ➡️ sdf12 #1167

Merged
merged 3 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
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
27 changes: 26 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,32 @@

## libsdformat 9.X

### libsdformat 9.X.X (202X-XX-XX)
### libsdformat 9.9.0 (2022-09-07)

1. sdf/camera.sdf: fields for projection matrix
* [Pull request #1088](https://github.com/gazebosim/sdformat/pull/1088)

1. urdf: fix sensor/light pose for links lumped by fixed joints
* [Pull request #1114](https://github.com/gazebosim/sdformat/pull/1114)

1. Ensure relocatable config files
* [Pull request #419](https://github.com/gazebosim/sdformat/pull/419)
* [Pull request #1093](https://github.com/gazebosim/sdformat/pull/1093)

1. Test using `__model__`, `world` in @attached_to, @relative_to
* [Pull request #1066](https://github.com/gazebosim/sdformat/pull/1066)

1. Readme: Ignition -> Gazebo
* [Pull request #1080](https://github.com/gazebosim/sdformat/pull/1080)

1. Document major and minor SDFormat version numbers
* [Pull request #1065](https://github.com/gazebosim/sdformat/pull/1065)

1. Bash completion for flags
* [Pull request #1042](https://github.com/gazebosim/sdformat/pull/1042)

1. Add Link::ResolveInertial API
* [Pull request #1012](https://github.com/gazebosim/sdformat/pull/1012)

### libsdformat 9.8.0 (2022-04-26)

Expand Down
30 changes: 10 additions & 20 deletions src/parser_urdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void CreateVisual(tinyxml2::XMLElement *_elem, urdf::LinkConstSharedPtr _link,

/// create SDF Joint block based on URDF
void CreateJoint(tinyxml2::XMLElement *_root, urdf::LinkConstSharedPtr _link,
ignition::math::Pose3d &_currentTransform);
const ignition::math::Pose3d &_currentTransform);

/// insert extensions into links
void InsertSDFExtensionLink(tinyxml2::XMLElement *_elem,
Expand All @@ -150,12 +150,11 @@ void AddTransform(tinyxml2::XMLElement *_elem,
const ignition::math::Pose3d &_transform);

/// create SDF from URDF link
void CreateSDF(tinyxml2::XMLElement *_root, urdf::LinkConstSharedPtr _link,
const ignition::math::Pose3d &_transform);
void CreateSDF(tinyxml2::XMLElement *_root, urdf::LinkConstSharedPtr _link);

/// create SDF Link block based on URDF
void CreateLink(tinyxml2::XMLElement *_root, urdf::LinkConstSharedPtr _link,
ignition::math::Pose3d &_currentTransform);
const ignition::math::Pose3d &_currentTransform);

/// reduced fixed joints: apply appropriate frame updates in joint
/// inside urdf extensions when doing fixed joint reduction
Expand Down Expand Up @@ -1034,12 +1033,10 @@ void ReduceJointsToParent(urdf::LinkSharedPtr _link)
{
// go down the tree until we hit a parent joint that is not fixed
urdf::LinkSharedPtr newParentLink = _link;
ignition::math::Pose3d jointAnchorTransform;
while (newParentLink->parent_joint &&
newParentLink->getParent()->name != "world" &&
FixedJointShouldBeReduced(newParentLink->parent_joint) )
{
jointAnchorTransform = jointAnchorTransform * jointAnchorTransform;
parentJoint->parent_to_joint_origin_transform =
TransformToParentFrame(
parentJoint->parent_to_joint_origin_transform,
Expand Down Expand Up @@ -2627,11 +2624,8 @@ void URDF2SDF::ListSDFExtensions(const std::string &_reference)

////////////////////////////////////////////////////////////////////////////////
void CreateSDF(tinyxml2::XMLElement *_root,
urdf::LinkConstSharedPtr _link,
const ignition::math::Pose3d &_transform)
urdf::LinkConstSharedPtr _link)
{
ignition::math::Pose3d _currentTransform = _transform;

// must have an <inertial> block and cannot have zero mass.
// allow det(I) == zero, in the case of point mass geoms.
// @todo: keyword "world" should be a constant defined somewhere else
Expand Down Expand Up @@ -2673,13 +2667,13 @@ void CreateSDF(tinyxml2::XMLElement *_root,
(!_link->parent_joint ||
!FixedJointShouldBeReduced(_link->parent_joint)))
{
CreateLink(_root, _link, _currentTransform);
CreateLink(_root, _link, ignition::math::Pose3d::Zero);
}

// recurse into children
for (unsigned int i = 0 ; i < _link->child_links.size() ; ++i)
{
CreateSDF(_root, _link->child_links[i], _currentTransform);
CreateSDF(_root, _link->child_links[i]);
}
}

Expand Down Expand Up @@ -2714,7 +2708,7 @@ urdf::Pose CopyPose(ignition::math::Pose3d _pose)
////////////////////////////////////////////////////////////////////////////////
void CreateLink(tinyxml2::XMLElement *_root,
urdf::LinkConstSharedPtr _link,
ignition::math::Pose3d &_currentTransform)
const ignition::math::Pose3d &_currentTransform)
{
// create new body
tinyxml2::XMLElement *elem = _root->GetDocument()->NewElement("link");
Expand Down Expand Up @@ -2894,7 +2888,7 @@ void CreateInertial(tinyxml2::XMLElement *_elem,
////////////////////////////////////////////////////////////////////////////////
void CreateJoint(tinyxml2::XMLElement *_root,
urdf::LinkConstSharedPtr _link,
ignition::math::Pose3d &/*_currentTransform*/)
const ignition::math::Pose3d &/*_currentTransform*/)
{
// compute the joint tag
std::string jtype;
Expand Down Expand Up @@ -3229,10 +3223,6 @@ void URDF2SDF::InitModelString(const std::string &_urdfStr,
// set model name to urdf robot name if not specified
robot->SetAttribute("name", robotModel->getName().c_str());

// initialize transform for the model, urdf is recursive,
// while sdf defines all links relative to model frame
ignition::math::Pose3d transform;

// parse sdf extension
tinyxml2::XMLDocument urdfXml;
if (urdfXml.Parse(_urdfStr.c_str()))
Expand Down Expand Up @@ -3279,13 +3269,13 @@ void URDF2SDF::InitModelString(const std::string &_urdfStr,
child = rootLink->child_links.begin();
child != rootLink->child_links.end(); ++child)
{
CreateSDF(robot, (*child), transform);
CreateSDF(robot, (*child));
}
}
else
{
// convert, starting from root link
CreateSDF(robot, rootLink, transform);
CreateSDF(robot, rootLink);
}

// insert the extensions without reference into <robot> root level
Expand Down
17 changes: 11 additions & 6 deletions test/integration/urdf_gazebo_extensions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,22 @@ TEST(SDFParser, UrdfGazeboExtensionURDFTest)
else if (jointName == "joint12")
{
// cfmDamping not provided
ASSERT_TRUE(joint->HasElement("physics"));
EXPECT_TRUE(joint->HasElement("physics"));
sdf::ElementPtr physics = joint->GetElement("physics");
EXPECT_FALSE(physics->HasElement("implicit_spring_damper"));
EXPECT_TRUE(physics->HasElement("ode"));
sdf::ElementPtr ode = physics->GetElement("ode");
EXPECT_TRUE(ode->HasElement("implicit_spring_damper"));
EXPECT_FALSE(ode->Get<bool>("implicit_spring_damper"));
}
else if (jointName == "joint13")
else if (jointName == "joint14")
{
// implicitSpringDamper = 1
ASSERT_TRUE(joint->HasElement("physics"));
EXPECT_TRUE(joint->HasElement("physics"));
sdf::ElementPtr physics = joint->GetElement("physics");
ASSERT_TRUE(physics->HasElement("implicit_spring_damper"));
EXPECT_TRUE(physics->Get<bool>("implicit_spring_damper"));
EXPECT_TRUE(physics->HasElement("ode"));
sdf::ElementPtr ode = physics->GetElement("ode");
EXPECT_TRUE(ode->HasElement("implicit_spring_damper"));
EXPECT_TRUE(ode->Get<bool>("implicit_spring_damper"));
}
}

Expand Down
30 changes: 21 additions & 9 deletions test/integration/urdf_gazebo_extensions.urdf
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@
<dampingFactor>0.1</dampingFactor>
</gazebo>

<joint name="joint13" type="revolute">
<origin rpy="-1.57079632679 0 -1.57079632679" xyz="0 -3.0 0.0"/>
<axis xyz="0 1 0"/> <!-- in child (link1) frame -->
<limit lower="0" upper="0" velocity="1000" effort="10000"/>
<parent link="link1"/>
<child link="link3"/>
</joint>

<joint name="joint23" type="revolute">
<origin rpy="-1.57079632679 0 -1.57079632679" xyz="-0.5 0.5 2.5"/>
<axis xyz="0 1 0"/> <!-- in child (link1) frame -->
Expand All @@ -125,7 +117,27 @@
</visual>
</link>

<gazebo reference="joint13">
<joint name="joint14" type="revolute">
<origin rpy="-1.57079632679 0 -1.57079632679" xyz="0 -3.0 0.0"/>
<axis xyz="0 1 0"/> <!-- in child (link1) frame -->
<limit lower="0" upper="0" velocity="1000" effort="10000"/>
<parent link="link1"/>
<child link="link4"/>
</joint>
<link name="link4">
<inertial>
<mass value="400"/>
<origin rpy="2 3 4" xyz="0.1 0.2 0.3"/>
<inertia ixx="8" ixy="0" ixz="0" iyy="9" iyz="0" izz="10"/>
</inertial>
<visual>
<geometry>
<box size="0.3 0.4 0.5"/>
</geometry>
<origin rpy="2 3 4" xyz="0.1 0.2 0.3"/>
</visual>
</link>
<gazebo reference="joint14">
<implicitSpringDamper>true</implicitSpringDamper>
</gazebo>

Expand Down