-
Notifications
You must be signed in to change notification settings - Fork 96
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
parser_urdf: add //frame for reduced links/joints #1148
Conversation
Codecov Report
@@ Coverage Diff @@
## sdf9 #1148 +/- ##
==========================================
+ Coverage 87.82% 87.94% +0.11%
==========================================
Files 64 64
Lines 10095 10118 +23
==========================================
+ Hits 8866 8898 +32
+ Misses 1229 1220 -9
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Currently the location of some links and joints is lost when fixed joints are reduced and links lumped together. This adds //model/frame tags with the same name and pose of the reduced links and joints. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
7760525
to
8b3c2ad
Compare
this is ready for review now that #1126 has been merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me !
ASSERT_NE(nullptr, link); | ||
auto massMatrix = link->Inertial().MassMatrix(); | ||
EXPECT_DOUBLE_EQ(2.0, massMatrix.Mass()); | ||
EXPECT_EQ(2.0 * ignition::math::Matrix3d::Identity, massMatrix.Moi()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit : Can this be changed to gz
namespace ? I guess not, since this is targeting an older sdf
branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be possible, but we would also have to bump the minimum required version of ignition-math6 to 6.13.0. These changes are already being handled in #1118, and it's slightly simpler for VIPER if we can merge this PR without the gz::
namespaces, so I'd prefer to defer that change for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor comments. Otherwise, this is a nice feature and LGTM!
src/parser_urdf.cc
Outdated
// Ensure model extension vector is allocated | ||
if (g_extensions.find("") == g_extensions.end()) | ||
{ | ||
std::vector<SDFExtensionPtr> ge; | ||
g_extensions.insert(std::make_pair("", ge)); | ||
} | ||
|
||
// Add //frame tags to model extension vector | ||
g_extensions.at("").push_back(sdfExt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This would do the same thing, I believe.
// Ensure model extension vector is allocated | |
if (g_extensions.find("") == g_extensions.end()) | |
{ | |
std::vector<SDFExtensionPtr> ge; | |
g_extensions.insert(std::make_pair("", ge)); | |
} | |
// Add //frame tags to model extension vector | |
g_extensions.at("").push_back(sdfExt); | |
g_extensions[""].push_back(sdfExt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call: simplified in 2e9f08e
auto stringToExtension = [&sdfExt](const std::string &_frame) | ||
{ | ||
TiXmlDocument xmlNewDoc; | ||
xmlNewDoc.Parse(_frame.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for this to fail? i.e, do we need to check if xmlNewDoc.FirstChildElement()
is nullptr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's lots of places where we aren't doing proper error checking, but I've added some for this new code in 2e9f08e
|
||
sdf::ElementPtr model = robot->Root()->GetElement("model"); | ||
auto modelDom = root.ModelByIndex(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an assertion on modelDom
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 2e9f08e
</joint> | ||
<link name="rotary_link"> | ||
<inertial> | ||
<mass value="12"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment that this <inertial>
is set with the expected value of the <inerital>
of base
and intermediate_link
combined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some clarifying comments about the model in 2e9f08e, including what you have suggested here
EXPECT_EQ(1u, model->LinkCount()); | ||
EXPECT_TRUE(model->LinkNameExists("base")); | ||
|
||
// Expect MassMatrix3 values to match for links |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 2e9f08e
* Check for tinyxml2 parsing errors * Simplify map logic * Add comments to example URDF * Assert point is valid in test * Remove outdated comment Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Follow-up for #1148 with a cleaner implementation for the sdf13 branch that constructs sdf::Frame objects and serializes them to a string rather than using a stringstream to construct XML. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
🎉 New feature
Retain frame information from URDF fixed joints that are not preserved, related to #1110
Summary
Currently the location of some links and joints is lost when fixed joints are reduced and links lumped together. For example, the first snippet below is a URDF with two links outlined in red and a fixed joint outlined in blue. The child link has a visual outlined in green. The second snippet shows what results when converting to SDFormat, with the fixed joint and child link removed, and the visual moved to the parent link.
This process of "fixed joint reduction" reduces the complexity of a simulation, particularly for solvers using maximal coordinates, but it does lose some frame information. This pull request adds
//model/frame
tags with the same name and pose of the reduced links and joints. For example, the following would be added for the examples shown above.Test it
Compile and run
INTEGRATION_urdf_gazebo_extensions
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.