Skip to content

Commit

Permalink
Quaternion in urdf (PR123 new attempt)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Doisy committed Jan 14, 2024
1 parent 29426ec commit 31390a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required( VERSION 3.5 FATAL_ERROR )
project (urdfdom CXX C)

set (URDF_MAJOR_VERSION 4)
set (URDF_MINOR_VERSION 0)
set (URDF_MINOR_VERSION 1)
set (URDF_PATCH_VERSION 0)

set (URDF_VERSION ${URDF_MAJOR_VERSION}.${URDF_MINOR_VERSION}.${URDF_PATCH_VERSION})
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

0 comments on commit 31390a9

Please sign in to comment.