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

Update document to better reflect proposed and accepted implementations #56

Merged
merged 4 commits into from
Sep 17, 2021

Conversation

azeey
Copy link
Collaborator

@azeey azeey commented Sep 9, 2021

This updates the proposal to reflect the accepted implementation in gazebosim/sdformat#589 and the proposed implementation in gazebosim/sdformat#690.

Preview: http://sdformat.org/tutorials?tut=better_pose_proposal&cat=pose_semantics_docs&branch=azeey%2Fbetter_pose_update

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

LGTM in general.

I'll just point out that everything that's added to the SDF spec must be implemented by all parsers, not only libSDFormat. It's important to take this into consideration, because the more complex the spec is, the more fragmented the SDF support is in the ecosystem. For example, the SDF parser that we have in JavaScript will probably not support this proposal for a long time.

This proposal intends to resolve on point (1) by adding `//pose/rotation/@type`
where degrees can be specified, and *could* address point (2) by structuring
This proposal intends to resolve on point (1) by adding `//pose/@degrees`
where degrees can be selected, and *could* address point (2) by structuring
the element differently (see below).
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the intro have some sentences about quaternions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think it should. I was hoping that folks who would like to see quaternions supported provide the motivations for doing so. The original proposal did not have a solid motivation for quaternions, so we decided to drop them, but we've had discussions to bring them back. It would be great if we can list out the motivations here, so we can justify the added complexity.

Copy link
Member

Choose a reason for hiding this comment

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

There is some documented support in the following issues for adding quaternion support to URDF in the following issues:

In terms of justification, though I find Quaternions less visually inspectable, they are more straightforward to interpret than Euler angles (24 total flavors). This simplifies the portability of quaternions to other pieces of software and algorithms.

If using a camera calibration algorithm that yields Quaternion coefficients (such as doi:10.1109/TIP.2011.2164421), it is most straightforward to directly specify those coefficients in the model file, rather than requiring a user to convert them to roll-pitch-yaw angles, with the risk of calculation errors and precision loss.

Copy link
Member

Choose a reason for hiding this comment

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

shall I suggest text in this PR or open a new pull request with justification for quaternions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Either way works, but please feel free to make direct changes to this PR.

angle. This is provided for legacy purposes and ease of conversion.
* It is not suggested to use this for a text-storage format.
* Same precision as suggested below for quaternions: Use 17 digits of
precision, and consider separating each value on a new line.
* `q_wxyz` - Quaternion as a 4-tuple, represented as `(w, x, y, z)`, where `w`
* `@rotation_format="q_wxyz"` - Quaternion as a 4-tuple, represented as `(w, x, y, z)`, where `w`
is the real component. This should generally be used when the rotation should be
machine-generated (e.g. calibration artifacts).
Copy link
Contributor

Choose a reason for hiding this comment

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

"Should" sounds a bit too opinionated. Some other use cases for quaternions that I can think of are precision and integration with specific tools. I'd recommend rephrasing to be less specific.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed it to "This is the recommended format for machine-generated files (e.g. calibration artifacts)." How does that sound?

* This should be used when the rotation should generally be human-readable.
* `rpy_radians` - Same as `rpy_degrees`, but with radians as the units for each
* `@rotation_format="rpy"`, `@degrees="false"` - Same as above, but with radians as the units for each
angle. This is provided for legacy purposes and ease of conversion.
Copy link
Contributor

Choose a reason for hiding this comment

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

Saying that this is provided for legacy purposes suggests that this may be deprecated in the future. Is that the case? Aren't there valid use cases for radian RPY?

Copy link
Member

Choose a reason for hiding this comment

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

👍

I would say that it is the default for legacy purposes, not that it is provided for legacy purposes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to "This is the default for legacy purposes" in a258425

* This should be used when the rotation should generally be human-readable.
* `rpy_radians` - Same as `rpy_degrees`, but with radians as the units for each
* `@rotation_format="rpy"`, `@degrees="false"` - Same as above, but with radians as the units for each
angle. This is provided for legacy purposes and ease of conversion.
Copy link
Member

Choose a reason for hiding this comment

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

👍

I would say that it is the default for legacy purposes, not that it is provided for legacy purposes

