00001 00027 #ifndef RIDGEBACK_BASE_RIDGEBACK_LIGHTING_H 00028 #define RIDGEBACK_BASE_RIDGEBACK_LIGHTING_H 00029 00030 #include<vector> 00031 00032 #include "ros/ros.h" 00033 00034 #include "geometry_msgs/Twist.h" 00035 #include "ridgeback_msgs/Lights.h" 00036 #include "ridgeback_msgs/Status.h" 00037 #include "puma_motor_msgs/MultiStatus.h" 00038 00039 namespace ridgeback_base 00040 { 00041 00042 typedef boost::array<uint32_t, 8> pattern; 00043 typedef std::vector<pattern> LightsPatterns; 00044 00045 00046 class RidgebackLighting 00047 { 00048 public: 00049 explicit RidgebackLighting(ros::NodeHandle* nh); 00050 00051 private: 00052 ros::NodeHandle* nh_; 00053 00054 ros::Publisher lights_pub_; 00055 00056 ros::Subscriber user_cmds_sub_; 00057 ros::Subscriber mcu_status_sub_; 00058 ros::Subscriber puma_status_sub_; 00059 ros::Subscriber cmd_vel_sub_; 00060 00061 puma_motor_msgs::MultiStatus pumas_status_msg_; 00062 ridgeback_msgs::Status mcu_status_msg_; 00063 geometry_msgs::Twist cmd_vel_msg_; 00064 00065 ros::Timer pub_timer_; 00066 ros::Timer user_timeout_; 00067 00068 bool allow_user_; 00069 bool user_publishing_; 00070 uint8_t state_; 00071 uint8_t old_state_; 00072 uint8_t current_pattern_count_; 00073 uint32_t current_pattern_[8]; 00074 00075 struct patterns 00076 { 00077 LightsPatterns stopped; 00078 LightsPatterns fault; 00079 LightsPatterns reset; 00080 LightsPatterns low_battery; 00081 LightsPatterns charged; 00082 LightsPatterns charging; 00083 LightsPatterns driving; 00084 LightsPatterns idle; 00085 } 00086 patterns_; 00087 00088 void setRGB(ridgeback_msgs::RGB* rgb, uint32_t colour); 00089 void setLights(ridgeback_msgs::Lights* lights, uint32_t pattern[8]); 00090 00091 void updateState(); 00092 void updatePattern(); 00093 00094 void userCmdCallback(const ridgeback_msgs::Lights::ConstPtr& lights_msg); 00095 void mcuStatusCallback(const ridgeback_msgs::Status::ConstPtr& status_msg); 00096 void cmdVelCallback(const geometry_msgs::Twist::ConstPtr& msg); 00097 void pumaStatusCallback(const puma_motor_msgs::MultiStatus::ConstPtr& status_msg); 00098 void timerCb(const ros::TimerEvent&); 00099 void userTimeoutCb(const ros::TimerEvent&); 00100 }; 00101 00102 } // namespace ridgeback_base 00103 00104 #endif // RIDGEBACK_BASE_RIDGEBACK_LIGHTING_H