cost_learner.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <std_srvs/Empty.h>
00003 
00004 #include <bwi_planning/cost_learner.h>
00005 #include <bwi_planning/CostLearnerInterface.h>
00006 
00007 boost::shared_ptr<bwi_planning::CostLearner> learner_;
00008 
00009 bool incrementEpisode(std_srvs::Empty::Request &req, 
00010     std_srvs::Empty::Response &res) {
00011   learner_->finalizeEpisode();
00012 }
00013 
00014 bool addSample(bwi_planning::CostLearnerInterface::Request &req, 
00015     bwi_planning::CostLearnerInterface::Response &res) {
00016   res.status = "";
00017   res.success = learner_->addSample(req.location, req.door_from, req.door_to,
00018       req.cost);
00019   if (!res.success) {
00020     res.status = "Invalid arguments. Please recheck!";
00021   }
00022 }
00023 
00024 int main(int argc, char **argv) {
00025 
00026   ros::init(argc, argv, "cost_learner");
00027   ros::NodeHandle n, private_nh("~");
00028 
00029   learner_.reset(new bwi_planning::CostLearner);
00030 
00031   ros::ServiceServer episode_service = 
00032     private_nh.advertiseService("increment_episode", incrementEpisode);
00033   ros::ServiceServer sample_service = 
00034     private_nh.advertiseService("add_sample", addSample);
00035   ros::spin();
00036 
00037   return 0;
00038 
00039 }


bwi_planning
Author(s): Piyush Khandelwal , Fangkai Yang
autogenerated on Wed Aug 26 2015 10:54:52