Advertisement
Briansmith61

Header File2

Apr 29th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. /*
  2.  * cmd_vel_subscribers.hpp
  3.  *
  4.  *  Created on: Oct 31, 2012
  5.  *      Author: jorge
  6.  */
  7.  
  8. #ifndef CMD_VEL_SUBSCRIBERS_H_
  9. #define CMD_VEL_SUBSCRIBERS_H_
  10.  
  11.  
  12. #include <ros/ros.h>
  13. #include <geometry_msgs/Twist.h>
  14.  
  15. #include <yaml-cpp/yaml.h>
  16.  
  17. #define VACANT  std::numeric_limits<unsigned int>::max()
  18.  
  19.  
  20. /**
  21.  * Pool of cmd_vel topics subscribers
  22.  */
  23. class CmdVelSubscribers
  24. {
  25. public:
  26.  
  27.   /**
  28.    * Inner class describing an individual subscriber to a cmd_vel topic
  29.    */
  30.   class CmdVelSubs
  31.   {
  32.   public:
  33.     unsigned int           idx;          /**< Index; assigned according to the order on YAML file */
  34.     std::string            name;         /**< Descriptive name */
  35.     ros::Subscriber        subs;         /**< The subscriber itself */
  36.     std::string            topic;        /**< The name of the topic */
  37.     ros::Timer             timer;        /**< No incoming messages timeout */
  38.     double                 timeout;      /**< Timer's timeout, in seconds  */
  39.     unsigned int           priority;     /**< UNIQUE integer from 0 (lowest priority) to MAX_INT */
  40.     std::string            short_desc;   /**< Short description (optional) */
  41.     bool                   active;       /**< Whether this source is active */
  42.  
  43.     CmdVelSubs(unsigned int idx) : idx(idx), active(false) {};
  44.  
  45.     void operator << (const YAML::Node& node);
  46.   };
  47.  
  48.   unsigned int allowed;
  49.  
  50.   CmdVelSubscribers() : allowed(VACANT) { }
  51.   ~CmdVelSubscribers() { }
  52.  
  53.   std::vector<CmdVelSubs>::size_type size() { return list.size(); };
  54.  
  55.   CmdVelSubs& operator [] (unsigned int idx) { return list[idx]; };
  56.  
  57.   bool loadSubscribersCfg(std::string path);
  58.  
  59. private:
  60.   std::vector<CmdVelSubs> list;
  61. };
  62.  
  63. #endif /* CMD_VEL_SUBSCRIBERS_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement