00001 // Copyright (C) 2010-2011 Institut de Robotica i Informatica Industrial, CSIC-UPC. 00002 // Author 00003 // All rights reserved. 00004 // 00005 // This file is part of iri-ros-pkg 00006 // iri-ros-pkg is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation, either version 3 of the License, or 00009 // at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 // 00019 // IMPORTANT NOTE: This code has been generated through a script from the 00020 // iri_ros_scripts. Please do NOT delete any comments to guarantee the correctness 00021 // of the scripts. ROS topics can be easly add by using those scripts. Please 00022 // refer to the IRI wiki page for more information: 00023 // http://wikiri.upc.es/index.php/Robotics_Lab 00024 00025 #ifndef _rule_learner_alg_node_h_ 00026 #define _rule_learner_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "rule_learner_alg.h" 00030 00031 // [publisher subscriber headers] 00032 00033 // [service client headers] 00034 //#include <iri_rule_learner/LearnWithPasula.h> 00035 #include <iri_learning_msgs/LearnRulesFromTransitions.h> 00036 #include <estirabot_msgs/RepresentationToString.h> 00037 #include <estirabot_msgs/StateRepresentationChanges.h> 00038 #include <estirabot_msgs/AddState.h> 00039 #include <estirabot_msgs/AddAction.h> 00040 00041 // [action server client headers] 00042 00043 // #include <fstream> 00044 00049 class RuleLearnerAlgNode : public algorithm_base::IriBaseAlgorithm<RuleLearnerAlgorithm> 00050 { 00051 private: 00052 // [publisher attributes] 00053 00054 // [subscriber attributes] 00055 00056 // [service attributes] 00057 // ros::ServiceServer learn_with_pasula_server_; 00058 // bool learn_with_pasulaCallback(iri_rule_learner::LearnWithPasula::Request &req, iri_rule_learner::LearnWithPasula::Response &res); 00059 // CMutex learn_with_pasula_mutex_; 00060 ros::ServiceServer add_state_server_; 00061 bool add_stateCallback(estirabot_msgs::AddState::Request &req, estirabot_msgs::AddState::Response &res); 00062 CMutex add_state_mutex_; 00063 ros::ServiceServer add_action_server_; 00064 bool add_actionCallback(estirabot_msgs::AddAction::Request &req, estirabot_msgs::AddAction::Response &res); 00065 CMutex add_action_mutex_; 00066 00067 // [client attributes] 00068 ros::ServiceClient learn_pasula_client_; 00069 iri_learning_msgs::LearnRulesFromTransitions learn_pasula_srv_; 00070 ros::ServiceClient representation_to_string_client_; 00071 estirabot_msgs::RepresentationToString representation_to_string_srv_; 00072 ros::ServiceClient get_state_changes_client_; 00073 estirabot_msgs::StateRepresentationChanges get_state_changes_srv_; 00074 00075 // [action server attributes] 00076 00077 // [action client attributes] 00078 00079 // sensor_msgs::Image last_image_; 00080 Symbol last_action_; 00081 std::string last_state_; 00082 // std::vector<estirabot_msgs::PointsDistanceMsg> last_distances_; 00083 std::vector<estirabot_msgs::DirtyArea> dirty_areas_; 00084 // std::vector<uint> target_dirty_areas_; 00085 00086 bool needs_learning_; 00087 00088 ros::Duration pasula_time_; 00089 uint pasula_iter_; 00090 00091 00092 00093 00094 public: 00101 RuleLearnerAlgNode(void); 00102 00109 ~RuleLearnerAlgNode(void); 00110 00111 protected: 00124 void mainNodeThread(void); 00125 00138 void node_config_update(Config &config, uint32_t level); 00139 00146 void addNodeDiagnostics(void); 00147 00148 // [diagnostic functions] 00149 00150 // [test functions] 00151 }; 00152 00153 #endif