00001 #include "screen_information_alg_node.h" 00002 00003 ScreenInformationAlgNode::ScreenInformationAlgNode(void) : 00004 algorithm_base::IriBaseAlgorithm<ScreenInformationAlgorithm>() 00005 { 00006 //init class attributes if necessary 00007 //this->loop_rate_ = 2;//in [Hz] 00008 00009 // [init publishers] 00010 00011 // [init subscribers] 00012 this->answerCode_subscriber_ = this->public_node_handle_.subscribe("answerCode", 100, &ScreenInformationAlgNode::answerCode_callback, this); 00013 00014 // [init services] 00015 00016 // [init clients] 00017 00018 // [init action servers] 00019 00020 // [init action clients] 00021 00022 this->public_node_handle_.getParam("path", this->alg_.path); 00023 this->alg_.initialize(); 00024 } 00025 00026 ScreenInformationAlgNode::~ScreenInformationAlgNode(void) 00027 { 00028 // [free dynamic memory] 00029 } 00030 00031 void ScreenInformationAlgNode::mainNodeThread(void) 00032 { 00033 this->alg_.lock(); 00034 this->alg_.iteration(); 00035 this->alg_.unlock(); 00036 // [fill msg structures] 00037 00038 // [fill srv structure and make request to the server] 00039 00040 // [fill action structure and make request to the action server] 00041 00042 // [publish messages] 00043 } 00044 00045 /* [subscriber callbacks] */ 00046 void ScreenInformationAlgNode::answerCode_callback(const iri_perception_msgs::voiceRecognitionAnswer::ConstPtr& msg) 00047 { 00048 //ROS_INFO("ScreenInformationAlgNode::answerCode_callback: New Message Received"); 00049 00050 //use appropiate mutex to shared variables if necessary 00051 this->alg_.lock(); 00052 //this->answerCode_mutex_.enter(); 00053 00054 //std::cout << msg->data << std::endl; 00055 this->alg_.setCode(msg->code); 00056 this->alg_.setAnswer(msg->answer); 00057 00058 //unlock previously blocked shared variables 00059 this->alg_.unlock(); 00060 //this->answerCode_mutex_.exit(); 00061 } 00062 00063 /* [service callbacks] */ 00064 00065 /* [action callbacks] */ 00066 00067 /* [action requests] */ 00068 00069 void ScreenInformationAlgNode::node_config_update(Config &config, uint32_t level) 00070 { 00071 this->alg_.lock(); 00072 00073 this->alg_.unlock(); 00074 } 00075 00076 void ScreenInformationAlgNode::addNodeDiagnostics(void) 00077 { 00078 } 00079 00080 /* main function */ 00081 int main(int argc,char *argv[]) 00082 { 00083 return algorithm_base::main<ScreenInformationAlgNode>(argc, argv, "screen_information_alg_node"); 00084 }