Advertisement
Briansmith61

Header File1

Apr 29th, 2014
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.97 KB | None | 0 0
  1. /*
  2.  * cmd_vel_mux.h
  3.  *
  4.  *  Created on: Nov 30, 2012
  5.  *      Author: jorge
  6.  */
  7.  
  8. #ifndef CMD_VEL_MUX_H_
  9. #define CMD_VEL_MUX_H_
  10.  
  11.  
  12. #include <ros/ros.h>
  13. #include <geometry_msgs/PoseWithCovarianceStamped.h>
  14. #include <geometry_msgs/PoseStamped.h>
  15. #include "cmd_vel_subscribers.h"
  16.  
  17.  
  18. class CmdVelMux
  19. {
  20. public:
  21.  
  22.   CmdVelMux();
  23.   ~CmdVelMux();
  24.  
  25.   bool init(ros::NodeHandle& nh);
  26.  
  27. private:
  28.   CmdVelSubscribers  cmd_vel_sub;  /**< Pool of cmd_vel topics subscribers */
  29.  
  30.   ros::Publisher mux_cmd_vel_pub;  /**< Multiplexed command velocity topic */
  31.   ros::Publisher allowed_sub_pub;  /**< Currently allowed cmd_vel subscriber */
  32.  
  33.   ros::Subscriber current_position; /**< Added by Rupam on 26-04-2014*/
  34.   ros::Subscriber goal_position; /**< Added by Rupam on 28-04-2014*/
  35.  
  36.   void timerCallback(const ros::TimerEvent& event, unsigned int idx);
  37.   void cmdVelCallback(const geometry_msgs::Twist::ConstPtr& msg, unsigned int idx);
  38.   void currentPosCallback(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& msg); /**< Added by Rupam on 26-04-2014*/
  39.   void goalPosCallback(const geometry_msgs::PoseStamped::ConstPtr& msg); /**< Added by Rupam on 28-04-2014*/
  40.  
  41.  
  42.  
  43.   // Functor assigned to each incoming velocity topic to bind it to cmd_vel callback
  44.   class CmdVelFunctor
  45.   {
  46.   private:
  47.     unsigned int idx;
  48.     CmdVelMux*  node;
  49.  
  50.   public:
  51.     CmdVelFunctor(unsigned int idx, CmdVelMux* node) :
  52.         idx(idx), node(node) { }
  53.  
  54.     void operator()(const geometry_msgs::Twist::ConstPtr& msg)
  55.     {
  56.       node->cmdVelCallback(msg, idx);
  57.     }
  58.   };
  59.  
  60.   // Functor assigned to each velocity messages source to bind it to timer callback
  61.   class TimerFunctor
  62.   {
  63.   private:
  64.     unsigned int idx;
  65.     CmdVelMux*  node;
  66.  
  67.   public:
  68.     TimerFunctor(unsigned int idx, CmdVelMux* node) :
  69.         idx(idx), node(node) { }
  70.  
  71.     void operator()(const ros::TimerEvent& event)
  72.     {
  73.       node->timerCallback(event, idx);
  74.     }
  75.   };
  76. };
  77.  
  78. #endif /* CMD_VEL_MUX_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement