StateEstimatorController.hpp
Go to the documentation of this file.
00001 /*
00002  * StateEstimatorController.hpp
00003  *
00004  *  Created on: Nov 8, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #ifndef STATEESTIMATORCONTROLLER_HPP_
00009 #define STATEESTIMATORCONTROLLER_HPP_
00010 
00011 #include <telekyb_defines/telekyb_defines.hpp>
00012 
00013 #include <telekyb_base/Messages.hpp>
00014 
00015 #include <tk_state/StateEstimator.hpp>
00016 #include <tk_state/StateEstimatorControllerOptions.hpp>
00017 
00018 // Time
00019 #include <telekyb_base/Time.hpp>
00020 
00021 // Class Loading
00022 #include <pluginlib/class_loader.h>
00023 
00024 // Locking
00025 #include <boost/thread/mutex.hpp>
00026 
00027 //TF
00028 #include <tf/transform_broadcaster.h>
00029 
00030 namespace TELEKYB_NAMESPACE {
00031 
00032 class StateEstimatorController {
00033 private:
00034         // Singleton Stuff
00035         static StateEstimatorController* instance;
00036 
00037         StateEstimatorController();
00038         virtual ~StateEstimatorController();
00039 
00040         StateEstimatorController(const StateEstimatorController &);
00041         StateEstimatorController& operator=(const StateEstimatorController &);
00042 
00043 
00044 protected:
00045         // Options
00046         StateEstimatorControllerOptions options;
00047 
00048         // ClassLoader
00049         pluginlib::ClassLoader<StateEstimator> seLoader;
00050 
00051         // active State
00052         StateEstimator* activeStateEstimator;
00053 
00054         // TKState lastState
00055         TKState lastState;
00056         mutable boost::mutex lastStateMutex;
00057         bool recvFirstState;
00058 
00059         // ROS
00060         ros::NodeHandle nodeHandle;
00061         ros::Publisher tkStatePublisher;
00062 
00063 
00064         // initialize. This does further setup AFTER the object has been created.
00065         // This is needed, since Objects that reference the Behavior Controller can only be created after it returns from the constuctor
00066         // (Singleton Issue).
00067         //** This is like a Constructor. It's called by the Singleton creator DIRECTLY AFTER the actual constructor. **/
00068         void initialize();
00069 
00070         // TF
00071         tf::TransformBroadcaster tfBroadCaster;
00072         void publishTransform(const TKState& tStateMsg);
00073 
00074         ros::Publisher transformStampedPub;
00075         void publishTransformStamped(const TKState& tStateMsg);
00076 
00077 
00078 public:
00079         // Callback from activeState
00080         void activeStateCallBack(const TKState& tStateMsg);
00081         const StateEstimator* getActiveStateEstimator() const;
00082 
00083         std::string getSePublisherTopic() const;
00084 
00085         // block till timeout or first state becomes available
00086         bool waitForFirstState(Time timeout) const;
00087 
00088         // Returns last Received State.
00089         TKState getLastState() const;
00090 
00091         const ros::NodeHandle& getSensorNodeHandle() const;
00092 
00093 
00094         // Singleton Stuff
00095         static StateEstimatorController& Instance();
00096         static const StateEstimatorController* InstancePtr();
00097         static bool HasInstance();
00098         static void ShutDownInstance();
00099 };
00100 
00101 }
00102 
00103 #endif /* STATEESTIMATORCONTROLLER_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