00001 /* 00002 * Copyright (c) 2010, Bosch LLC 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Neither the name of Bosch LLC nor the names of its 00014 * contributors may be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00030 /********************************************************************* 00031 * 00032 * Disclaimer 00033 * 00034 * This source code is not officially released or supported by Bosch Sensortec. 00035 * Please contact the listed authors with bugs or other modifications. 00036 * If you would like the official Bosch Sensortec drivers, please contact: 00037 * contact@bosch-sensortec.com 00038 * 00039 *********************************************************************/ 00040 00041 //\Author Lukas Marti, Bosch LLC 00042 00043 #ifndef __BMA180_CALIBRATE__ 00044 #define __BMA180_CALIBRATE__ 00045 00046 #include <bma180/bma180meas.h> 00047 #include <bma180/bma180.h> 00048 00049 namespace bma180_spec { 00050 const static double std_acc_g = 0.02; //[g] measured on the actual sensor 00051 const static double outlier_sigma = 2; //consdiering 3 sigma rule for outlier 00052 const static int calib_varreduct = 100; //calibartion accuracy -> variance red = num of calib samples 00053 }; 00054 00056 00060 class bma180_calibrate 00061 { 00062 public: 00064 00068 bma180_calibrate (); 00069 00071 ~bma180_calibrate (); 00072 00074 00081 bool setdata_bma180 (struct OneBma180Meas); 00082 00084 00091 void setcalibsens (struct OneBma180Meas); 00092 00094 00097 void clearcalibsens (); 00098 00100 00103 bool calibsens_completed (); 00104 00106 00109 bool verification_completed (); 00110 00112 00119 bool verification_active (); 00120 00122 00125 bool calibsens_set (); 00126 00128 00131 bool get_estbiases (double*, double*, double*); 00132 bool biasverify (); 00133 bool get_verifiedbiases (double*, double*, double*); 00134 00135 private: 00136 struct SensID { 00137 std::string Sub20ID; 00138 int iChipSelect; 00139 }; 00140 struct OneCalibDataSet { 00141 SensID Sensor_ID; 00142 ros::Time AgeOfBias; //contains the time stamp of the last calibration measurement 00143 double dBias_AccX; 00144 double dBias_AccY; 00145 double dBias_AccZ; 00146 int iNumOfCalibMeas; 00147 bool bCalib_complete; 00148 bool bCalibsensID_set; 00149 }; 00150 OneCalibDataSet CalibSensor[2]; //2 array of 0: primary calibration, 1: calibration verification 00151 short int iActiveDataIndex; 00152 bool bVerification_activated; 00153 }; // class 00154 00155 #endif