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

Redwood noisy depth #189

Merged
merged 47 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5bbab7a
CUDA!
erikwijmans Jul 24, 2019
c461879
Add tester
erikwijmans Jul 24, 2019
12a90af
Seems to be working!
erikwijmans Jul 25, 2019
2bae50b
Add dist-model
erikwijmans Jul 25, 2019
32c448f
Ranme file
erikwijmans Jul 25, 2019
0293624
Fix and add clip
erikwijmans Jul 25, 2019
38c6994
Merge branch 'redwood-noisy-depth' of github.com:facebookresearch/hab…
erikwijmans Jul 25, 2019
9aa4d5c
Make noise models return new data always
erikwijmans Jul 25, 2019
7d1ee3b
Remove numba
erikwijmans Jul 25, 2019
9ed6e4f
Formatters
erikwijmans Jul 25, 2019
e39a759
Remove include
erikwijmans Jul 25, 2019
49ca004
Support multiple devices
erikwijmans Jul 27, 2019
47f0b3e
Merge branch 'redwood-noisy-depth' of github.com:facebookresearch/hab…
erikwijmans Jul 27, 2019
c0690a1
Change large value behavior
erikwijmans Jul 30, 2019
8ddfc35
Swap to numba implemention for CPU
erikwijmans Jul 30, 2019
c40879a
Merge branch 'master' of github.com:facebookresearch/habitat-sim into…
erikwijmans Sep 4, 2019
a1fe2ce
Reviving this
erikwijmans Sep 4, 2019
d369af4
Should be pretty much good to go!
erikwijmans Sep 4, 2019
fe71349
Whoops
erikwijmans Sep 4, 2019
0265c82
Less strange
erikwijmans Sep 4, 2019
78e0b1f
CUDA cleanup
erikwijmans Sep 4, 2019
7da6cfb
Fix sort
erikwijmans Sep 4, 2019
8c7cf43
Noise multiplier
erikwijmans Sep 4, 2019
f247a0e
Fix CI
erikwijmans Sep 4, 2019
9e4339d
Get CI to pass
erikwijmans Sep 4, 2019
7f82063
Let's try this
erikwijmans Sep 4, 2019
8041a18
This
erikwijmans Sep 4, 2019
9450dc7
That should do it
erikwijmans Sep 4, 2019
239208d
No PySensorSpec
erikwijmans Sep 5, 2019
b4a2837
Merge branch 'master' of github.com:facebookresearch/habitat-sim into…
erikwijmans Sep 18, 2019
14de723
Merge branch 'master' of github.com:facebookresearch/habitat-sim into…
erikwijmans Sep 28, 2019
61471ce
Wat
erikwijmans Sep 28, 2019
e2e70e4
Dealt with that
erikwijmans Sep 28, 2019
c0069d6
Remove unneeded lines
erikwijmans Sep 28, 2019
5e5c97b
Merge branch 'master' of github.com:facebookresearch/habitat-sim into…
erikwijmans Oct 1, 2019
98672af
Coming along
erikwijmans Oct 1, 2019
4a99950
Better doc string
erikwijmans Oct 1, 2019
4f1e737
Merge branch 'master' of github.com:facebookresearch/habitat-sim into…
erikwijmans Oct 4, 2019
6d3277c
Remove tmp.py
erikwijmans Oct 4, 2019
e3b935b
Merge branch 'master' of github.com:facebookresearch/habitat-sim into…
erikwijmans Oct 10, 2019
bf7ffcf
Address comments
erikwijmans Oct 10, 2019
83ac606
Add formatting and explicit
erikwijmans Oct 11, 2019
93834d3
Merge branch 'master' of github.com:facebookresearch/habitat-sim into…
erikwijmans Oct 22, 2019
7598a3c
Merge branch 'redwood-noisy-depth' of github.com:facebookresearch/hab…
erikwijmans Oct 22, 2019
6e0b694
Add comments
erikwijmans Oct 22, 2019
0a8bc5a
Add pass-through
erikwijmans Oct 22, 2019
1d31881
Merge branch 'master' of github.com:facebookresearch/habitat-sim into…
erikwijmans Nov 2, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ jobs:
- run:
name: run clang-format
command: |
find . -not -path "*/\.*" -not -path "*/deps/*" -not -path "*/obsolete/*" -not -path "*/build/*" | grep -E ".*\.cpp$|.*\.h$|.*\.cu$|.*\.hpp$" | xargs -I {} bash -c "diff -u <(cat {}) <(clang-format -style=file {})"
find . -not -path "*/\.*" -not -path "*/deps/*" -not -path "*/obsolete/*" -not -path "*/build/*" | grep -E ".*\.(cpp|h|cu|hpp|cuh)$" | xargs -I {} bash -c "diff -u <(cat {}) <(clang-format -style=file {})"

js_lint:
docker:
- image: circleci/node:11.9
Expand Down Expand Up @@ -236,13 +237,13 @@ jobs:
name: Run sim benchmark
command: |
while [ ! -f ./cuda_installed ]; do sleep 2; done # wait for CUDA
export PATH=$HOME/miniconda/bin:$PATH
export PATH=$HOME/miniconda/bin:/usr/local/cuda/bin:$PATH
. activate habitat; cd habitat-sim
python examples/example.py --scene data/scene_datasets/habitat-test-scenes/van-gogh-room.glb --silent --test_fps_regression $FPS_THRESHOLD
- run:
name: Run sim tests
command: |
export PATH=$HOME/miniconda/bin:$PATH
export PATH=$HOME/miniconda/bin:/usr/local/cuda/bin:$PATH
. activate habitat; cd habitat-sim

export PYTHONPATH=$PYTHONPATH:$(pwd)
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ run_example
*.swp

tests/17DRP5sb8fy
data/
/data/
*.zip
habitat_sim/_ext
build_js/
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
name: Run clang-format
entry: clang-format -i -style=file
types: [text]
files: '.*\.cpp|.*\.h'
files: '.*\.(cpp|h|hpp|cu|cuh)$'
language: system

- repo: https://github.com/pre-commit/mirrors-eslint
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
graft habitat_sim/sensors/noise_models/data
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
FAVICON = "habitat-blue.png"
MAIN_PROJECT_URL = "/"
INPUT_MODULES = [habitat_sim]
INPUT_DOCS = ["docs.rst", "gfx.rst"]
INPUT_DOCS = ["docs.rst", "gfx.rst", "noise_models.rst"]
INPUT_PAGES = [
"pages/index.rst",
"pages/new-actions.rst",
Expand Down
53 changes: 53 additions & 0 deletions docs/noise_models.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.. py:module:: habitat_sim.sensors.noise_models
:summary: Library of Sensor noise models


A library of noise models to close the gap between simulated observations
and observations from real sensors.

A noise model can be applied to a sensor by specifying the name of the noise
model in the `sensor.SensorSpec.noise_model` feild.
Arguments can be passed to the noise model constructor as keyword arguments using
the `sensor.SensorSpec.noise_model_kwargs` field. For instance, to use the `RedwoodDepthNoiseModel`
with a ``noise_multiplier`` of 5

.. code:: py

sensor_spec.noise_model = "RedwoodDepthNoiseModel"
sensor_spec.noise_model_kwargs = dict(noise_multiplier=5)



These noise models are commonly the result of contributions from various research projects.
If you use a noise model in your research, please cite the relevant work specified by the docummentation


**Depth Noise Models**

* Redwood Noise Model for PrimSense depth cameras: `RedwoodDepthNoiseModel`

.. py:class:: habitat_sim.sensors.noise_models.NoSensorNoiseModel
:summary: No noise noise model. Simply returns a copy of the input

Accessible from the registry under the name ``"None"``

.. py:class:: habitat_sim.sensors.noise_models.RedwoodDepthNoiseModel
:summary: Redwood Noise Model for PrimSense depth cameras

Accessible from the registry under the name ``"RedwoodDepthNoiseModel"``

Implements the noise model provided by http://redwood-data.org/indoor/dataset.html

If you use this noise model, please cite::

@inproceedings{choi2015robust,
erikwijmans marked this conversation as resolved.
Show resolved Hide resolved
title={Robust reconstruction of indoor scenes},
author={Choi, Sungjoon and Zhou, Qian-Yi and Koltun, Vladlen},
booktitle={Proceedings of the IEEE Conference on Computer Vision and
Pattern Recognition}, pages={5556--5565}, year={2015}
}


.. py:function:: habitat_sim.sensors.noise_models.RedwoodDepthNoiseModel.__init__
:param gpu_device_id: The ID of CUDA device to use (only applicable if habitat-sim was built with ``--with-cuda``)
:param noise_multiplier: Multipler for the Guassian random-variables. This reduces or increase the amount of noise
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo Guassian -> Gaussian; increase -> increases

2 changes: 1 addition & 1 deletion habitat_sim/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import habitat_sim.bindings as hsim
import habitat_sim.errors
from habitat_sim.sensors import SensorSuite
from habitat_sim.sensors.sensor_suite import SensorSuite
from habitat_sim.utils.common import (
quat_from_coeffs,
quat_from_magnum,
Expand Down
46 changes: 41 additions & 5 deletions habitat_sim/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import re
from typing import Optional, Type

from habitat_sim.agent.controls import SceneNodeControl

__all__ = ["registry"]


Expand Down Expand Up @@ -37,12 +35,12 @@ class _Registry:
@classmethod
def register_move_fn(
cls,
controller: Optional[Type[SceneNodeControl]] = None,
controller: Optional[Type] = None,
*,
name: Optional[str] = None,
body_action: bool = None,
):
r"""Registers a new control with Habitat-Sim. Registered conrtols can
r"""Registers a new control with Habitat-Sim. Registered controls can
then be retrieved via `get_move_fn()`

See `new-actions <new-actions.html>`_ for an example of how to add new actions
Expand All @@ -62,6 +60,7 @@ def register_move_fn(
assert (
body_action is not None
), "body_action must be explicitly set to True or False"
from habitat_sim.agent.controls.controls import SceneNodeControl

def _wrapper(controller: Type[SceneNodeControl]):
assert issubclass(
Expand All @@ -79,17 +78,54 @@ def _wrapper(controller: Type[SceneNodeControl]):
else:
return _wrapper(controller)

@classmethod
def register_noise_model(
cls, noise_model: Optional[Type] = None, *, name: Optional[str] = None
):
r"""Registers a new sensor noise model with Habitat-Sim

:param noise_model: The class of the noise model to register
If `None`, will return a wrapper for use with decorator syntax
:param name: The name to register the noise model with
If `None`, will register with the name of the noise_model
"""
from habitat_sim.sensors.noise_models.sensor_noise_model import SensorNoiseModel

def _wrapper(noise_model: Type[SensorNoiseModel]):
assert issubclass(
noise_model, SensorNoiseModel
), "All noise_models must inherit from habitat_sim.sensor.SensorNoiseModel"

cls._mapping["sensor_noise_model"][
noise_model.__name__ if name is None else name
] = noise_model

return noise_model

if noise_model is None:
return _wrapper
else:
return _wrapper(noise_model)

@classmethod
def _get_impl(cls, _type, name):
return cls._mapping[_type].get(name, None)

@classmethod
def get_move_fn(cls, name: str) -> SceneNodeControl:
def get_move_fn(cls, name: str):
r"""Retrieve the move_fn register under ``name``

:param name: The name provided to `register_move_fn`
"""
return cls._get_impl("move_fn", name)

@classmethod
def get_noise_model(cls, name: str):
r"""Retrieve the noise_model register under ``name``
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo: register -> registered


:param name: The name provided to `register_noise_model`
"""
return cls._get_impl("sensor_noise_model", name)


registry = _Registry()
4 changes: 3 additions & 1 deletion habitat_sim/sensors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from habitat_sim.sensors import noise_models

from .sensor_suite import SensorSuite

__all__ = ["SensorSuite"]
__all__ = ["SensorSuite", "noise_models"]
35 changes: 35 additions & 0 deletions habitat_sim/sensors/noise_models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3

# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import Any, Dict

from habitat_sim.registry import registry
from habitat_sim.sensors.noise_models.no_noise_model import NoSensorNoiseModel
from habitat_sim.sensors.noise_models.redwood_depth_noise_model import (
RedwoodDepthNoiseModel,
)
from habitat_sim.sensors.noise_models.sensor_noise_model import SensorNoiseModel


def make_sensor_noise_model(name: str, kwargs: Dict[str, Any]) -> SensorNoiseModel:
r"""Constructs a noise model using the given name and keyword arguments

:param name: The name of the noise model in the `habitat_sim.registry`
:param kwargs: The keyword arguments to be passed to the constructor of the noise model
"""

model = registry.get_noise_model(name)
assert model is not None, "Could not find a noise model for name '{}'".format(name)

return model(**kwargs)


__all__ = [
"make_sensor_noise_model",
"SensorNoiseModel",
"RedwoodDepthNoiseModel",
"NoSensorNoiseModel",
]
Binary file not shown.
23 changes: 23 additions & 0 deletions habitat_sim/sensors/noise_models/no_noise_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3

# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

import numpy as np

from habitat_sim.registry import registry
from habitat_sim.sensors.noise_models.sensor_noise_model import SensorNoiseModel


@registry.register_noise_model(name="None")
class NoSensorNoiseModel(SensorNoiseModel):
@staticmethod
def is_valid_sensor_type(sensor_type):
return True

def apply(self, x):
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this Noise Model that is producing copying? maybe we can just miss applying any noise model if it wasn't specified.

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 had a copy before-hand, so I just rolled the copy into this as it felt cleaner to always apply a noise model and have a no-noise model which just returns a copy.

if isinstance(x, np.ndarray):
return x.copy()
else:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to check for cases where x has a type with no clone() defined? e.g. scalar-valued sensors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a check to see if x is a torch tensor.

return x.clone()
Loading