00001 //================================================================================================= 00002 // Copyright (c) 2013, Johannes Meyer, TU Darmstadt 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 // * Redistributions of source code must retain the above copyright 00008 // notice, this list of conditions and the following disclaimer. 00009 // * Redistributions in binary form must reproduce the above copyright 00010 // notice, this list of conditions and the following disclaimer in the 00011 // documentation and/or other materials provided with the distribution. 00012 // * Neither the name of the Flight Systems and Automatic Control group, 00013 // TU Darmstadt, nor the names of its contributors may be used to 00014 // endorse or promote products derived from this software without 00015 // specific prior written permission. 00016 00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00018 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00019 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00020 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 //================================================================================================= 00028 00029 #include <hector_pose_estimation/filter.h> 00030 #include <hector_pose_estimation/pose_estimation.h> 00031 00032 namespace hector_pose_estimation { 00033 00034 Filter::Filter() 00035 { 00036 } 00037 00038 Filter::~Filter() 00039 { 00040 } 00041 00042 bool Filter::init(PoseEstimation& estimator) 00043 { 00044 return true; 00045 } 00046 00047 void Filter::cleanup() 00048 { 00049 } 00050 00051 void Filter::reset() 00052 { 00053 state_.reset(); 00054 } 00055 00056 bool Filter::predict(const Systems& systems, double dt) { 00057 SystemStatus system_status = 0; 00058 bool result = true; 00059 00060 for(Systems::iterator it = systems.begin(); it != systems.end(); it++) { 00061 const SystemPtr& system = *it; 00062 result &= predict(system, dt); 00063 system_status |= system->getStatusFlags(); 00064 } 00065 00066 // call the filter's global predict method 00067 result &= doPredict(dt); 00068 00069 state_.updateSystemStatus(system_status, STATE_MASK); 00070 return result; 00071 } 00072 00073 bool Filter::predict(const SystemPtr& system, double dt) { 00074 return system->update(dt); 00075 } 00076 00077 bool Filter::doPredict(double dt) { 00078 state_.updated(); 00079 return true; 00080 } 00081 00082 bool Filter::correct(const Measurements& measurements) { 00083 SystemStatus measurement_status = 0; 00084 bool result = true; 00085 00086 for(Measurements::iterator it = measurements.begin(); it != measurements.end(); it++) { 00087 const MeasurementPtr& measurement = *it; 00088 result &= correct(measurement); 00089 measurement_status |= measurement->getStatusFlags(); 00090 } 00091 00092 // call the filter's global correct method 00093 result &= doCorrect(); 00094 00095 state_.setMeasurementStatus(measurement_status); 00096 return result; 00097 } 00098 00099 bool Filter::correct(const MeasurementPtr& measurement) { 00100 return measurement->process(); 00101 } 00102 00103 bool Filter::doCorrect() { 00104 state_.updated(); 00105 return true; 00106 } 00107 00108 } // namespace hector_pose_estimation