Skip to content

Support quaternions representation for poses#690

Merged
aaronchongth merged 25 commits intomainfrom
aaron/pose-quaternion-support
Sep 21, 2021
Merged

Support quaternions representation for poses#690
aaronchongth merged 25 commits intomainfrom
aaron/pose-quaternion-support

Conversation

@aaronchongth
Copy link
Copy Markdown
Collaborator

@aaronchongth aaronchongth commented Sep 7, 2021

🎉 New feature

Per proposal, http://sdformat.org/tutorials?tut=better_pose_proposal&cat=pose_semantics_docs&
Related to #252
Discussed briefly in #589

Summary

Support quaternions in the order of (x, y, z, w) for pose elements, using an new attribute //pose[@rotation_format], which is euler_rpy by default, but can be set to quat_xyzw.

  • Poses that have a quaternion representation will be expected to have 7 values instead of the usual 6.
  • Modified API for SetParentElement to return a bool in the event that the Reparse fails, for example having //pose[@degrees='true'][@rotation_format='quat_xyzw']
  • When calling functions like ToString(), the exact value string that was provided in the .sdf file is expected. If left empty, the exact default value string that was defined in sdf/1.9/*.sdf will be expected. This is the reason some tests have been modified.
  • Added tests and fixed broken tests.

These are valid poses,

<pose>1 2 3   0.4 0.5 0.6</pose>

<pose rotation_format="euler_rpy">1 2 3   0.4 0.5 0.6</pose>
      
<pose rotation_format="euler_rpy" degrees="true">1 2 3   90 180 270</pose>

<pose rotation_format="quat_xyzw">1 2 3   0.7071068 0 0 0.7071068</pose>

<pose rotation_format="quat_xyzw" degrees="false">1 2 3   0.7071068 0 0 0.7071068</pose>
      
<include>
  <uri>box</uri>
  <name>second_box</name>
  <pose rotation_format="quat_xyzw">0 10 0   0.7071068 0 0 0.7071068</pose>
</include>

These are not a valid pose,

<!--  An empty value uses the default 6-tuple, which will not make up a quaternion which expects a 7-tuple -->
<pose rotation_format="quat_xyzw"></pose>

<!-- Defining a quaternion and using degrees will cause a failure to parse too -->
<pose rotation_format="quat_xyzw" degrees="true">1 2 3   0.7071068 0 0 0.7071068</pose>

Test

source install/setup.bash
colcon test --packages-select sdformat12

Checking representations,

source install/setup.bash

ign sdf -p WORKSPACE/src/sdformat/test/sdf/pose_1_9.sdf

# includes
export SDF_PATH=WORKSPACE/src/sdformat/test/integration/model
ign sdf -p WORKSPACE/src/sdformat/test/sdf/include_pose_1_9.sdf

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge

@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Sep 7, 2021
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 7, 2021

Codecov Report

Merging #690 (70accc4) into main (3b4d136) will increase coverage by 0.08%.
The diff coverage is 94.62%.

❗ Current head 70accc4 differs from pull request most recent head 697d143. Consider uploading reports for the commit 697d143 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #690      +/-   ##
==========================================
+ Coverage   88.06%   88.14%   +0.08%     
==========================================
  Files          75       75              
  Lines       11333    11363      +30     
==========================================
+ Hits         9980    10016      +36     
+ Misses       1353     1347       -6     
Impacted Files Coverage Δ
include/sdf/Param.hh 77.14% <ø> (ø)
src/Param.cc 91.13% <93.15%> (+1.95%) ⬆️
src/Element.cc 96.82% <100.00%> (ø)
src/parser.cc 86.03% <100.00%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b4d136...697d143. Read the comment docs.

@chapulina chapulina added the beta Targeting beta release of upcoming collection label Sep 8, 2021
@aaronchongth aaronchongth force-pushed the aaron/pose-quaternion-support branch 2 times, most recently from ac7ca0a to 73a1a49 Compare September 14, 2021 06:48
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
…y pose string

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
…tation formats

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
@aaronchongth aaronchongth force-pushed the aaron/pose-quaternion-support branch from 517dcea to 3c151fa Compare September 16, 2021 17:03
@aaronchongth aaronchongth marked this pull request as ready for review September 16, 2021 17:03
@aaronchongth aaronchongth requested a review from azeey September 16, 2021 17:03
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Copy link
Copy Markdown
Collaborator

@azeey azeey left a comment

Choose a reason for hiding this comment

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

I'm getting a few test regressions in ign-physics and ign-gazebo with this PR. I can't seem to figure what's causing them though.

Comment thread sdf/1.9/pose.sdf Outdated
Comment thread src/Param.cc Outdated
Comment thread src/Param.cc
Comment thread src/Param.cc Outdated
Comment thread test/integration/default_elements.cc
Comment thread src/Param_TEST.cc
Comment thread src/parser.cc
Comment thread test/integration/pose_1_9_sdf.cc Outdated
Comment thread test/integration/pose_1_9_sdf.cc
…n description

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
@azeey
Copy link
Copy Markdown
Collaborator

azeey commented Sep 17, 2021

I'm getting a few test regressions in ign-physics and ign-gazebo with this PR. I can't seem to figure what's causing them though.

I believe some of the regressions caused by the use of ValueFromString for computing min and max values in:
https://github.com/ignitionrobotics/sdformat/blob/ea6729fbaa4915340343496f6928cb448b4620b0/src/Param.cc#L90-L100

Instead of the default value, strValue ends up having the max value since ValueFromString is called on max values last. Of course, this only affects values that have min and max constraints.

Using ValueFromStringImpl should fix the issue. You'll have to pass this->dataPtr->minValue.emplace() as the third argument because minValue would not contain any value at that call site. Same for maxValue.

The regressions in ign-gazebo on tests UNIT_SdfGenerator_TEST and INTEGRATION_save_world seem to be caused by a different issue. I see a lot of assertions with the message: "Cannot set parent Element of cloned attribute Param to cloned Element."

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
…ving hard coded default value from ValueFromStringImpl

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
…::string, used ValueFromStringImpl for min and max value

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
@aaronchongth aaronchongth force-pushed the aaron/pose-quaternion-support branch from 0b81a05 to 0fdcd97 Compare September 20, 2021 08:15
@aaronchongth
Copy link
Copy Markdown
Collaborator Author

Thanks for catching the mistakes regarding min and max values, I've corrected them in 0fdcd97. I'll continue looking into the regressions

…at don't use 1.9/pose.sdf

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
@aaronchongth
Copy link
Copy Markdown
Collaborator Author

The regressions in ign-gazebo on tests UNIT_SdfGenerator_TEST and INTEGRATION_save_world seem to be caused by a different issue. I see a lot of assertions with the message: "Cannot set parent Element of cloned attribute Param to cloned Element."

@azeey, I've managed to fix the regression tests by adding this check for the attribute, as there are some pose elements that don't support degrees and rotation_format, like actor and urdf

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
…uler_rpy

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
…he value is parsed successfully

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
…ns from previous test

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
@scpeters scpeters mentioned this pull request Sep 20, 2021
@aaronchongth aaronchongth requested a review from azeey September 20, 2021 19:30
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Copy link
Copy Markdown
Collaborator

@azeey azeey left a comment

Choose a reason for hiding this comment

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

Other than the issue below, this looks good. I propose we create an issue for it and merge this PR. @jennuine or @scpeters , do you mind taking a look at the changes I made in fcac14d

Comment thread src/Param.cc
return false;
}

std::string input = _input.empty() ? defaultValueStr : _input;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When parsing <pose />, the _input will not actually be empty, it will be the default value of //pose because in Param(), calls ValueFromString with the default string https://github.com/ignitionrobotics/sdformat/blob/fcac14d3c9359910c12fcf029eb70ca468e3220e/src/Param.cc#L76 and ValueFromString sets strValue to whatever it's input argument is:
https://github.com/ignitionrobotics/sdformat/blob/fcac14d3c9359910c12fcf029eb70ca468e3220e/src/Param.cc#L586-L593

I think this is why <pose rotation_format='quat_xyzw/>` doesn't work currently.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ticketed an issue for this #707.

@jennuine
Copy link
Copy Markdown
Collaborator

@jennuine or @scpeters , do you mind taking a look at the changes I made in fcac14d

fcac14d LGTM, left one minor nit

@scpeters
Copy link
Copy Markdown
Member

@jennuine or @scpeters , do you mind taking a look at the changes I made in fcac14d

fcac14d LGTM, left one minor nit

same, it LGTM with minor nits

Addisu Z. Taddese added 3 commits September 20, 2021 18:27
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
@azeey
Copy link
Copy Markdown
Collaborator

azeey commented Sep 21, 2021

@jennuine or @scpeters , do you mind taking a look at the changes I made in fcac14d

fcac14d LGTM, left one minor nit

Done in 1f542c4

nit: ASSERT_* statements will abort the test if they fail. I find them useful when checking that pointers aren't nullptr before dereferencing them in subsequent parts of the test, but I generally prefer EXPECT_* if a failed expectation will not cause the test to crash

so consider if ASSERT_TRUE is needed for these new expectations

I agree, I changed them to EXPECT_EQ in ae929b5

Copy link
Copy Markdown
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

just two small nits

Comment thread test/sdf/pose_1_9.sdf Outdated
Comment thread test/integration/pose_1_9_sdf.cc Outdated
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
@scpeters
Copy link
Copy Markdown
Member

I propose we create an issue for it and merge this PR.

I'll approve once we have this issue created

@scpeters
Copy link
Copy Markdown
Member

I propose we create an issue for it and merge this PR.

I'll approve once we have this issue created

thanks for opening #707.

Copy link
Copy Markdown
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

nice work!

whoever does the squash and merge, please remember the merging strategy in our process documentation involves editing the commit message in the GitHub UI to "captures the core ideas of the pull request and contains all authors' signatures". By default these messages contain lots of unnecessary details about the commit history of the pull request, rather than a succinct summary.

@aaronchongth aaronchongth merged commit ef2bc64 into main Sep 21, 2021
@aaronchongth aaronchongth deleted the aaron/pose-quaternion-support branch September 21, 2021 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta Targeting beta release of upcoming collection 🏯 fortress Ignition Fortress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants