Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef GENERIC_MODEL_H_
00009 #define GENERIC_MODEL_H_
00010
00011 #include "articulation_msgs/ModelMsg.h"
00012 #include "articulation_msgs/TrackMsg.h"
00013 #include "articulation_msgs/ParamMsg.h"
00014 #include "../utils.h"
00015
00016 namespace articulation_models {
00017
00018
00019 class GenericModel {
00020 public:
00021
00022 double sigma_position;
00023 double sigma_orientation;
00024 double supress_similar;
00025 double outlier_ratio;
00026 double sac_iterations;
00027 double optimizer_iterations;
00028
00029
00030 double complexity;
00031 double avg_error_position;
00032 double avg_error_orientation;
00033 double loglikelihood;
00034 double bic;
00035 double prior_outlier_ratio;
00036 Eigen::MatrixXd jacobian;
00037 Eigen::MatrixXd hessian;
00038
00039 double last_error_jacobian;
00040
00041 double evaluated;
00042
00043 int channelOutlier;
00044 int channelLogLikelihood;
00045 int channelInlierLogLikelihood;
00046 std::vector<int> channelConfiguration;
00047
00048 articulation_msgs::ModelMsg model;
00049 public:
00050 GenericModel();
00051 virtual void setModel(const articulation_msgs::ModelMsg& model);
00052 virtual articulation_msgs::ModelMsg getModel();
00053 virtual void setTrack(const articulation_msgs::TrackMsg& track);
00054 virtual articulation_msgs::TrackMsg getTrack();
00055 void setId(int id);
00056 int getId();
00057
00058 virtual std::string getModelName();
00059 virtual size_t getDOFs();
00060 virtual size_t getSamples();
00061
00062 virtual void readParamsFromModel();
00063 virtual void writeParamsToModel();
00064 virtual void prepareChannels();
00065
00066 bool hasParam(std::string name);
00067 double getParam(std::string name);
00068 void getParam(std::string name,double& data);
00069 void getParam(std::string name,tf::Vector3 &vec);
00070 void getParam(std::string name,tf::Quaternion &quat);
00071 void getParam(std::string name,tf::Transform &t);
00072 void getParam(std::string name,Eigen::VectorXd &vec);
00073 void getParam(std::string name,Eigen::MatrixXd &mat);
00074 void setParam(std::string name,double value,int type);
00075 void setParam(std::string name,const tf::Vector3 &vec,int type);
00076 void setParam(std::string name,const tf::Quaternion &quat,int type);
00077 void setParam(std::string name,const tf::Transform &t,int type);
00078 void setParam(std::string name,const Eigen::VectorXd &vec,int type);
00079 void setParam(std::string name,const Eigen::MatrixXd &mat,int type);
00080
00081 virtual int openChannel(std::string name,bool autocreate=true);
00082
00083 virtual bool fitModel();
00084 virtual bool fitMinMaxConfigurations();
00085
00086 virtual bool evaluateModel();
00087 virtual double evalLatestJacobian();
00088 virtual double getPositionError();
00089 virtual double getOrientationError();
00090 virtual double getBIC();
00091
00092 virtual geometry_msgs::Pose predictPose(V_Configuration q);
00093 virtual M_CartesianJacobian predictJacobian(V_Configuration q,double delta = 1e-6);
00094 virtual M_CartesianJacobian predictHessian(V_Configuration q,double delta = 1e-6);
00095
00096 virtual void setConfiguration(size_t index,V_Configuration q);
00097 virtual void setJacobian(size_t index,M_CartesianJacobian J);
00098 virtual V_Configuration getConfiguration(size_t index);
00099
00100 virtual V_Configuration predictConfiguration(geometry_msgs::Pose pose);
00101 virtual V_Configuration getMinConfigurationObserved();
00102 virtual V_Configuration getMaxConfigurationObserved();
00103
00104 virtual void projectPoseToConfiguration();
00105 virtual void projectConfigurationToPose();
00106 virtual void projectConfigurationToJacobian();
00107 virtual void sampleConfigurationSpace(double resolution);
00108 virtual void keepLatestPoseOnly();
00109
00110 virtual double getInlierLogLikelihood( size_t index );
00111 virtual double getOutlierLogLikelihood();
00112 virtual double getLogLikelihoodForPoseIndex(size_t index);
00113 virtual double getLogLikelihood(bool estimate_outlier_ratio);
00114 virtual bool guessParameters();
00115 virtual bool sampleConsensus();
00116 virtual bool optimizeParameters();
00117 virtual bool normalizeParameters();
00118 std::vector<articulation_msgs::ParamMsg> params_initial;
00119 virtual void updateParameters(std::vector<double> delta);
00120 };
00121
00122 typedef boost::shared_ptr<GenericModel > GenericModelPtr;
00123 typedef boost::shared_ptr<GenericModel const> GenericModelConstPtr;
00124
00125 }
00126
00127 #endif