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

PhysicsManager CHECK cleanup #305

Merged
merged 3 commits into from
Oct 16, 2019
Merged

PhysicsManager CHECK cleanup #305

merged 3 commits into from
Oct 16, 2019

Conversation

aclegg3
Copy link
Contributor

@aclegg3 aclegg3 commented Oct 16, 2019

Motivation and Context

This PR replaces if statements in PhysicsManager and BulletPhysicsManager based on the validity of object IDs with CHECK().

As @msbaines mentioned in a review for PR #237, PhysicsManager functions taking an object ID as input should not fail silently when an invalid object ID is provided. This may allow hidden bugs to crop up. For example: setting a force or torque on an object which does not exist and then receiving no indication that the set failed resulting in extended debugging. Instead, such an invalid set should be fatal and produce a clear error message.

How Has This Been Tested

Local testing.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@aclegg3 aclegg3 requested a review from msbaines October 16, 2019 16:44
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Oct 16, 2019
Copy link
Contributor

@msbaines msbaines left a comment

Choose a reason for hiding this comment

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

You may want to consider using a helper so that the CHECK is in one place.

LOG(ERROR) << "Failed to remove object: no object with ID " << physObjectID;
return ID_UNDEFINED;
}
assertIDValidity(physObjectID);
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 object destructor call removeObject()? That way you never forget to call it.
delete should be avoid and RTTI used instead. Could we use unique_ptr instead here? The last three lines would then boil down to:

existingObjects_.erase(physObjectID);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comes back to the SceneNode problem. SceneNode objects are owned completely by the SceneGraph. I have not gotten around to converting RigidObject from a SceneNode to an AbstractFeature3D as suggested in reviews for PR #91 . We use raw pointers to denote that PhysicsManager does not own the RigidObject.

That said, the removal process could probably be improved. I'll lump that in with the AbstractFeature3D re-design.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't own the object, why are we calling delete on it below on line 89?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have to remove the SceneNode from the SceneGraph when the object no longer exists. I agree the current situation is not entirely self-consistent. The simulator was not initially designed for this sort of dynamic restructuring.

@aclegg3 aclegg3 merged commit 67a0ddb into master Oct 16, 2019
@aclegg3 aclegg3 deleted the physicsmanager-check-cleanup branch October 16, 2019 20:10
eundersander pushed a commit to eundersander/habitat-sim that referenced this pull request Aug 6, 2020
…tation. (facebookresearch#305)

* Integrated RGB noises
* Integrated Depth noise
* Added PyRobot noisy actuations action space
* Integrated initial camera orientation
* Updated objectnav_mp3d.yaml config
* Improved overwrite_config to decrease code duplication
* Added fix to respect CONTENT_SCENES for habitat baselines training
Ram81 pushed a commit to Ram81/habitat-web-sim that referenced this pull request Dec 10, 2020
* replace if statements with CHECK for PhysicsManager and BulletPhysicsManager instead of failing silently
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants