-
Notifications
You must be signed in to change notification settings - Fork 41
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 Gravity Feature, fix LinkFeatures_TEST #275
Add Gravity Feature, fix LinkFeatures_TEST #275
Conversation
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Codecov Report
@@ Coverage Diff @@
## ign-physics4 #275 +/- ##
================================================
- Coverage 75.40% 75.30% -0.11%
================================================
Files 125 125
Lines 5433 5463 +30
================================================
+ Hits 4097 4114 +17
- Misses 1336 1349 +13
Continue to review full report at Codecov.
|
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.
How about adding unit tests to WorldFeatures_TEST
?
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.
LGTM! Thanks for adding this feature.
include/ignition/physics/World.hh
Outdated
/// \brief Implementation API for setting the gravity vector, which is | ||
/// expressed in the World frame.. | ||
/// \param[in] _id Identity of the world. | ||
/// \param[in] _gravity Name of gravity. |
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.
nit: "Name"->"Value"?
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.
include/ignition/physics/World.hh
Outdated
/// (a quantity that contains information about the coordinates | ||
/// in which it is expressed). | ||
/// \return Relative Gravity vector. | ||
public: RelativeGravityType GetGravity() const; |
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.
it now occurs to me that the two GetGravity
functions will be confusing for compilers since they can both be called with no arguments and have different return types. I'm inclined to remove this one that returns RelativeGravityType
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.
It's weird that the compiler doesn't catch this. I'd also vote for removing the function that returns RelativeGravityType
.
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.
removed in 7fa6ab2
dartsim/src/LinkFeatures_TEST.cc
Outdated
|
||
TestWorldPtr world = _engine->ConstructWorld(*sdfWorld); | ||
EXPECT_NE(nullptr, world); | ||
world->SetGravity(_gravity); |
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.
Can you add an expectation on GetGravity
just to exercise the API?
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.
I had intended to do that, but then I realized that I would need to move the AssertVectorApprox
class definition up above this function in order to use it in the expectation. So I stalled out on doing it. I'll do it now though
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.
done in ef1012d
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
done in 315424c |
Requires moving definition of AssertVectorApprox Signed-off-by: Steven Peters <scpeters@openrobotics.org>
// Get default gravity in link frame, which is pitched by pi/4 | ||
EXPECT_PRED_FORMAT2(vectorPredicate10, | ||
Eigen::Vector3d(6.92964645563, 0, -6.92964645563), | ||
world->GetGravity(linkFrameID)); |
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.
somehow this call to GetGravity
is causing an assertion in KinematicsFeatures.cc
related to call to detail::Resolve
in detail/World.hh
:
I think we should relax the assertion, unless I'm going something wrong here
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.
I've disabled the assertion in 37d09ae
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.
I'm not sure if it hurts to ask the world frame what it's frame data is. Could be a problem for some physics engines? Looking at the code https://github.com/ignitionrobotics/ign-physics/blob/37d09ae717292623e6c1345efb26f66e458b0275/include/ignition/physics/detail/FrameSemantics.hh#L58-L62, maybe we should set currentCoordinates = RotationType::Identity();
if the _relativeTo
is the world frame, as is done a couple of lines below.
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.
ooh, that's smart. I could leave the assert unchanged that way
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.
I've reverted the removal of the assert and followed your suggestion in 12b4cd4
Signed-off-by: Steven Peters <scpeters@openrobotics.org>
This reverts commit 37d09ae. Signed-off-by: Steven Peters <scpeters@openrobotics.org>
Avoid calling FrameDataRelativeToWorld for quantities relative to the world frame but expressed in different coordinates. This prevents an assertion in KinematicsFeatures.cc Signed-off-by: Steven Peters <scpeters@openrobotics.org>
🎉 New feature
This adds a feature for getting and setting the gravity vector in a
World
. This was motivated by a failing test in #261.Summary
The LinkFeatures_TEST currently loads an
sdf::World
object then copies it in order to modify the<gravity/>
SDFormat element, with a comment noting "// TODO Add a world property feature to set gravity instead of this hack". Inignition-physics3
and earlier, this was a useful hack, but it doesn't work inignition-physics4
due to an internal change inlibsdformat11
. I've illustrated the problem by adding some failing test expectations in e270f65 that callsdf::World::ValidateGraphs
. Loading thesdf::World
from ansdf::ElementPtr
does not work anymore; you have to load ansdf::Root
in order for theFrameAttachedToGraph
andPoseRelativeToGraph
to be properly loaded. I believe this is also related to the test failures observed in #261.To fix the issue, I've added
World::GetGravity
andWorld::SetGravity
APIs in a newGravity
Feature inWorld.hh
(94048ea). The APIs use
FrameSemantics.hh
so you can specify theFrameID
for the coordinates in which the gravity vector is specified. I then updated theLoadWorld
function inLinkFeatures_TEST
in ec232ac so it can load the world properly. I removed theLoadWorld
function fromShapeFeatures_TEST
in 573f001 since it has the same flaw but is unused.Test it
Compile the code as of e270f65 and observe the failure of
UNIT_LinkFeatures_TEST
, and then observe that the test passes with the tip of the branch.Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge