-
Notifications
You must be signed in to change notification settings - Fork 404
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
Redwood noisy depth #189
Conversation
…itat-sim into redwood-noisy-depth
…itat-sim into redwood-noisy-depth
… redwood-noisy-depth
200k?!! Damn. Are those two images w/ and w/o noise? Request -- is it easy to show images with varying levels of noise? (Or is that not feasible for this noise type?) |
Yes they are :)
We could make that doable with this noise model. There are two different Gaussian that are sampled from and I could make the variance on those changeable. |
… redwood-noisy-depth
… redwood-noisy-depth
… redwood-noisy-depth
… redwood-noisy-depth
This is ready for review. |
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.
That's really important step towards sim2real direction. Reviewed all the PR except details of redwood noise model implementations. Noise model registration pattern looks appealing.
Thank you for creating both CPU & GPU versions. Overall looks good to go, some minor comments.
def is_valid_sensor_type(sensor_type): | ||
return True | ||
|
||
def apply(self, x): |
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.
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.
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.
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.
else: | ||
# Distort | ||
undistorted_d = _undistort( | ||
int(x / xmax * 639.0 + 0.5), int(y / ymax * 479.0 + 0.5), d, model |
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.
If there is a meaning behind all the constants in this method., let's give them reasonable names. That can help to adopt noise for specific camera type/sim2real setup later.
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.
480x640 is the resolution of the sensor used to create the distortion model originally. This logic just rescales any given observation to 480x640 so that it can query the distortion model.
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 think adding a brief comment to this effect in the code would be helpful for readability
pass | ||
|
||
@abc.abstractmethod | ||
def apply(self, sensor_observation): |
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.
def apply(self, sensor_observation): | |
def apply(self, sensor_observation) -> Observations: |
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 don't believe we have a generic Observations
type currently defined.
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 we expose to python and flesh out Observation
from the C++ side? (Bringing this up here, but it likely makes sense to create a separate issue & PR for that)
@@ -391,7 +398,7 @@ def get_observation(self): | |||
else: | |||
tgt.read_frame_rgba_gpu(self._buffer.data_ptr()) | |||
|
|||
return self._buffer.flip(0).clone() |
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.
Got it, you moved copying logic to NoNoise
. Still will copying/cloning be valid for all types of sensors?
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.
For all visual sensors, yes. This current sensor class is really for just visual sensors. When we introduce other sensors, I would imagine those will have their own separate python wrapper.
… redwood-noisy-depth
… redwood-noisy-depth
…itat-sim into redwood-noisy-depth
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.
Awesome to see sensor noise models coming in! 👍LGTM in general, left a few minor comments about typos and readability.
docs/noise_models.rst
Outdated
|
||
.. 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 |
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.
typo Guassian
-> Gaussian
; increase
-> increases
habitat_sim/registry.py
Outdated
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`` |
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.
typo: register
-> registered
def apply(self, x): | ||
if isinstance(x, np.ndarray): | ||
return x.copy() | ||
else: |
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.
Do we need to check for cases where x
has a type with no clone()
defined? e.g. scalar-valued sensors
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.
Added a check to see if x
is a torch tensor.
|
||
|
||
@numba.jit(nopython=True) | ||
def _undistort(x, y, z, model): |
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.
Here it would be nice to have a succinct comment describing the undistortion model being used (or at least a pointer to the original description of this in Redwood). This will help others to understand the variable names below.
else: | ||
# Distort | ||
undistorted_d = _undistort( | ||
int(x / xmax * 639.0 + 0.5), int(y / ymax * 479.0 + 0.5), d, model |
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 think adding a brief comment to this effect in the code would be helpful for readability
pass | ||
|
||
@abc.abstractmethod | ||
def apply(self, sensor_observation): |
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 we expose to python and flesh out Observation
from the C++ side? (Bringing this up here, but it likely makes sense to create a separate issue & PR for that)
const int MODEL_N_DIMS = 5; | ||
const int MODEL_N_COLS = 80; | ||
|
||
__device__ float undistort(const int _x, |
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.
Similar comment as above regarding a quick pointer to aid readability of the implementation.
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 added the link, http://www.alexteichman.com/octo/clams/ but that doesn't really help the implementation read-ability. I just took the code from here: http://redwood-data.org/indoor/data/simdepth.py and made it not slow.
src/esp/sensor/RedwoodNoiseModel.h
Outdated
* @brief Constructor | ||
* @param model The distortion model from | ||
* http://redwood-data.org/indoor/data/dist-model.txt | ||
* The 3rd dimensions is assumed to have been |
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.
typo: dimensions
-> dimension
src/esp/sensor/RedwoodNoiseModel.h
Outdated
|
||
/** | ||
* @brief Simulates noisy depth from clean depth. The input is assumed to be | ||
* on the CPU and the output will be on the CPU |
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.
Maybe add: what happens if assumption does not hold?
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.
Bad things happen. Segfaults happen :)
src/esp/sensor/RedwoodNoiseModel.h
Outdated
|
||
/** | ||
* @brief Similar to @ref simulateFromCPU() but the input and output are | ||
* assumed to be on the GPU |
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.
Maybe add: what happens if assumption does not hold?
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.
Bad things happen. Segfaults happen :)
Add depth noise model!
Motivation and Context
Adds the noise model from here: http://redwood-data.org/indoor/dataset.html
There are 2 implementations:
@msavva @bigbike @mosra What are your thoughts on how I am currently providing arguments to the sensor noise models? I just added a
py::dict
to the python binding of the sensor spec so that people can pass arbitrary arguments in it.TODO
py::dynamic_attr()
tmp.py
file. That has just been useful for testing :)How Has This Been Tested
Via the tests and visually!
Types of changes