ViconImuStateEstimator.hpp
Go to the documentation of this file.
00001 /*
00002  * ViconImuStateEstimator.hpp
00003  *
00004  *  Created on: Jul 11, 2012
00005  *      Author: mriedel & rspica
00006  */
00007 
00008 #ifndef VICONIMUSTATEESTIMATOR_HPP_
00009 #define VICONIMUSTATEESTIMATOR_HPP_
00010 
00011 #include <telekyb_defines/telekyb_defines.hpp>
00012 #include <telekyb_base/Options.hpp>
00013 
00014 #include <tk_state/StateEstimator.hpp>
00015 
00016 // plugin stuff
00017 #include <pluginlib/class_list_macros.h>
00018 
00019 #include <geometry_msgs/PoseWithCovarianceStamped.h>
00020 // ros
00021 #include <ros/subscriber.h>
00022 
00023 #include <telekyb_base/Spaces/R3.hpp>
00024 #include <telekyb_base/Filter/IIRFilter.hpp>
00025 #include <telekyb_base/Time.hpp>
00026 
00027 #include <sensor_msgs/Imu.h>
00028 
00029 #include <boost/thread.hpp>
00030 
00031 using namespace TELEKYB_NAMESPACE;
00032 
00033 namespace telekyb_state {
00034 
00035 class ViconImuStateEstimatorOptions : public OptionContainer {
00036 public:
00037         Option<std::string>* tViconSeTopicName;
00038         Option<std::string>* tImuSeTopicName;
00039         Option<Eigen::Matrix3d>* tViconToNEDMatrix;
00040         Option<Eigen::Quaterniond>* tViconToNEDQuaternion;
00041 
00042         Option<double>* timeStep;
00043 
00044         // Velocity Filters
00045         Option<double>* tViconVelFilterFreq;
00046         Option<double>* tViconSmoothVelFilterFreq;
00047         Option<double>* tViconAngFilterFreq;
00048         Option<double>* tViconSampleTime;
00049         Option<bool>* tViconPublishSmoothVel;
00050 
00051         Option<bool>* tIntegrateLinVel;
00052         Option<bool>* tIntegrateAngVel;
00053 
00054         ViconImuStateEstimatorOptions();
00055 
00056         Option<std::string>* tSsxSeTopicName;
00057 
00058 };
00059 
00060 class ViconImuStateEstimator : public TELEKYB_NAMESPACE::StateEstimator {
00061 protected:
00062         ViconImuStateEstimatorOptions options;
00063 
00064         ros::NodeHandle nodeHandle;
00065         ros::Subscriber viconSub;
00066         ros::Subscriber imuSub;
00067         ros::Publisher smoothVelPub;
00068 
00069 //      ros::Subscriber ssxSub;
00070 //      ros::Publisher debugPub;
00071 
00072         void initVelocityFilters();
00073         void publishState();
00074 
00075         IIRFilter* velFilter[3];
00076         IIRFilter* smoothVelFilter[3];
00077 
00078         Velocity3D angVelocityNED;
00079         Quaternion quatNED;
00080         Position3D posNED;
00081         Velocity3D velNED;
00082         Velocity3D smoothVelNED;
00083         telekyb::Time intTime;
00084         telekyb::Timer intTimer; 
00085 
00086         // Thread
00087         boost::thread thread;
00088         // Mutexes
00089         boost::mutex imuMutex;
00090         boost::mutex viconMutex;
00091         boost::mutex timeMutex;
00092         telekyb::Timer rtTimer;
00093 
00094         void spin();
00095         bool spinning;
00096         void viconCallback(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& msg);
00097         void imuCallback(const sensor_msgs::Imu::ConstPtr& msg);
00098         void ssxCallback(const telekyb_msgs::TKState::ConstPtr& stateMsg);
00099 
00100 public:
00101         virtual void initialize();
00102         virtual void willBecomeActive();
00103         virtual void willBecomeInActive();
00104         virtual void destroy();
00105 
00106         virtual std::string getName() const;
00107 
00108 };
00109 
00110 } /* namespace telekyb_state */
00111 #endif /* VICONIMUSTATEESTIMATOR_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