SimpleSensorNoise.cpp
Go to the documentation of this file.
00001 // kate: replace-tabs off; indent-width 4; indent-mode normal
00002 // vim: ts=4:sw=4:noexpandtab
00003 /*
00004 
00005 Copyright (c) 2010--2018,
00006 François Pomerleau and Stephane Magnenat, ASL, ETHZ, Switzerland
00007 You can contact the authors at <f dot pomerleau at gmail dot com> and
00008 <stephane at magnenat dot net>
00009 
00010 All rights reserved.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014     * Redistributions of source code must retain the above copyright
00015       notice, this list of conditions and the following disclaimer.
00016     * Redistributions in binary form must reproduce the above copyright
00017       notice, this list of conditions and the following disclaimer in the
00018       documentation and/or other materials provided with the distribution.
00019     * Neither the name of the <organization> nor the
00020       names of its contributors may be used to endorse or promote products
00021       derived from this software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00024 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00025 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00026 DISCLAIMED. IN NO EVENT SHALL ETH-ASL BE LIABLE FOR ANY
00027 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00028 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00030 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00031 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 #include "SimpleSensorNoise.h"
00036 
00037 #include "PointMatcherPrivate.h"
00038 
00039 #include <string>
00040 #include <vector>
00041 
00042 #include <boost/format.hpp>
00043 
00044 // SimpleSensorNoiseDataPointsFilter
00045 // Constructor
00046 template<typename T>
00047 SimpleSensorNoiseDataPointsFilter<T>::SimpleSensorNoiseDataPointsFilter(const Parameters& params):
00048         PointMatcher<T>::DataPointsFilter("SimpleSensorNoiseDataPointsFilter",
00049         SimpleSensorNoiseDataPointsFilter::availableParameters(), params),
00050         sensorType(Parametrizable::get<unsigned>("sensorType")),
00051         gain(Parametrizable::get<T>("gain"))
00052 {
00053         std::vector<std::string> sensorNames = {"Sick LMS-1xx",
00054                                                                                         "Hokuyo URG-04LX",
00055                                                                                         "Hokuyo UTM-30LX",
00056                                                                                         "Kinect / Xtion","Sick Tim3xx"};
00057         if (sensorType >= sensorNames.size())
00058         {
00059                 throw InvalidParameter(
00060                         (boost::format("SimpleSensorNoiseDataPointsFilter: Error, sensorType id %1% does not exist.") % sensorType).str());
00061         }
00062 
00063         LOG_INFO_STREAM("SimpleSensorNoiseDataPointsFilter - using sensor noise model: " << sensorNames[sensorType]);
00064 }
00065 
00066 
00067 // SimpleSensorNoiseDataPointsFilter
00068 // Compute
00069 template<typename T>
00070 typename PointMatcher<T>::DataPoints 
00071 SimpleSensorNoiseDataPointsFilter<T>::filter(const DataPoints& input)
00072 {
00073         DataPoints output(input);
00074         inPlaceFilter(output);
00075         return output;
00076 }
00077 
00078 // In-place filter
00079 template<typename T>
00080 void SimpleSensorNoiseDataPointsFilter<T>::inPlaceFilter(DataPoints& cloud)
00081 {
00082         cloud.allocateDescriptor("simpleSensorNoise", 1);
00083         BOOST_AUTO(noise, cloud.getDescriptorViewByName("simpleSensorNoise"));
00084 
00085         switch(sensorType)
00086         {
00087         case 0: // Sick LMS-1xx
00088         {
00089                 noise = computeLaserNoise(0.012, 0.0068, 0.0008, cloud.features);
00090                 break;
00091         }
00092         case 1: // Hokuyo URG-04LX
00093         {
00094                 noise = computeLaserNoise(0.028, 0.0013, 0.0001, cloud.features);
00095                 break;
00096         }
00097         case 2: // Hokuyo UTM-30LX
00098         {
00099                 noise = computeLaserNoise(0.018, 0.0006, 0.0015, cloud.features);
00100                 break;
00101         }
00102         case 3: // Kinect / Xtion
00103         {
00104                 const int dim = cloud.features.rows();
00105                 const Matrix squaredValues(cloud.features.topRows(dim-1).colwise().norm().array().square());
00106                 noise = squaredValues*(0.5*0.00285);
00107                 break;
00108         }
00109   case 4: // Sick Tim3xx
00110   {
00111     noise = computeLaserNoise(0.004, 0.0053, -0.0092, cloud.features);
00112     break;
00113   }
00114         default:
00115                 throw InvalidParameter(
00116                         (boost::format("SimpleSensorNoiseDataPointsFilter: Error, cannot compute noise for sensorType id %1% .") % sensorType).str());
00117         }
00118 
00119 }
00120 
00121 template<typename T>
00122 typename PointMatcher<T>::Matrix 
00123 SimpleSensorNoiseDataPointsFilter<T>::computeLaserNoise(
00124         const T minRadius, const T beamAngle, const T beamConst, const Matrix& features)
00125 {
00126         typedef typename Eigen::Array<T, 2, Eigen::Dynamic> Array2rows;
00127 
00128         const int nbPoints = features.cols();
00129         const int dim = features.rows();
00130 
00131         Array2rows evalNoise = Array2rows::Constant(2, nbPoints, minRadius);
00132         evalNoise.row(0) =  beamAngle * features.topRows(dim-1).colwise().norm();
00133         evalNoise.row(0) += beamConst;
00134 
00135         return evalNoise.colwise().maxCoeff();
00136 }
00137 
00138 
00139 template struct SimpleSensorNoiseDataPointsFilter<float>;
00140 template struct SimpleSensorNoiseDataPointsFilter<double>;
00141 
00142 


libpointmatcher
Author(s):
autogenerated on Thu Jun 20 2019 19:51:32