UncertainTransformListener.h
Go to the documentation of this file.
00001 
00002 #ifndef _UNCERTAIN_TRANSFORM_LISTENER_
00003 #define _UNCERTAIN_TRANSFORM_LISTENER_
00004 
00005 #include "uncertain_tf/UncertainTransformer.h"
00006 #include "uncertain_tf/utfMessage.h"
00007 #include "uncertain_tf/EigenMultiVariateNormal.hpp"
00008 
00009 using namespace tf;
00010 using namespace Eigen;
00011 
00012 namespace uncertain_tf {
00013 
00014 
00015 //TODO: Most of this functionality should move to UncertainTransformer!
00016 
00017 class UncertainTransformListener : public UncertainTransformer
00018 {
00019 
00020 public:
00021 
00022     UncertainTransformListener(ros::Duration max_cache_time = ros::Duration(tf::Transformer::DEFAULT_CACHE_TIME), bool spin_thread = true);
00023 
00025     void sampleTransform(const std::string& target_frame, const std::string& source_frame,
00026                          const ros::Time& time, std::vector<StampedTransform>& output, size_t n);
00027 
00029     void sampleTransform(const std::string& target_frame, const ros::Time& target_time,
00030                           const std::string& source_frame, const ros::Time& time,
00031                           const std::string& fixed_frame,
00032                           std::vector<StampedTransform>& output, size_t n);
00033 
00035     void sampleTransformGaussianTime(const std::string& target_frame, const std::string& source_frame,
00036                          const ros::Time& time_mean, const ros::Duration& time_variance, std::vector<StampedTransform>& output, size_t n);
00037 
00039     void sampleTransformUniformTime(const std::string& target_frame, const std::string& source_frame,
00040                          const ros::Time& time_start, const ros::Time& time_end, std::vector<StampedTransform>& output, size_t n);
00041 
00042     void printFrame(std::string last_frame, std::string current_frame, tf::Transform rel);
00043 
00044 
00046     MatrixXd sampleFromMeanCov(const VectorXd &mean_, const MatrixXd &cov_, size_t n = 1);
00047 
00049     void sampleFromMeanCov(const tf::Transform &mean, const MatrixXd &cov, std::vector<tf::Transform> &output, size_t n = 1);
00050 
00052     tf::Transform sampleFromMeanCov(const tf::Transform &mean, const MatrixXd &cov);
00053 
00055     VectorXd transformTFToVectorXd(const tf::Transform &transform);
00056 
00058     tf::Transform transformVectorXdToTF(const VectorXd &vec);
00059 
00061     bool isZero(const MatrixXd mat);
00062 
00064     template <typename Derived, typename OtherDerived> void calculateSampleCovariance(const MatrixBase<Derived>& x, const MatrixBase<Derived>& y, MatrixBase<OtherDerived> & C_);
00065 
00067     VectorXd calculateSampleMean(const MatrixXd &x);
00068 
00070     MatrixXd sampleSetTFtoMatrixXd(std::vector<tf::StampedTransform> sampleset);
00071 
00072 private:
00073 
00074     void subscription_callback(const uncertain_tf::utfMessageConstPtr& msg);
00075 
00076     ros::NodeHandle node_;
00077     ros::Subscriber message_subscriber_utf_;
00078     EigenMultivariateNormal<double, 6> *emn_;
00079     UnivariateNormal<double> *univ_;
00080 };
00081 
00082 template <typename Derived, typename OtherDerived>
00083 void UncertainTransformListener::calculateSampleCovariance(const MatrixBase<Derived>& x, const MatrixBase<Derived>& y, MatrixBase<OtherDerived> & C_)
00084 {
00085     typedef typename Derived::Scalar Scalar;
00086     typedef typename internal::plain_row_type<Derived>::type RowVectorType;
00087 
00088     const Scalar num_observations = static_cast<Scalar>(x.rows());
00089 
00090     const RowVectorType x_mean = x.colwise().sum() / num_observations;
00091     const RowVectorType y_mean = y.colwise().sum() / num_observations;
00092 
00093     MatrixBase<OtherDerived>& C = const_cast< MatrixBase<OtherDerived>& >(C_);
00094 
00095     C.derived().resize(x.cols(),x.cols()); // resize the derived object
00096     C = (x.rowwise() - x_mean).transpose() * (y.rowwise() - y_mean) / num_observations;
00097 }
00098 
00099 
00100 }
00101 
00102 #endif


uncertain_tf
Author(s): Thomas Ruehr
autogenerated on Mon Oct 6 2014 08:20:49