-
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
Draft: Parser warning message when <gazebo> reference does not exist in URDF #1392
base: sdf14
Are you sure you want to change the base?
Changes from all commits
640766f
ff06de3
bff4f75
d9f56f5
2d221fe
d610aa9
47f9c1f
8046a01
7f7b183
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2460,6 +2460,179 @@ TEST(URDFParser, ZeroMassLeafLink) | |||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
///////////////////////////////////////////////// | ||||||||||
TEST(URDFParser, ParseGazeboRefDoesntExistWarningMessage) | ||||||||||
{ | ||||||||||
// Redirect sdfwarn output | ||||||||||
std::stringstream buffer; | ||||||||||
sdf::testing::RedirectConsoleStream redir( | ||||||||||
sdf::Console::Instance()->GetMsgStream(), &buffer); | ||||||||||
#ifdef _WIN32 | ||||||||||
sdf::Console::Instance()->SetQuiet(false); | ||||||||||
sdf::testing::ScopeExit revertSetQuiet( | ||||||||||
[] | ||||||||||
{ | ||||||||||
sdf::Console::Instance()->SetQuiet(true); | ||||||||||
}); | ||||||||||
#endif | ||||||||||
|
||||||||||
// test if reference to link exists | ||||||||||
{ | ||||||||||
// clear the contents of the buffer | ||||||||||
buffer.str(""); | ||||||||||
|
||||||||||
std::string str = R"( | ||||||||||
<robot name="test_robot"> | ||||||||||
<link name="link1"> | ||||||||||
<inertial> | ||||||||||
<mass value="1" /> | ||||||||||
<inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01" /> | ||||||||||
</inertial> | ||||||||||
</link> | ||||||||||
<gazebo reference="lіnk1"> | ||||||||||
<sensor name="link1_imu" type="imu"> | ||||||||||
<always_on>1</always_on> | ||||||||||
<update_rate>100</update_rate> | ||||||||||
<pose>0.13525 0 -0.07019999999999993 0.0 -0.0 -2.0943952105869315</pose> | ||||||||||
<plugin name="sensor_plugin" filename="example_plugin.so" /> | ||||||||||
</sensor> | ||||||||||
</gazebo> | ||||||||||
</robot>)"; | ||||||||||
|
||||||||||
sdf::URDF2SDF parser; | ||||||||||
tinyxml2::XMLDocument sdfResult; | ||||||||||
sdf::ParserConfig config; | ||||||||||
parser.InitModelString(str, config, &sdfResult); | ||||||||||
|
||||||||||
EXPECT_PRED2(sdf::testing::contains, buffer.str(), | ||||||||||
"<link> tag reference[link1] does not exist" | ||||||||||
" in the URDF model. Please ensure that the reference attribute" | ||||||||||
" matches the name of a link."); | ||||||||||
} | ||||||||||
|
||||||||||
{ | ||||||||||
// clear the contents of the buffer | ||||||||||
buffer.str(""); | ||||||||||
|
||||||||||
std::string str = R"( | ||||||||||
<robot name="test_robot"> | ||||||||||
<link name="link1"> | ||||||||||
<inertial> | ||||||||||
<mass value="1" /> | ||||||||||
<inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01" /> | ||||||||||
</inertial> | ||||||||||
<visual name="visual1"> | ||||||||||
<geometry> | ||||||||||
<box> | ||||||||||
<size>1 1 1</size> | ||||||||||
</box> | ||||||||||
Comment on lines
+2526
to
+2528
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, will add to next commit |
||||||||||
</geometry> | ||||||||||
<material> | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
<color rgba="0.8 0.1 0.1 1.0"/> | ||||||||||
</material> | ||||||||||
<origin xyz="0 0 0.5" rpy="0 0 0"/> | ||||||||||
</visual> | ||||||||||
</link> | ||||||||||
<gazebo reference="vіsual1"> | ||||||||||
</gazebo> | ||||||||||
</robot>)"; | ||||||||||
|
||||||||||
sdf::URDF2SDF parser; | ||||||||||
tinyxml2::XMLDocument sdfResult; | ||||||||||
sdf::ParserConfig config; | ||||||||||
parser.InitModelString(str, config, &sdfResult); | ||||||||||
|
||||||||||
EXPECT_PRED2(sdf::testing::contains, buffer.str(), | ||||||||||
"<link> tag reference[link1] does not exist" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the error message reference
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep looking into this. I'be tried using |
||||||||||
" in the URDF model. Please ensure that the reference attribute" | ||||||||||
" matches the name of a link."); | ||||||||||
} | ||||||||||
|
||||||||||
{ | ||||||||||
// clear the contents of the buffer | ||||||||||
buffer.str(""); | ||||||||||
|
||||||||||
std::string str = R"( | ||||||||||
<robot name="test_robot"> | ||||||||||
<link name="link1"> | ||||||||||
<inertial> | ||||||||||
<mass value="1" /> | ||||||||||
<inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01" /> | ||||||||||
</inertial> | ||||||||||
<collision name="collision1"> | ||||||||||
<geometry> | ||||||||||
<sphere radius="0.5" /> | ||||||||||
</geometry> | ||||||||||
<origin xyz="0 0 0.5" rpy="0 0 0"/> | ||||||||||
</collision> | ||||||||||
</link> | ||||||||||
<gazebo reference="collіsion1"> | ||||||||||
<sensor name="link1_imu" type="imu"> | ||||||||||
<always_on>1</always_on> | ||||||||||
<update_rate>100</update_rate> | ||||||||||
<pose>0.13525 0 -0.07019999999999993 0.0 -0.0 -2.0943952105869315</pose> | ||||||||||
<plugin name="sensor_plugin" filename="example_plugin.so" /> | ||||||||||
</sensor> | ||||||||||
</gazebo> | ||||||||||
</robot>)"; | ||||||||||
|
||||||||||
sdf::URDF2SDF parser; | ||||||||||
tinyxml2::XMLDocument sdfResult; | ||||||||||
sdf::ParserConfig config; | ||||||||||
parser.InitModelString(str, config, &sdfResult); | ||||||||||
|
||||||||||
EXPECT_PRED2(sdf::testing::contains, buffer.str(), | ||||||||||
"<link> tag reference[link1] does not exist" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
" in the URDF model. Please ensure that the reference attribute" | ||||||||||
" matches the name of a link."); | ||||||||||
} | ||||||||||
|
||||||||||
{ | ||||||||||
// clear the contents of the buffer | ||||||||||
buffer.str(""); | ||||||||||
|
||||||||||
std::string str = R"( | ||||||||||
<robot name="test_robot"> | ||||||||||
<link name="link1"> | ||||||||||
<inertial> | ||||||||||
<mass value="1" /> | ||||||||||
<inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01" /> | ||||||||||
</inertial> | ||||||||||
</link> | ||||||||||
<link name="link2"> | ||||||||||
<inertial> | ||||||||||
<mass value="1" /> | ||||||||||
<inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01" /> | ||||||||||
</inertial> | ||||||||||
</link> | ||||||||||
<joint name="joint1" type="revolute"> | ||||||||||
<parent link="link1"/> | ||||||||||
<child link="link2"/> | ||||||||||
<axis xyz="0 0 1"/> | ||||||||||
<limit lower="-1.57" upper="1.57" effort="10" velocity="1.0"/> | ||||||||||
</joint> | ||||||||||
<gazebo reference="joіnt1"> | ||||||||||
<sensor name="link1_imu" type="imu"> | ||||||||||
<always_on>1</always_on> | ||||||||||
<update_rate>100</update_rate> | ||||||||||
<pose>0.13525 0 -0.07019999999999993 0.0 -0.0 -2.0943952105869315</pose> | ||||||||||
<plugin name="sensor_plugin" filename="example_plugin.so" /> | ||||||||||
</sensor> | ||||||||||
</gazebo> | ||||||||||
</robot>)"; | ||||||||||
|
||||||||||
sdf::URDF2SDF parser; | ||||||||||
tinyxml2::XMLDocument sdfResult; | ||||||||||
sdf::ParserConfig config; | ||||||||||
parser.InitModelString(str, config, &sdfResult); | ||||||||||
|
||||||||||
EXPECT_PRED2(sdf::testing::contains, buffer.str(), | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you comment why the two |
||||||||||
"<joint> tag reference[joint1] does not exist" | ||||||||||
" in the URDF model. Please ensure that the reference attribute" | ||||||||||
" matches the name of a joint."); | ||||||||||
} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've noticed with this PR that even properly working URDFs print a warning message. Do you mind adding a test with a URDF that has a correct reference and check that there is no warning printed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep ran into this while addressing the previous point. Will do. |
||||||||||
} | ||||||||||
aagrawal05 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
///////////////////////////////////////////////// | ||||||||||
/// Main | ||||||||||
int main(int argc, char **argv) | ||||||||||
|
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 here why the two
link1
s are not the same? I believe theі
(https://www.compart.com/en/unicode/U+0456) in<gazebo reference="lіnk1">
is the issue.