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

Add support for quaternion in URDF #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<exec_depend>libconsole-bridge-dev</exec_depend>
<exec_depend>tinyxml2</exec_depend>
<exec_depend>tinyxml2_vendor</exec_depend>
<exec_depend version_gte="0.2.3">urdfdom_headers</exec_depend>
<exec_depend version_gte="1.2.0">urdfdom_headers</exec_depend>

<test_depend>python3</test_depend>

Expand Down
18 changes: 18 additions & 0 deletions urdf_parser/src/pose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ bool parsePoseInternal(Pose &pose, tinyxml2::XMLElement* xml)
}

const char* rpy_str = xml->Attribute("rpy");
const char* quat_str = xml->Attribute("quat_xyzw");
if (rpy_str != NULL && quat_str != NULL)
{
CONSOLE_BRIDGE_logError("Both rpy and quat_xyzw orientations are defined. Use either one or the other.");
return false;
}

if (rpy_str != NULL)
{
try {
Expand All @@ -117,6 +124,17 @@ bool parsePoseInternal(Pose &pose, tinyxml2::XMLElement* xml)
return false;
}
}

if (quat_str != NULL)
{
try {
pose.rotation.initQuaternion(quat_str);
}
catch (ParseError &e) {
CONSOLE_BRIDGE_logError(e.what());
return false;
}
}
}
return true;
}
Expand Down
1 change: 1 addition & 0 deletions xsd/urdf.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<xs:complexType name="pose">
<xs:attribute name="xyz" type="xs:string" default="0 0 0" />
<xs:attribute name="rpy" type="xs:string" default="0 0 0" />
<xs:attribute name="quat_xyzw" type="xs:string" default="0 0 0 1" />
</xs:complexType>

<!-- pose node type -->
Expand Down