nucManager.hpp
Go to the documentation of this file.
00001 
00005 /* This class implements a simple NUC manager that allows or forbids NUC depending on the current camera rotation.
00006  * The parameter rotThreshold can be changed in the launch file and the default value can also be changed in the constructor.
00007  * 
00008  * The node subscribes to a "pose" message, analyses the current amount of rotation and then publishes a topic called nuc_flag, which contains a data field with valeu 0 or 1 (1: NUC allowed, 0: NUC forbidden)
00009 */
00010 
00011 
00012 #include <vector>
00013 #include <string>
00014 #include <ros/node_handle.h>
00015 #include <ros/init.h>
00016 
00017 #include <ros/ros.h>
00018 #include <std_msgs/Float32.h>
00019 
00020 #include <geometry_msgs/PoseStamped.h>
00021 //#include <geometry_messages/Twist.h>
00022 
00023 
00024 #ifndef _THERMALVIS_NUCMANAGER_H_
00025 #define _THERMALVIS_NUCMANAGER_H_
00026 
00027  
00028 const char __PROGRAM__[] = "THERMALVIS_NUCMANAGER";
00029 
00030 
00031 
00032 class nucManager{
00033   
00034   private:
00035 
00036   std::vector<float> quadBuffer;
00037   
00038   ros::NodeHandle nh_;
00039 
00040   ros::Subscriber pose_sub_;
00041   ros::Publisher nucFlag_pub_;
00042   
00043   std_msgs::Float32 nuc_msg;
00044   geometry_msgs::PoseStamped poseStp;
00045   
00046   // Input parameters 
00047   double rotThreshold;      
00048   std::string inputTopic;
00049     
00050   
00051   public:
00052     nucManager()
00053     {
00054       
00055       ros::NodeHandle nh_read("~");
00056       
00057       nh_read.param("rotThreshold", rotThreshold, 0.004);
00058       nh_read.param<std::string>("inputTopic", inputTopic, "mono_odometer/pose");
00059       
00060       nucFlag_pub_  = nh_.advertise<std_msgs::Float32>("thermalvis/nuc_flag", 1);
00061       pose_sub_ = nh_.subscribe(inputTopic, 1, &nucManager::poseCallBack, this);
00062      
00063     }
00064 
00065   
00066     void poseCallBack(const geometry_msgs::PoseStamped msg)
00067     {
00068       
00069       poseStp = msg;
00070       
00071       quadBuffer.push_back(msg.pose.orientation.y);
00072       
00073       if(quadBuffer.size() > 2)
00074       {
00075         quadBuffer.erase(quadBuffer.begin() );
00076         
00077       }
00078       
00079     }
00080     
00081     //Function to evaluate the amount of rotation and set the NUC permission flag
00082     void setFlag();
00083     
00084     // Simply gives access to the current flag status
00085     float getStatus();
00086     
00087     // Publishes the message
00088     void publish()
00089     {
00090       nucFlag_pub_.publish(nuc_msg);
00091     };
00092     
00093 
00094       
00095    
00096   
00097 };
00098 
00099 
00100 
00101 #endif


thermalvis
Author(s): Stephen Vidas
autogenerated on Sun Jan 5 2014 11:38:45