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 
37  public fawkes::LoggingAspect,
42 {
43 public:
45 
46  virtual void init();
47  virtual void finalize();
48  virtual void loop();
49 
50  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
51 protected:
52  virtual void
53  run()
54  {
55  Thread::run();
56  }
57 
58 private:
59  struct action
60  {
61  std::string name;
62  std::vector<std::string> args;
63  };
64  fawkes::PddlPlannerInterface *plan_if_;
65  std::string cfg_descripton_path_;
66  std::string cfg_result_path_;
67  std::string cfg_domain_path_;
68  std::string cfg_problem_path_;
69  std::string cfg_fd_options_;
70  std::string cfg_collection_;
71 
72  std::vector<action> action_list_;
73 
74  std::function<void()> planner_;
75 
76  void ff_planner();
77  void fd_planner();
78  void dbmp_planner();
79  mongo::BSONObj BSONFromActionList();
80  static size_t find_nth_space(const std::string &s, size_t nth);
81  void print_action_list();
82  std::string run_planner(std::string command);
83  virtual bool bb_interface_message_received(fawkes::Interface *interface,
84  fawkes::Message * message) throw();
85 };
86 
87 #endif
virtual void init()
Initialize the thread.
Thread aspect to get access to a the RobotMemory.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:33
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:41
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread class encapsulation of pthreads.
Definition: thread.h:45
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:78
PddlPlannerThread()
Constructor.
Starts a pddl planner and writes the resulting plan into the robot memory.
const char * name() const
Get name of thread.
Definition: thread.h:100
Thread aspect to log output.
Definition: logging.h:32
virtual void finalize()
Finalize the thread.
Thread aspect to access configuration data.
Definition: configurable.h:32
virtual void loop()
Thread is only waked up if there was a new interface message to plan.
BlackBoard interface listener.