-
Notifications
You must be signed in to change notification settings - Fork 97
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
URDF->SDF handle links with no inertia or small mass #1238
Conversation
…r if mass is too small Signed-off-by: Aaron Chong <[email protected]>
… more verbose messages Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
… being explicit about epsilon in equal Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
Codecov Report
@@ Coverage Diff @@
## sdf12 #1238 +/- ##
==========================================
+ Coverage 92.03% 92.14% +0.10%
==========================================
Files 79 79
Lines 13090 13120 +30
==========================================
+ Hits 12047 12089 +42
+ Misses 1043 1031 -12
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
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.
The main issue that we have to resolve is what to assign the attached_to
attribute of the created frame. In thinking about that I've come to realize there will be some use cases we can't/shouldn't support as they will cause more confusion. My conclusion so far is, for the link->frame conversion, the link has have a parent or child joint with a "fixed" type.
Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
…th::equals Signed-off-by: Aaron Chong <[email protected]>
…f no inertial frame Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
…ides gazebo tags for joint lumping, warnings with more information and placeholder url Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
Per VC,
|
…ting (#1251) Signed-off-by: Aaron Chong <[email protected]>
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 looks great! Thanks a lot for iterating and for the through tests. This was a doozy!
…ed/dropped Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
…m sdf_tutorials#88 Signed-off-by: Aaron Chong <[email protected]>
I've also committed the expected URL of gazebosim/sdf_tutorials#88, we can wait for that to be merged before hitting the green button then |
src/parser_urdf.cc
Outdated
jointReductionHappens = true; | ||
break; |
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.
Codecov says these two lines are not covered. Is it a false negative?
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 believe so! This test will cause the break
, https://github.com/gazebosim/sdformat/pull/1238/files#diff-fc2484863e209b4368da90c08381488ec4b010f386c642b1ea1e8bcf82cf6f02R2141-R2190
Could this be due to the code only checking !jointReductionHappens
and not do anything if jointReductionHappens
is true?
I'm not too sure how to see if this gets reported again, is it just https://app.codecov.io/gh/gazebosim/sdformat/pull/1238? Looks alright at the moment
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 tested with gdb, and looks like it really isn't covered. Apparently, a massless link with a non-fixed parent joint and a fixed child joint is reduced before CreateSDF
is ever called :
Lines 3385 to 3398 in ba52e6f
if (g_reduceFixedJoints) | |
{ | |
ReduceFixedJoints(robot, urdf::const_pointer_cast<urdf::Link>(rootLink)); | |
} | |
if (rootLink->name == "world") | |
{ | |
// convert all children link | |
for (std::vector<urdf::LinkSharedPtr>::const_iterator | |
child = rootLink->child_links.begin(); | |
child != rootLink->child_links.end(); ++child) | |
{ | |
CreateSDF(robot, (*child)); | |
} |
This means, the massless link now has mass from the lumped child links. So, I guess if we encounter a massless link here, it would only be if:
- it's parent joint is reduced (i.e, the link has been lumped into it's parent link) or
- it's child joint is fixed, but could not be reduced because joint lumping is disabled.
Can you verify my logic? Does that maybe simplify anything?
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.
Yup, I can recreate it with gdb
too, it doesn't even allow me to set a breakpoint there, probably got optimized away by the compiler. Looking at the code, I can verify that is the intended behavior too.
94382d7, 6aa625c, I've refactored the fixed child joint logic and reduced the number of checks we are doing overall (only if parent joint is reduced)
I kept the use of Errors
, instead of using sdfwarn << Error(...)
directly, to make easier when we do introduce passing Errors
into these functions in the future.
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.
@azeey, per VC, regarding whether or not a similar situation for reduced parent joints is a bug, I don't believe it is a bug, just that checks happen after . Before this PR, joints are lumped recursively onto their parents with L3387 (shared by you above), and relies on https://github.com/gazebosim/sdformat/pull/1238/files#diff-2bc5ca23bcfc66fe173f513399bec8065b1cb4e607d741566517d7368e6bce0fL2705 to not create the link (whose's inertia has been lumped) if the parent joint is reduced, but the urdf link still contains the mass values
so there will be cases where CreateSDF
is called on a massless link, https://github.com/gazebosim/sdformat/pull/1238/files#diff-2bc5ca23bcfc66fe173f513399bec8065b1cb4e607d741566517d7368e6bce0fL2713, where the parent has already been reduced, hence the need to check if the parent has been reduced.
on the otherhand, as you surmised, a massless link A
with a fixed child joint, and child link B
with mass, will already have B
's mass lumped into it in CreateSDF
, so it should always have mass unless joint lumping was turned off.
…in case links change, we are not testing for that anyway Signed-off-by: Aaron Chong <[email protected]>
Signed-off-by: Aaron Chong <[email protected]>
…t is reduced Signed-off-by: Aaron Chong <[email protected]>
* Adding tests that catch warnings when urdf have no inertia element, or if mass is too small Signed-off-by: Aaron Chong <[email protected]> * Promote link inertia and mass related urdf2sdf sdfdbg to sdfwarn with more verbose messages Signed-off-by: Aaron Chong <[email protected]> * Added flag for converting urdf links with small or no mass to frames Signed-off-by: Aaron Chong <[email protected]> * Converts urdf links with small or no mass to frames, added tests Signed-off-by: Aaron Chong <[email protected]> * Adding warning when conversion happens, added tests for small masses, being explicit about epsilon in equal Signed-off-by: Aaron Chong <[email protected]> * Fix cpplint errors Signed-off-by: Aaron Chong <[email protected]> * Adding integration test Signed-off-by: Aaron Chong <[email protected]> * Fix lint Signed-off-by: Aaron Chong <[email protected]> * Use camelCase Signed-off-by: Aaron Chong <[email protected]> * Added URDFMinimumAllowedLinkMass Signed-off-by: Aaron Chong <[email protected]> * Fix tests expecting warnings when converting to frames Signed-off-by: Aaron Chong <[email protected]> * Adding inline contains and notContains to test_utils Signed-off-by: Aaron Chong <[email protected]> * Using RedirectConsoleStream and ScopeExit Signed-off-by: Aaron Chong <[email protected]> * Refactor to use Root::LoadSdfString Signed-off-by: Aaron Chong <[email protected]> * Removing debug message when converted frame is from a root link Signed-off-by: Aaron Chong <[email protected]> * Added attached_to for frames during conversion, using < instead of math::equals Signed-off-by: Aaron Chong <[email protected]> * Update brief of URDFSetConvertLinkWithNoMassToFrame to mention case of no inertial frame Signed-off-by: Aaron Chong <[email protected]> * Remove stale commentted code Signed-off-by: Aaron Chong <[email protected]> * Update comment about the errors we are expecting Signed-off-by: Aaron Chong <[email protected]> * Convert to frame by default, remove minimal mass option, refactor implementation to handle lumping, modified unit tests Signed-off-by: Aaron Chong <[email protected]> * Only convert to frame when parent joint is fixed, attaches and transforms pose to parent link, leaves out the fixed joint Signed-off-by: Aaron Chong <[email protected]> * Rephrased conversion error, modified unit tests Signed-off-by: Aaron Chong <[email protected]> * prints zero mass errors as well when conversion to frame fails Signed-off-by: Aaron Chong <[email protected]> * integration tests that mimic the unit tests Signed-off-by: Aaron Chong <[email protected]> * Added integration test with valid and invalid use of force torque sensor where massless child links occur Signed-off-by: Aaron Chong <[email protected]> * Fix lint Signed-off-by: Aaron Chong <[email protected]> * Fix joint reduction logic, more specific error messages, more targeted unit tests for each case Signed-off-by: Aaron Chong <[email protected]> * Convert joints to frames when converting links, attach them to converted links Signed-off-by: Aaron Chong <[email protected]> * Integration tests with child fixed links as well Signed-off-by: Aaron Chong <[email protected]> * Change sdferr to sdfwarn, no way to use ParserConfig::WarningsPolicy for now Signed-off-by: Aaron Chong <[email protected]> * sdferr to sdfwarn for the case where conversion to frame is attempted Signed-off-by: Aaron Chong <[email protected]> * Removing case within converting to frame, where parent joint turns into revolute joint, that is not covered Signed-off-by: Aaron Chong <[email protected]> * Reduced scope of implementation, more specific warning messages Signed-off-by: Aaron Chong <[email protected]> * Remove mention of parser config in warning, since that is not typically used by workflows Signed-off-by: Aaron Chong <[email protected]> * Integration tests revisited and modified, removed printouts Signed-off-by: Aaron Chong <[email protected]> * Test case showing ParserConfig::URDFSetPreserveFixedJoint(true) overrides gazebo tags for joint lumping, warnings with more information and placeholder url Signed-off-by: Aaron Chong <[email protected]> * Use sdf::testing::contains instead of local contains functions in testing (#1251) Signed-off-by: Aaron Chong <[email protected]> * Remove unused InitSDF, added TODO for warning when joints are converted/dropped Signed-off-by: Aaron Chong <[email protected]> * Cleaned up if else cases Signed-off-by: Aaron Chong <[email protected]> * Using << operator of Errors Signed-off-by: Aaron Chong <[email protected]> * Replacing placeholder url with expected URL for the documentation from sdf_tutorials#88 Signed-off-by: Aaron Chong <[email protected]> * URL to tutorial as a constant, removing checking URL from test, just in case links change, we are not testing for that anyway Signed-off-by: Aaron Chong <[email protected]> * Refactored fixed child joint logic as it is never reached Signed-off-by: Aaron Chong <[email protected]> * Reduce number of if statements, renaming to only check if parent joint is reduced Signed-off-by: Aaron Chong <[email protected]> --------- Signed-off-by: Aaron Chong <[email protected]> (cherry picked from commit 6ffe669) Signed-off-by: Aaron Chong <[email protected]>
* Adding tests that catch warnings when urdf have no inertia element, or if mass is too small Signed-off-by: Aaron Chong <[email protected]> * Promote link inertia and mass related urdf2sdf sdfdbg to sdfwarn with more verbose messages Signed-off-by: Aaron Chong <[email protected]> * Added flag for converting urdf links with small or no mass to frames Signed-off-by: Aaron Chong <[email protected]> * Converts urdf links with small or no mass to frames, added tests Signed-off-by: Aaron Chong <[email protected]> * Adding warning when conversion happens, added tests for small masses, being explicit about epsilon in equal Signed-off-by: Aaron Chong <[email protected]> * Fix cpplint errors Signed-off-by: Aaron Chong <[email protected]> * Adding integration test Signed-off-by: Aaron Chong <[email protected]> * Fix lint Signed-off-by: Aaron Chong <[email protected]> * Use camelCase Signed-off-by: Aaron Chong <[email protected]> * Added URDFMinimumAllowedLinkMass Signed-off-by: Aaron Chong <[email protected]> * Fix tests expecting warnings when converting to frames Signed-off-by: Aaron Chong <[email protected]> * Adding inline contains and notContains to test_utils Signed-off-by: Aaron Chong <[email protected]> * Using RedirectConsoleStream and ScopeExit Signed-off-by: Aaron Chong <[email protected]> * Refactor to use Root::LoadSdfString Signed-off-by: Aaron Chong <[email protected]> * Removing debug message when converted frame is from a root link Signed-off-by: Aaron Chong <[email protected]> * Added attached_to for frames during conversion, using < instead of math::equals Signed-off-by: Aaron Chong <[email protected]> * Update brief of URDFSetConvertLinkWithNoMassToFrame to mention case of no inertial frame Signed-off-by: Aaron Chong <[email protected]> * Remove stale commentted code Signed-off-by: Aaron Chong <[email protected]> * Update comment about the errors we are expecting Signed-off-by: Aaron Chong <[email protected]> * Convert to frame by default, remove minimal mass option, refactor implementation to handle lumping, modified unit tests Signed-off-by: Aaron Chong <[email protected]> * Only convert to frame when parent joint is fixed, attaches and transforms pose to parent link, leaves out the fixed joint Signed-off-by: Aaron Chong <[email protected]> * Rephrased conversion error, modified unit tests Signed-off-by: Aaron Chong <[email protected]> * prints zero mass errors as well when conversion to frame fails Signed-off-by: Aaron Chong <[email protected]> * integration tests that mimic the unit tests Signed-off-by: Aaron Chong <[email protected]> * Added integration test with valid and invalid use of force torque sensor where massless child links occur Signed-off-by: Aaron Chong <[email protected]> * Fix lint Signed-off-by: Aaron Chong <[email protected]> * Fix joint reduction logic, more specific error messages, more targeted unit tests for each case Signed-off-by: Aaron Chong <[email protected]> * Convert joints to frames when converting links, attach them to converted links Signed-off-by: Aaron Chong <[email protected]> * Integration tests with child fixed links as well Signed-off-by: Aaron Chong <[email protected]> * Change sdferr to sdfwarn, no way to use ParserConfig::WarningsPolicy for now Signed-off-by: Aaron Chong <[email protected]> * sdferr to sdfwarn for the case where conversion to frame is attempted Signed-off-by: Aaron Chong <[email protected]> * Removing case within converting to frame, where parent joint turns into revolute joint, that is not covered Signed-off-by: Aaron Chong <[email protected]> * Reduced scope of implementation, more specific warning messages Signed-off-by: Aaron Chong <[email protected]> * Remove mention of parser config in warning, since that is not typically used by workflows Signed-off-by: Aaron Chong <[email protected]> * Integration tests revisited and modified, removed printouts Signed-off-by: Aaron Chong <[email protected]> * Test case showing ParserConfig::URDFSetPreserveFixedJoint(true) overrides gazebo tags for joint lumping, warnings with more information and placeholder url Signed-off-by: Aaron Chong <[email protected]> * Use sdf::testing::contains instead of local contains functions in testing (#1251) Signed-off-by: Aaron Chong <[email protected]> * Remove unused InitSDF, added TODO for warning when joints are converted/dropped Signed-off-by: Aaron Chong <[email protected]> * Cleaned up if else cases Signed-off-by: Aaron Chong <[email protected]> * Using << operator of Errors Signed-off-by: Aaron Chong <[email protected]> * Replacing placeholder url with expected URL for the documentation from sdf_tutorials#88 Signed-off-by: Aaron Chong <[email protected]> * URL to tutorial as a constant, removing checking URL from test, just in case links change, we are not testing for that anyway Signed-off-by: Aaron Chong <[email protected]> * Refactored fixed child joint logic as it is never reached Signed-off-by: Aaron Chong <[email protected]> * Reduce number of if statements, renaming to only check if parent joint is reduced Signed-off-by: Aaron Chong <[email protected]> --------- Signed-off-by: Aaron Chong <[email protected]> (cherry picked from commit 6ffe669) Signed-off-by: Aaron Chong <[email protected]>
When converting from URDF to SDFormat, some links without an <inertial> block or a small mass may be dropped with only debug messages in a log file, which are easily missed. This makes the following changes: * When a massless link in the middle of a kinematic chain is successfully merged to its parent by fixed joint reduction, fix bug that was dropping the massless link's child links and joints. * Print no warnings or debug messages when a massless link is successfully merged to a parent by fixed joint reduction. * Promote debug messages to warnings / errors when links are dropped to improve visibility. Improve message clarity and suggest fixes to the user. * Change massless threshold test to `> 0` instead of being within a 1e-6 tolerance of 0. * Add unit and integration tests. Related to #199 and #1007. (cherry picked from commit 6ffe669) Signed-off-by: Aaron Chong <[email protected]> Co-authored-by: Steve Peters <[email protected]>
🦟 Bug fix
Related to #199, and #1007.
Summary
(edited)
Current behavior
When a URDF link has no
<inertial>
block or has a mass of less than or eqaul to1e-6
it is considered a link without mass, and if joint lumping does not help convert it to a frame, it will be ignored during the conversion to sdf, with debug messages instead of warnings or errors, which is easily missed and users might be surprised when a large part of their model disappears.Changes
sdfdbg
tosdfwarn
for when links with no block or mass values of 0 or less are ignored, parent joint, and their child joints and links<gazebo>
tags to allow joint lumping and reduction to resolve massless link issues> 0
for mass requirement, instead ofgz::math::equals
and the epsilon of1e-6
Tests
Example of suggesting removal of
<gazebo>
tagIntermediate joint with zero mass, fixed parent link, but joint lumping and reduction disabled with gazebo tag,
Warnings expected:
Resulting sdf will have everything below
joint1_2
ignored,Removing it, we get
Resulting in no warnings or errors, and a valid sdf,
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.