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 quaternion in URDF attributes #123

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
26 changes: 22 additions & 4 deletions urdf_parser/src/pose.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*********************************************************************
* Software License Agreement (BSD License)
*
*
* Copyright (c) 2008, Willow Garage, Inc.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
Expand All @@ -17,7 +17,7 @@
* * Neither the name of the Willow Garage nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
Expand Down Expand Up @@ -105,6 +105,13 @@ bool parsePose(Pose &pose, TiXmlElement* xml)
}

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

if (rpy_str != NULL)
{
try {
Expand All @@ -115,6 +122,17 @@ bool parsePose(Pose &pose, TiXmlElement* 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" type="xs:string" default="0 0 0 1" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there somewhere that it can be explicitly documented what the order of the quaternion is, in a way such that people don't have to look at the documentation of some upstream math library?

(This looks like xyzw... as a minor side comment, perhaps wxyz - where the non-imaginary part comes first - is a way to up-front distinguish the name from translation, if you were to make some accessor like wxyz or what not.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This looks like xyzw... as a minor side comment, perhaps wxyz - where the non-imaginary part comes first - is a way to up-front distinguish the name from translation, if you were to make some accessor like wxyz or what not.)

I highly prefer xyzw, since that is what most of the ROS stuff uses (going to and from Eigen is the place where this hurts, but at least we should be internally consistent).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

</xs:complexType>

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