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

Python viewer #1519

Merged
merged 24 commits into from
Oct 12, 2021
Merged

Python viewer #1519

merged 24 commits into from
Oct 12, 2021

Conversation

JuanTheEngineer
Copy link
Contributor

@JuanTheEngineer JuanTheEngineer commented Oct 5, 2021

Motivation and Context

  • Clean up Python Viewer
  • Enrich the viewer application with some additional features and utilities. For example, features of interest may include:
    • moving the camera with keyboard and mouse
    • reloading the scene
    • run and pause simulations
    • load ReplicaCAD data sets

All features can be seen in help text.

Previous PRs: 727 & 1056

How Has This Been Tested

In order to run the viewer, you must use the commands below.

  1. Build Habitat-Sim
# build habitat with bullet physics
python setup.py install --bullet
# or
./build.sh --bullet

# Add habitat-sim to PYTHONPATH
export PYTHONPATH=$(pwd)
  1. Run Habitat-Sim
# Example structure
python examples/viewer.py --scene [SCENE] --dataset [DATASET]

# Example with ReplicaCAD
python examples/viewer.py --dataset /path/to/data/versioned_data/replica_cad_dataset_1.1/replicaCAD.scene_dataset_config.json --scene apt_0
  1. Commands
# For args help
python examples/viewer.py -h

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.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Oct 5, 2021
@dhruvbatra
Copy link
Contributor

Very cool. I was able to test and reproduce on a mac with building from source.

However, it only works with ./build.sh --bullet. If I build using python setup.py install --bullet, I see the following error (which is likely not related to your PR):

Traceback (most recent call last):
  File "examples/viewer.py", line 1, in <module>
    from magnum import gl
  File "/Users/dbatra/miniconda3/envs/habitat-src/lib/python3.6/site-packages/magnum/__init__.py", line 28, in <module>
    from _magnum import *
ImportError: dlopen(/Users/dbatra/miniconda3/envs/habitat-src/lib/python3.6/site-packages/_magnum.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libMagnum.2.dylib
  Referenced from: /Users/dbatra/miniconda3/envs/habitat-src/lib/python3.6/site-packages/_magnum.cpython-36m-darwin.so
  Reason: image not found

@Skylion007
Copy link
Contributor

Skylion007 commented Oct 6, 2021

@JuanTheEngineer Pulling from master should resolve the CI CA issues.

src/cmake/dependencies.cmake Outdated Show resolved Hide resolved
@Skylion007
Copy link
Contributor

Skylion007 commented Oct 6, 2021

@JuanTheEngineer You also need to run pre-commit on this PR for proper formatting + linting. pre-commit run -a

@aclegg3
Copy link
Contributor

aclegg3 commented Oct 6, 2021

Very cool. I was able to test and reproduce on a mac with building from source.

However, it only works with ./build.sh --bullet. If I build using python setup.py install --bullet, I see the following error (which is likely not related to your PR):

Yes, this is related to the issue @Skylion007 mentioned. For now ./build.sh --bullet with dynamic linking is the workaround.

@JuanTheEngineer thanks for the thorough instructions in the testing section. Maybe add a line that building with setup.py isn't working for now also.

examples/viewer.py Outdated Show resolved Hide resolved
examples/viewer.py Show resolved Hide resolved
examples/viewer.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@mosra mosra left a comment

Choose a reason for hiding this comment

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

Once #1529 is merged, these two changes should allow you to resize the window. However, viewer.cpp's viewportEvent() has a lot of code to resize all existing framebuffers and I'm not sure how/if these are exposed to Python. So it's possibly not even implementable at this point.

examples/viewer.py Show resolved Hide resolved
examples/viewer.py Show resolved Hide resolved
examples/viewer.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Skylion007 Skylion007 left a comment

Choose a reason for hiding this comment

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

Instead rebasing, you may just want to pull from main next time as it would also make reviewing this PR a bit easier.

examples/viewer.py Outdated Show resolved Hide resolved
Copy link
Contributor

@aclegg3 aclegg3 left a comment

Choose a reason for hiding this comment

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

Looks good, almost ready. A couple of notes from our chat.

examples/viewer.py Outdated Show resolved Hide resolved
examples/viewer.py Outdated Show resolved Hide resolved
Comment on lines +199 to +202
action_queue: List[str] = [act[k] for k, v in press.items() if v]

for _ in range(int(repetitions)):
[agent.act(x) for x in action_queue]
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this reduction. 👍

Copy link
Contributor

@aclegg3 aclegg3 left a comment

Choose a reason for hiding this comment

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

Looks good. Let's merge it. 🥳

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

7 participants