<pose rotation_type="rpy_radians">{xyz} {rpy_radians}</pose>
<pose rotation_type="rpy_degrees">{xyz} {rpy_degrees}</pose>
<pose rotation_format="rpy_radians">{xyz} {rpy_radians}</pose>
<pose rotation_format="rpy_degrees">{xyz} {rpy_degrees}</pose>
Copy link
Member

Choose a reason for hiding this comment

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

if we are using //pose/@degrees, then I would change the @rotation_format values to euler_rpy or q_wxyz / quat_wxyz / quaternion_wxyz

this way the portion before the _ describes the rotation format (quaternion or Euler angles) and the part after the _ describes the component order

I would still only support one form of Euler angles, but ensure that the rotation order is clearly documented

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

euler_rpy and quat_wxyz sound good to me.

I would still only support one form of Euler angles, but ensure that the rotation order is clearly documented

Agreed. Looking at that link reminded me a recent change to the pose spec (fix in gazebosim/sdformat#698). I don't think we can completely get rid of confusion about Euler angles, but we should do our best to clearly document SDFormat's convention.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to euler_rpy and quat_wxyz in a258425.

* This should be used when the rotation should generally be human-readable.
* `rpy_radians` - Same as `rpy_degrees`, but with radians as the units for each
* `@rotation_format="rpy"`, `@degrees="false"` - Same as above, but with radians as the units for each
Copy link
Member

Choose a reason for hiding this comment

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

the candidate values for @rotation_format given here don't match the values above in Syntax B.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in a258425.

@@ -321,19 +288,17 @@ in code, the order of operations, etc.).

#### 1.2 Conversion to SDFormat 1.9

When SDFormat files are converted from SDFormat <=1.8 to 1.9, the `//pose` tags
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed this section because I think this was a remnant of when this document proposed to deprecate RPY with radians. IMO, we should leave poses in older files intact. This will keep converted from getting verbose. Also, we currently print out only attributes with non-default values. We can have a special case for //pose so that //pose/rotation_format="euler_rpy" and //pose/@degrees=false get printed even though they are the default values, but the added complexity doesn't seem justified.

Copy link
Collaborator

@aaronchongth aaronchongth left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes! Looks good in general, on a separate note, I found a typo we missed out in the past, coordiantes
https://github.com/ignitionrobotics/sdf_tutorials/blob/azeey/better_pose_update/specify_pose/proposal.md?plain=1#L279

@azeey
Copy link
Collaborator Author

azeey commented Sep 14, 2021

Looking at ROS, ROS2 and Ignition messages, it looks like the order xyzw is preferred for quaternions. Even though I like wxyz since it follows the alphabetical order, I propose we change it to xyzw to maintain consistency with tools that will be commonly used with SDFormat.

\cc @EricCousineau-TRI, @FirefoxMetzger

@scpeters
Copy link
Member

Looking at ROS, ROS2 and Ignition messages, it looks like the order xyzw is preferred for quaternions. Even though I like wxyz since it follows the alphabetical order, I propose we change it to xyzw to maintain consistency with tools that will be commonly used with SDFormat.

\cc @EricCousineau-TRI, @FirefoxMetzger

I am indifferent between wxyz and xyzw; the important thing is that the convention is clear. If we have to choose only one, I think xyzw makes sense to match ROS and ignition.

Separately, would it be confusing for users if we supported both quat_xyzw and quat_wxyz? I don't think it would add too much parser complexity

@scpeters
Copy link
Member

Separately, would it be confusing for users if we supported both quat_xyzw and quat_wxyz? I don't think it would add too much parser complexity

To answer my own question: if we are only supporting one form of Euler angles, I think we can also pick a single form for quaternions. So I would lean towards quat_xyzw

@FirefoxMetzger
Copy link

I like the proposal. quart_xyzw (to align with ROS) works for me, too, and I agree with @scpeters that only supporting one version of quaternions for consistency is likely the better choice.

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
@azeey
Copy link
Collaborator Author

azeey commented Sep 14, 2021

Okay, I've updated the document to quat_xyzw in 6e54b94.

\cc @aaronchongth

#57)

* Add motivation for quaternions as rotation format


Signed-off-by: Steve Peters <scpeters@openrobotics.org>

Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org>
@azeey azeey merged commit 59b6b20 into master Sep 17, 2021
@azeey azeey deleted the azeey/better_pose_update branch September 17, 2021 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants