[Sensor] Hierarchical Sensor spec#1090
Conversation
…1064) - Create a factory class SensorFactory, which contains a static method to return a SensorSuite given a reference to a - - SceneNode and reference to a vector of SensorSpec::ptrs called SensorSetup. - Add method SensorSuite::merge to merge the sensors from another SensorSuite into its existing map of sensors - SensorFactory is called in Simulator::AddAgent to provide sensors. - Add method Simulator::addSensorToObject to add a sensor at a node, given the node's objectId and the specification of the sensor - Add tests in SimTest and SensorTest
…1064) - Create a factory class SensorFactory, which contains a static method to return a SensorSuite given a reference to a - - SceneNode and reference to a vector of SensorSpec::ptrs called SensorSetup. - Add method SensorSuite::merge to merge the sensors from another SensorSuite into its existing map of sensors - SensorFactory is called in Simulator::AddAgent to provide sensors. - Add method Simulator::addSensorToObject to add a sensor at a node, given the node's objectId and the specification of the sensor - Add tests in SimTest and SensorTest
| if (spec->sensorType == SensorType::Color) { | ||
| if (spec->sensorSubType == SensorSubType::Pinhole || | ||
| spec->sensorSubType == SensorSubType::Orthographic) { | ||
| sensorSuite.add(sensor::CameraSensor::create(sensorNode, spec)); |
There was a problem hiding this comment.
We need appropiate errors here.
0293edb to
171a01e
Compare
| "SensorSpec::sanityCheck(): position is illegal", ); | ||
| CORRADE_ASSERT((abs(orientation.array()) >= 0).any(), | ||
| "SensorSpec::sanityCheck(): orientation is illegal", ); | ||
| CORRADE_ASSERT(!noiseModel.empty(), |
There was a problem hiding this comment.
Are you sure noise model is a must have?
| isVisualSensor, | ||
| "VisualSensorSpec::sanityCheck(): sensorType must be Color, Depth, " | ||
| "Normal, or Semantic", ); | ||
| if (noiseModel == "Gaussian" || noiseModel == "Poisson" || |
There was a problem hiding this comment.
I am not sure if noise model is a must have, but I see in hab-lab that there are sensors which use the noise model (seems like only visual sensors though). @Skylion007 what do you think we should do here?
These checks in the VisualSensorSpec mirror checks on they python side.
There was a problem hiding this comment.
Yili, I think your question is whether we want noiseModel to be an attribute of SensorSpec or VisualSensorSpec, (and not to get rid of noiseModel in all SensorSpecs) right? Since for nonVisualSensorSpecs noiseModel will always be None. Let me know if this is what you're asking.
There was a problem hiding this comment.
Ok, from discussion in hab-sim dev sync we want to keep the attribute in SensorSpec because we anticipate that future non-visual sensor specs will want to add a noiseModel
There was a problem hiding this comment.
I think we should keep the checks for noiseModel in SanityCheck because it would be nice to have for C++ and js, but let me know if you would like them removed because of redundancy on the python side.
There was a problem hiding this comment.
All the noise models are in Pure Python now, it would be a good idea to move them to C++ if performance warrants it though.
Skylion007
left a comment
There was a problem hiding this comment.
Else issues in python
| "noiseModel is Gaussian, Poisson, SaltAndPepper, or Speckle", ); | ||
| } | ||
| if (noiseModel == "Redwood") { | ||
| CORRADE_ASSERT( |
There was a problem hiding this comment.
Can these noise models even be used from C++?
There was a problem hiding this comment.
So far I did not see the noise models were used anywhere in the C++, but maybe I am wrong.
I think we can keep the sanity check like this since it is coded up. It can be easily modified in the future.
But we need to make sure the logic is correct at least. For example, when "redwood" is noise model, the sensor type must be depth sensor.
|
Thanks @bigbike and @Skylion007 I've addressed all your feedback except the point regarding noiseModel. I understand it's not used in C++ but we are deciding to keep the attribute in SensorSpec, and anticipate that one day we want to include it in C++. Could you confirm/deny that we want to remove the sanityChecks for noiseModel in this PR? |
erikwijmans
left a comment
There was a problem hiding this comment.
This is very nice! Thank you for all the work @vauduong
| */ | ||
| void setFar(float _far) { | ||
| spec_->parameters.at("far") = std::to_string(_far); | ||
| CORRADE_ASSERT( |
There was a problem hiding this comment.
@vauduong :
This is something we did not capture.
"near" and "far" should be in the VisualSensor spec! They were in the spec before refactoring.
Then member variables, far_ and near_ should be removed.
Please do fix it in another PR.
There was a problem hiding this comment.
@vauduong : Also, please lift up the
bool getObservation(sim::Simulator& sim, Observation& obs) override;
bool getObservationSpace(ObservationSpace& space) override;
from CameraSensor to VisualSensor
There was a problem hiding this comment.
move ortho_scale to the CameraSensorSpec.
move channel and observationSpace to VisualSensorSpec. (@Skylion007 : is observationSpace used somewhere in the python side??)
There was a problem hiding this comment.
It's replicated entirely on the Python side. The C++ isn't used directly.
There was a problem hiding this comment.
deprecate the encoding (I did not see it was used anywhere, please double check).
deprecate the observationSpace.
There was a problem hiding this comment.
@vauduong : you can see the branch "cubemap-pr". See what I did there for your reference.
https://github.com/facebookresearch/habitat-sim/pull/1131/files

Motivation and Context
Currently we only have SensorSpec structure in the simulator. (in Sensor.h). This task is to build a hierarchical sensor spec abstractions to match the new sensor framework. For example, we have “SensorSpec” (base class) containing uuid, sensor type, position and orientation etc., then deriving “VisualSensorSpec”, “NonVisualSensorSpec”, and then “CameraSensorSpec”;
Since we do not have any non visual sensor yet. This task will be focusing on the visual sensor and its subclasses (the left side in the tree structure).
The following PR:
CameraSensorSpec::create(). After initialization, default parameters can be modified. When a vector of sensorSpecs is passed intoSensorFactory::createSensors(), SensorFactory will perform checks and automatically initialize the correct sensor for each SensorSpec and return it in a SensorSuiteSensorSubType::NoneSensorSpec::create()is no longer used, use correct SensorSpec initialization to create correct sensor, such asCameraSensorSpec::create()CameraSensorSpec()to initialize sensorSpecs, adds relevant checks for sensor initializationHow Has This Been Tested
Build and modify tests
Types of changes
Checklist