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 
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) noexcept;
87 };
88 
89 #endif
Starts a pddl planner and writes the resulting plan into the robot memory.
PddlPlannerThread()
Constructor.
virtual void init()
Initialize the thread.
virtual void finalize()
Finalize the thread.
virtual void loop()
Thread is only waked up if there was a new interface message to plan.
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
BlackBoard interface listener.
Thread aspect to access configuration data.
Definition: configurable.h:33
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Thread aspect to log output.
Definition: logging.h:33
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
Thread aspect to get access to a the RobotMemory.
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100