PersistenceModel.cpp
Go to the documentation of this file.
00001 
00012 // worldlib
00013 #include "worldlib/model/PersistenceModel.h"
00014 
00015 using namespace std;
00016 using namespace rail::spatial_temporal_learning::worldlib::model;
00017 using namespace rail::spatial_temporal_learning::worldlib::world;
00018 
00019 PersistenceModel::PersistenceModel(const Item &item, const Surface &surface, const double lambda, const uint32_t count,
00020     const ros::Time &last_seen) : item_(item), surface_(surface), last_seen_(last_seen), exponential_(lambda)
00021 {
00022   count_ = count;
00023 }
00024 
00025 const Item &PersistenceModel::getItem() const
00026 {
00027   return item_;
00028 }
00029 
00030 Item &PersistenceModel::getItem()
00031 {
00032   return item_;
00033 }
00034 
00035 void PersistenceModel::setItem(const Item &item)
00036 {
00037   item_ = item;
00038 }
00039 
00040 const Surface &PersistenceModel::getSurface() const
00041 {
00042   return surface_;
00043 }
00044 
00045 Surface &PersistenceModel::getSurface()
00046 {
00047   return surface_;
00048 }
00049 
00050 void PersistenceModel::setSurface(const Surface &surface)
00051 {
00052   surface_ = surface;
00053 }
00054 
00055 double PersistenceModel::getLambda() const
00056 {
00057   return exponential_.lambda();
00058 }
00059 
00060 void PersistenceModel::setLambda(const double lambda)
00061 {
00062   exponential_ = boost::math::exponential_distribution<>(lambda);
00063 }
00064 
00065 ros::Duration PersistenceModel::getExpectedPersistence() const
00066 {
00067   // get the time in hours and convert to seconds
00068   double hours = boost::math::mean(exponential_);
00069   double seconds = hours * 3600;
00070   return ros::Duration(seconds);
00071 }
00072 
00073 double PersistenceModel::getProbabilityItemStillExists(const ros::Time &time) const
00074 {
00075   // need the complement of the CDF (probability the event did not occur yet)
00076   return 1.0 - this->getProbabilityItemRemoved(time);
00077 }
00078 
00079 double PersistenceModel::getProbabilityItemRemoved(const ros::Time &time) const
00080 {
00081   // calculate the time from when we last saw it
00082   ros::Duration duration = time - last_seen_;
00083   // convert to hours
00084   double hours = duration.toSec() / 3600;
00085   // calculate the CDF (probability the event did occur)
00086   return boost::math::cdf(exponential_, abs(hours));
00087 }
00088 
00089 uint32_t PersistenceModel::getCount() const
00090 {
00091   return count_;
00092 }
00093 
00094 void PersistenceModel::setCount(const uint32_t count)
00095 {
00096   count_ = count;
00097 }
00098 
00099 const ros::Time &PersistenceModel::getLastSeen() const
00100 {
00101   return last_seen_;
00102 }
00103 
00104 ros::Time &PersistenceModel::getLastSeen()
00105 {
00106   return last_seen_;
00107 }
00108 
00109 void PersistenceModel::setLastSeen(const ros::Time &last_seen)
00110 {
00111   last_seen_ = last_seen;
00112 }


worldlib
Author(s): Russell Toris
autogenerated on Fri Feb 12 2016 00:24:18