-
Notifications
You must be signed in to change notification settings - Fork 132
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
Conversation
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.
With the one exception of the name of the method, this looks pretty good to me.
URDF is quite used also outside of ROS/urdfdom, including in several commercial and proprietary products. A change like this renders all the existing URDF parser implementations incomplete, and can create confusion in the users that do not understand why a URDF that is correctly parsed by urdfdom is not parsed by a third party tool. Perhaps it would make to add some kind of versioning to the format, so that the quaternion-less URDF would be "URDFv1", and the new URDF would be "URDFv2", and libraries that needs to be updated could simply claim compatibility with "URDFv1" (and incompatibility with "URDFv2")? |
In the current implementation, if both |
I think having a version in URDF is a good thing in general. And if this change broke existing URDF, then I'd definitely be on board with versioning it and being sure that other implementations knew about it. But for backwards compatible changes like this one, I have to argue that we must be able to iterate on it. Otherwise, the format becomes set in stone and eventually becomes irrelevant as the world changes around it. Also, bumping the URDF version every time we add a new field just doesn't seem sustainable.
That's a really good point. I'd actually argue that we should make the parser throw an error at that point, since it is unclear what the user means. I'll add a note to the implementation. |
I agree that this change is backward compatible from the point of view of who genererates models: your old model will continue to be loaded as before in the new urdfdom. However, it is not backward compatible for authors of library, tools and products that consume URDFs: as soon as it is merged in master, there will be URDFs that will be accepted by urdfdom, while being silently parsed in the wrong way in all other libraries that consume URDF. The tricky part is the currently if the
Note that there is no need to bump the URDF major version, we could have a minor/patch version and just bump that one. Do not get my wrong: I totally agree that we should have space to evolve the URDF format: I just think we should try to do that limiting as much as possible the confusion for users of the format itself. |
I have modified the code so that an error is thrown if both <origin quat_xyzw="0 0 0.7071 0.7071" rpy="0 0 0" xyz="2.5 0 0"/> Will lead to: [ERROR] [1551279485.356898376]: Both rpy and quat_xyzw orientations are defined. Use either one or the other.
[ERROR] [1551279485.356938194]: Could not parse visual element for Link [suzanne_green]
|
xsd/urdf.xsd
Outdated
@@ -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" /> |
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.
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.)
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.
(This looks like
xyzw
... as a minor side comment, perhapswxyz
- 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 likewxyz
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).
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.
Sounds good!
If it's not too late, can I make a plea to make the ordering of quaternions explicit in the name? Something like |
That's a good idea, I'm good with that. I'd go for |
Good idea, explicit is better than implicit. |
Sweet! Thanks! |
Any other ideas or remarks? |
I agree with @traversaro that we some kind of versioning for URDF as features are added. There is a version attribute in urdf.xsd, so we should probably start using it for new features. |
I actually do have one question: What's the motivation for adding this format? What workflow is improved by having this? (a) Is it easier for you to interpret the physical meaning of a quaternion instead of I ask because I've filed #124 motivated by (a) being able to better physically interpret the meaning of numbers. (Even if I can recognize |
I will change the version of the urdfdom project and XML version attribute Angles are represented with quaternions within ROS, pretty much everywhere. So it makes sense to be able to use/get quaternions everywhere. (a) Yes, unlike Euler angles there is no conventions with quaternion, getting the rotation matrix from quaternions is straightforward, with Euler angles you have to make sure of what convention is used; if you use the wrong one, you get a wrong result.
If you train your brain to work in radians you will be able to play with them like with degrees, but we are usually taught to think with degrees 😄. |
That all makes sense, thanks for explaining! For (a) and (b), that can be partially resolved by the standard explicitly stating what type of Euler angles there are, rather than trying to cross-ref. software and heuristically match the representations. For the degrees bit, I have trained myself to think in radians, but I still hate it :P I can certainly interpret radians, but I do prefer the simplicity and "roundness" of degrees, and if modeling formats tend towards human readability, RPY in degrees are a little bit more quickly interpreted for me (and require fewer duplicate computations, e.g. storing / computing Thanks! |
Are you ok with the changes? What is preventing this pull request from being merged? |
I think this may be dependent on what @scpeters said about versioning?
|
Ping, I've updated the file versions number so we should be good. |
I am personally totally fine with using the version attribute of URDF. If we start to use it, I suggest to remove the After that, it will be up to the URDF consuming/producing software to correctly parse or reject URDF v1.1 files. However, I wonder what strategy should be used for ROS packages that parse URDFs, but without using urdfdom, such as https://github.com/ros/urdf_parser_py . They should be updated to handle v1.1 URDFs? |
While this PR is open I wonder if we could also talk about adding support for custom transforms to be defined in the URDF (allow the user to supply the full 4x4 matrix). My use case is that I am working on supporting robots by utilizing the DH convention. I would like to make a single URDF that takes in a DH parameter table and produces a robot_description parameter in ROS. This would allow me to take calibration parameters given by industrial robots (I.E. The Yaskawa Motoman offers the ability to query its calibrated DH parameters) and read/apply them on the next startup without hand modifying the URDF. I have a simple version of this working with the current framework, only works if the theta_offset of the DH is zero, because the two rotations that are applied in DH are not done in the same order that URDF applies them. I could get a system fully working if I made dummy links between links that applied the rotation properly, or recalculated the transform to the ROS convention with another program but would really like to avoid these approaches if possible. For example here is the forward kinematics code I made in school to apply a single DH transform...
|
Is there any progress regarding this PR? I am waiting for quaternions in the URDF for some time and wondering, whether it will be available in the current ROS noetic. Best regards |
I gave up because I don't like endless discussions. Feel free to take/improve my work into a new pull request! |
We also would be happy when this pull request would be merged! The output of our extrinsic sensor calibration is in quaternion so there would be no need to convert them every time. |
As a workaround we are able to use quaternions by using a xacro macro:
It can be used like this:
|
Reading this, it is a shame it did not go through. |
There's nothing planned that I know of. I'm not opposed to the idea at all, and now that we have URDF versions we can easily bump the version number. So do feel free to open a PR with this code in place plus a bump of the version. We'll also have to add support to https://github.com/ros/urdf_parser_py |
ros#123 Signed-off-by: Guillaume Doisy <guillaume@dexory.com>
Created a new issue and PRs, see: #195 |
Fixes #13
Short description
Only
rpy
rotations are supported inurdf
now. This pull request allows to use quaternions inside ofurdf
files.URDF syntax example
How to test
Compile / install modified
urdfdom_headers
Compile / install modified
urdfdom
Change
LD_LIBRARY_PATH
to make sure newurdfdom
version will be usedLD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
Compile a simple example package and visualize result in RViz
Green suzanne is turned 90° around the Z axis because the provided quaternion is 0 0 0.7071 0.7071 (xyzw):
Notes
xyzw
, some libraries (Eigen) initialize in thewxyz
order, so we must document the initialization order.