-
Notifications
You must be signed in to change notification settings - Fork 419
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
Attach SceneNode to simulation #492
Conversation
… a physical object's SceneNode heirarchy. Enabled simple deletion of visualNode_ when detaching SceneNode from PhysicsManager without deleting the node.
Codecov Report
@@ Coverage Diff @@
## master #492 +/- ##
==========================================
+ Coverage 61.04% 61.23% +0.19%
==========================================
Files 164 164
Lines 7500 7538 +38
Branches 84 84
==========================================
+ Hits 4578 4616 +38
Misses 2922 2922
Continue to review full report at Codecov.
|
/** | ||
* @brief All Drawable components are children of this node. | ||
*/ | ||
scene::SceneNode* visualNode_ = nullptr; |
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.
any reason this is public versus having a getter (like node()
)?
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.
Reasoning: Currently, PhysicsManager
needs access to these pointers and they can be null, so references aren't ideal. The getters would then be for raw pointer anyway. Users should not be getting direct access to a RigidObject to manipulate these, so I left them at public.
@@ -408,3 +408,52 @@ TEST_F(PhysicsManagerTest, TestVelocityControl) { | |||
ASSERT_EQ(physicsManager_->getAngularVelocity(objectId), Magnum::Vector3{}); | |||
} | |||
} | |||
|
|||
TEST_F(PhysicsManagerTest, TestSceneNodeAttachment) { |
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.
From now on, suggest using Corrade::TestSuite.
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.
Yes but definitely in a separate PR :)
The new test doesn't do anything that would strongly benefit from switching to TestSuite, so I'm fine with keeping it in gtest and rewriting with TestSuite later.
|
||
esp::assets::PhysicsObjectAttributes physicsObjectAttributes; | ||
physicsObjectAttributes.setString("renderMeshHandle", objectFile); | ||
resourceManager_.loadObject(physicsObjectAttributes, objectFile); |
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.
Underscore is not needed.
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 is a call to PhysicsManagerTest::resourceManager_
, so underscore is needed. Did I miss your meaning?
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.
Oh, I see. This is the member variable of the class PhysicsManagerTest.
My bad.
@@ -88,21 +91,27 @@ int PhysicsManager::addObject(const int objectLibIndex, | |||
|
|||
int PhysicsManager::addObject(const std::string& configFile, | |||
DrawableGroup* drawables, | |||
scene::SceneNode* attachmentNode, |
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.
May I understand why this argument is a must have?
Can we just create a scene object within addObject(...), and thus hide this detail to the user?
I did not see any usage case in this PR that leverage this argument. The only caller (in Simulator.cpp) just passed a nullptr.
Did I miss the big picture 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 pushed this into python and wrote a test case in test_physics.py to demonstrate the usage. This PR is really to address the visual/simulated agent problems. An Agent SceneNode
can be passed to addObject
to use that node instead of generating a new one.
|
||
esp::assets::PhysicsObjectAttributes physicsObjectAttributes; | ||
physicsObjectAttributes.setString("renderMeshHandle", objectFile); | ||
resourceManager_.loadObject(physicsObjectAttributes, objectFile); |
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.
Oh, I see. This is the member variable of the class PhysicsManagerTest.
My bad.
* Add SceneNode attachment option to addObject and makeRigidObject. * Added RigidObject::visualNode_ to clearly separate Drawable branch of a physical object's SceneNode hierarchy. * Enabled optional deletion of visualNode_ and object SceneNode hierarchy when removing objects from PhysicsManager. * Added python bindings and unit tests in python and C++.
* typed Habitat Core * Fix more habitat typing issues * Fix objnav typecheck * Fix incorrect config type * complete habitat lab mypy conversion * Migrate mypy config to mypy.ini * Remove unused mypy config values * Re-enable episodes setter * Finish typing habitat_baselines * Stricten type hints in habitat.core.simulator * Fix registry type add constructor to Simulator * Fix import error * Make max singleton * Remove list copy * Update mypy with global ignores * Do better list casting * Update pre-commit hooks * unify pre-commit style * Add check-yaml pre-commit hook * Bugfix and optimize ci tests * Remove one more type ignore * Update habitat_baselines/rl/ppo/ppo.py * Fix ppo imports * remove dead code * Revert "remove dead code" This reverts commit acf9fd8c3e7f7989137ad54eaacab158c23dd1b4.
Motivation and Context
This change enables an existing SceneNode to be attached to a newly instanced physics object. Also enables removal of objects from simulation while deleting either the object's full SceneNode structure, the visual component only, or nothing.
This enables rendering of embodied agents (#332) and continuous control of an Agent's state via
PhysicsManager
functions.Added python bindings for this functionality.
How Has This Been Tested
C++ and python unit tests
and new viewer demo option to attach/detach the agent to/from physics withEdit: viewer demo shown below removed to keep things clean, but functionality is the same.'p'
. While attached to an object,'w','a','s','d'
command dynamic linear velocity of the attached object (instead of navmesh discrete control of the agent) andLEFT|RIGHT
command local angular velocity (+-Y axis).Example - agent attachment to a can with user controlled rolling:
Example - agent attachment to a locobot with user control:
Types of changes
Checklist