ComplementaryStateEstimator.hpp
Go to the documentation of this file.
00001 /*
00002  * ComplementaryStateEstimator.hpp
00003  *
00004  *  Created on: Jun 19, 2012
00005  *      Author: rspica
00006  */
00007 
00008 #ifndef COMPLEMENTARYSTATEESTIMATOR_HPP_
00009 #define COMPLEMENTARYSTATEESTIMATOR_HPP_
00010 
00011 #include <telekyb_defines/telekyb_defines.hpp>
00012 #include <telekyb_base/Options.hpp>
00013 #include <tk_state/StateEstimator.hpp>
00014 
00015 #include <telekyb_base/Filter/IIRFilter.hpp>
00016 
00017 // plugin stuff
00018 #include <pluginlib/class_list_macros.h>
00019 
00020 #include "ComplementaryDataTypes.hpp"
00021 
00022 #include <tk_draft_msgs/TKSmallImu.h>
00023 #include <geometry_msgs/TransformStamped.h>
00024 
00025 // Boost
00026 #include <boost/thread/mutex.hpp>
00027 #include <boost/thread/thread.hpp>
00028 #include <telekyb_base/Time.hpp>
00029 
00030 using namespace TELEKYB_NAMESPACE;
00031 
00032 namespace telekyb_state {
00033 
00034 class ComplementaryStateEstimatorOptions : public OptionContainer {
00035 public:
00036 
00037         Option<Eigen::Vector3d>* imuAccBias;
00038         Option<Eigen::Vector3d>* imuGyrBias;
00039         Option<Eigen::Vector3d>* vicPosition;
00040         Option<Eigen::Vector2d>* vicOrientation;
00041         Option<double>* predStep;
00042         Option<double>* pubStep;
00043         Option<double>* normalizationGain;
00044         Option<Eigen::Vector3d>* worldGravity;
00045         Option<std::string>* tViconSeTopicName;
00046         Option<std::string>* tImuSeTopicName;
00047         Option<std::string>* tViconRepubTopicName;
00048 
00049         Option<Eigen::Matrix3d>* positionGain;
00050         Option<Eigen::Matrix3d>* velocityGain;
00051         Option<Eigen::Matrix3d>* rotationGain;
00052         Option<Eigen::Matrix3d>* biasGain;
00053 
00054         Option<Eigen::Matrix3d>* matrixA;
00055         Option<Eigen::Vector3d>* vectorB;
00056 
00057         Option<double>* tOmegaFilterFreq;
00058         Option<double>* tOmegaSampleTime;
00059         ComplementaryStateEstimatorOptions();
00060 };
00061 
00062 class ComplementaryStateEstimator : public TELEKYB_NAMESPACE::StateEstimator {
00063 public:
00064 
00065         ComplementaryStateEstimator();
00066         void inputCallback(const tk_draft_msgs::TKSmallImuConstPtr& msg);
00067         void measureCallback(const geometry_msgs::TransformStampedConstPtr& msg);
00068 
00069         virtual void initialize();
00070         virtual void willBecomeActive();
00071         virtual void willBecomeInActive();
00072         virtual void destroy();
00073 
00074         virtual std::string getName() const;
00075 
00076 protected:
00077         IIRFilter* omegaFilter[3];
00078         void initVelocityFilters();
00079         Eigen::Vector3d angVelFiltered;
00080 
00081 
00082         ros::NodeHandle nodeHandle;
00083         ros::Subscriber viconSub;
00084         ros::Subscriber imuSub;
00085 
00086         ros::Publisher biasPub;
00087         ros::Publisher viconRepublisher;
00088 
00089 
00090         bool spinning;
00091         bool isInitialized, receivedFirstInput, receivedFirstMeasure;
00092 
00093         boost::thread thread;
00094         boost::mutex threadMutex;
00095 
00096         boost::mutex imuMutex;
00097         boost::mutex viconMutex;
00098         telekyb::Timer rtTimer;
00099         telekyb::Timer pubTimer;
00100 
00101         void spin();
00102         /* Options */
00103         ComplementaryStateEstimatorOptions options;
00104 
00105         State internalState;
00106 
00107         DynamicSystem system;
00108 
00109         void initializationDone();
00110 
00111 
00112 
00113         /* Core functions */
00114         void prediction(State& state, double Tpred);
00115         void publishState();
00116 
00117 };
00118 
00119 } /* namespace telekyb_state */
00120 #endif /* COMPLEMENTARYSTATEESTIMATOR_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


tk_state
Author(s): Dr. Antonio Franchi and Martin Riedel
autogenerated on Mon Nov 11 2013 11:13:03