Fawkes API  Fawkes Development Version
pddl-planner_thread.h
1 
2 /***************************************************************************
3  * pddl-planner_thread.h - pddl-planner
4  *
5  * Created: Wed Dec 7 19:09:44 2016
6  * Copyright 2016 Frederik Zwilling
7  * 2017 Matthias Loebach
8  * 2017 Till Hofmann
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL file in the doc directory.
22  */
23 
24 #ifndef _PLUGINS_PDDL_PLANNER_THREAD_H_
25 #define _PLUGINS_PDDL_PLANNER_THREAD_H_
26 
27 #include <aspect/blackboard.h>
28 #include <aspect/blocked_timing.h>
29 #include <aspect/configurable.h>
30 #include <aspect/logging.h>
31 #include <blackboard/interface_listener.h>
32 #include <core/threading/thread.h>
33 #include <interfaces/PddlPlannerInterface.h>
34 #include <plugins/robot-memory/aspect/robot_memory_aspect.h>
35 
36 #include <bsoncxx/document/value.hpp>
37 
38 class PddlPlannerThread : public fawkes::Thread,
39  public fawkes::LoggingAspect,
44 {
45 public:
47 
48  virtual void init();
49  virtual void finalize();
50  virtual void loop();
51 
52  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
53 protected:
54  virtual void
55  run()
56  {
57  Thread::run();
58  }
59 
60 private:
61  struct action
62  {
63  std::string name;
64  std::vector<std::string> args;
65  };
66  fawkes::PddlPlannerInterface *plan_if_;
67  std::string cfg_descripton_path_;
68  std::string cfg_result_path_;
69  std::string cfg_domain_path_;
70  std::string cfg_problem_path_;
71  std::string cfg_fd_options_;
72  std::string cfg_collection_;
73 
74  std::vector<action> action_list_;
75 
76  std::function<void()> planner_;
77 
78  void ff_planner();
79  void fd_planner();
80  void dbmp_planner();
81  bsoncxx::document::value BSONFromActionList();
82  static size_t find_nth_space(const std::string &s, size_t nth);
83  void print_action_list();
84  std::string run_planner(std::string command);
85  virtual bool bb_interface_message_received(fawkes::Interface *interface,
86  fawkes::Message * message) throw();
87 };
88 
89 #endif
PddlPlannerThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: pddl-planner_thread.h:60
fawkes::Message
Definition: message.h:40
PddlPlannerThread::PddlPlannerThread
PddlPlannerThread()
Constructor.
Definition: pddl-planner_thread.cpp:45
fawkes::BlackBoardInterfaceListener
Definition: interface_listener.h:45
fawkes::Thread::name
const char * name() const
Definition: thread.h:99
fawkes::BlackBoardAspect
Definition: blackboard.h:36
fawkes::LoggingAspect
Definition: logging.h:36
fawkes::Interface
Definition: interface.h:77
PddlPlannerThread::loop
virtual void loop()
Thread is only waked up if there was a new interface message to plan.
Definition: pddl-planner_thread.cpp:102
PddlPlannerThread::finalize
virtual void finalize()
Finalize the thread.
Definition: pddl-planner_thread.cpp:128
fawkes::Thread
Definition: thread.h:44
fawkes::ConfigurableAspect
Definition: configurable.h:36
fawkes::RobotMemoryAspect
Definition: robot_memory_aspect.h:37
PddlPlannerThread::init
virtual void init()
Initialize the thread.
Definition: pddl-planner_thread.cpp:52
PddlPlannerThread
Definition: pddl-planner_thread.h:37