depth_noise_model.hpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 Michael Pantic, ASL, ETH Zurich, Switzerland
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef ROTORS_GAZEBO_PLUGINS_DEPTH_NOISE_MODEL_H
00017 #define ROTORS_GAZEBO_PLUGINS_DEPTH_NOISE_MODEL_H
00018 
00019 #include <Eigen/Eigen>
00020 #include <random>
00021 
00022 class DepthNoiseModel {
00023  public:
00024   DepthNoiseModel()
00025       : max_depth(1000.0f), min_depth(0.2f), gen(std::random_device{}()) {}
00026 
00027   virtual void ApplyNoise(uint32_t width, uint32_t height, float *data) = 0;
00028 
00029   float max_depth;  // [m]
00030   float min_depth;  // [m] Values smaller/larger than these two are replaced
00031                     //     by NaN
00032 
00033  protected:
00034   bool InRange(float depth) const;
00035 
00036   const float bad_point = std::numeric_limits<float>::quiet_NaN();
00037   std::normal_distribution<float> dist;
00038   std::mt19937 gen;
00039 };
00040 
00041 class KinectDepthNoiseModel : public DepthNoiseModel {
00042  public:
00043   KinectDepthNoiseModel() : DepthNoiseModel() {}
00044 
00045   void ApplyNoise(uint32_t width, uint32_t height, float *data);
00046 };
00047 
00048 class D435DepthNoiseModel : public DepthNoiseModel {
00049  public:
00050   D435DepthNoiseModel()
00051       : h_fov(M_PI_2),       // Default 90deg for D435
00052         baseline(0.05f),     // Default 50 mm for D435
00053         subpixel_err(0.1f),  // Default subpixel calibration error
00054         max_stdev(3.0f),
00055         DepthNoiseModel() {}
00056 
00057   void ApplyNoise(uint32_t width, uint32_t height, float *data);
00058 
00059   // public params...
00060   float h_fov;         // [rad]
00061   float baseline;      // [m]
00062   float subpixel_err;  // [pixel] Calibration error
00063   float max_stdev;     // [m] cutoff for distance standard deviation:
00064                        //     If modeled standard deviation becomes bigger, it is replaced with this
00065                        //     value.
00066 };
00067 
00068 #endif  // ROTORS_GAZEBO_PLUGINS_DEPTH_NOISE_MODEL_H


rotors_gazebo_plugins
Author(s): Fadri Furrer, Michael Burri, Mina Kamel, Janosch Nikolic, Markus Achtelik
autogenerated on Thu Apr 18 2019 02:43:43