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 _prada_planner_alg_h_ 00026 #define _prada_planner_alg_h_ 00027 00028 #include <iri_prada_planner/PradaPlannerConfig.h> 00029 #include "mutex.h" 00030 00031 //include prada_planner_alg main library 00032 // #include <TL/logicDefinitions.h> 00033 // #include <TL/ruleReasoning.h> 00034 // #include <TL/prada.h> 00035 #include <relational/prada.h> 00036 #include <relational/robotManipulationSymbols.h> 00037 00038 //#include <iri_planning_msgs/PradaPlanSrv.h> 00039 00040 // std::min 00041 #include <algorithm> 00042 00048 class PradaPlannerAlgorithm 00049 { 00050 protected: 00057 CMutex alg_mutex_; 00058 00059 // private attributes and methods 00060 relational::RuleSet* rules; 00061 // relational::RuleSet *ground_rules; 00062 relational::Reward* reward; 00063 relational::NID_Planner* planner; 00064 relational::SymbolicState * state; 00065 00066 // config files parameters 00067 std::string conf_file_language, conf_file_reward, conf_file_rules, conf_file_state; 00068 00069 // planning for board / small objects 00070 bool board_plan; 00071 00072 // prada parameters 00073 int max_prada_horizon, prada_num_samples; 00074 double prada_discount_factor, prada_noise_softener; 00075 00076 00077 public: 00084 typedef iri_prada_planner::PradaPlannerConfig Config; 00085 00092 Config config_; 00093 00102 PradaPlannerAlgorithm(void); 00103 00109 void lock(void) { alg_mutex_.enter(); }; 00110 00116 void unlock(void) { alg_mutex_.exit(); }; 00117 00125 bool try_enter(void) { return alg_mutex_.try_enter(); }; 00126 00138 void config_update(Config& new_cfg, uint32_t level=0); 00139 00140 // here define all prada_planner_alg interface methods to retrieve and set 00141 // the driver parameters 00142 00149 ~PradaPlannerAlgorithm(void); 00150 00151 00152 void initializePlan(); 00153 00154 void setPlanStateFromFile(); 00155 00156 void setupPlanner(relational::SymbolicState *state); 00157 00158 relational::Literal* getSinglePlan(uint32_t plan_length); 00159 00160 relational::LitL getCompletePlan(uint32_t plan_length); 00161 00162 void reloadRules(); 00163 00164 00177 uint32_t getRecommendedPlanLength(uint32_t ellipses_size); 00178 }; 00179 00180 #endif