Fawkes API Fawkes Development Version
be_adapter.h
1
2/***************************************************************************
3 * be_adapter.h - PLEXIL adapter for the Behavior Engine
4 *
5 * Created: Tue Aug 14 15:21:49 2018
6 * Copyright 2006-2018 Tim Niemueller [www.niemueller.de]
7 ****************************************************************************/
8
9/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Library General Public License for more details.
18 *
19 * Read the full text in the LICENSE.GPL file in the doc directory.
20 */
21
22#ifndef __PLUGINS_PLEXIL_SKILL_ADAPTER_H_
23#define __PLUGINS_PLEXIL_SKILL_ADAPTER_H_
24
25#include <blackboard/blackboard.h>
26#include <blackboard/interface_listener.h>
27#include <config/config.h>
28#include <interfaces/SkillerInterface.h>
29#include <logging/logger.h>
30
31#include <InterfaceAdapter.hh>
32#include <Value.hh>
33#include <mutex>
34
35namespace fawkes {
36class ActionSkillMapping;
37}
38
39/** Interface adapter to provide logging facilities. */
40class BehaviorEnginePlexilAdapter : public PLEXIL::InterfaceAdapter,
42{
43public:
44 BehaviorEnginePlexilAdapter(PLEXIL::AdapterExecInterface &execInterface);
45 BehaviorEnginePlexilAdapter(PLEXIL::AdapterExecInterface &execInterface,
46 pugi::xml_node const xml);
47
48 /// @cond DELETED
52 /// @endcond
53
55
56 virtual bool initialize();
57 virtual bool start();
58 virtual bool stop();
59 virtual bool reset();
60 virtual bool shutdown();
61
62 void executeCommand(PLEXIL::Command *cmd);
63 void invokeAbort(PLEXIL::Command *cmd);
64
65 virtual void bb_interface_data_refreshed(fawkes::Interface *interface) noexcept;
66
67private:
68 struct skill_config
69 {
70 /// Specify a skill argument.
72 {
73 /// Name of skill argument
74 std::string name;
75 /// Expected type of skill argument
76 PLEXIL::ValueType type;
77 };
78
79 std::string name;
80 std::vector<skill_argument> args;
81 std::string template_str;
82 };
83
84 std::string format_skillstring(const std::vector<PLEXIL::Value> &values);
85 std::string map_skillstring(const std::string & name,
86 const skill_config & skill_config,
87 const std::vector<PLEXIL::Value> &values);
88 void call_skill(const std::string &skill_string, PLEXIL::Command *cmd);
89
90private:
91 fawkes::Configuration * config_;
92 fawkes::Logger * logger_;
93 fawkes::BlackBoard * blackboard_;
94 fawkes::SkillerInterface *skiller_if_;
95
96 std::shared_ptr<fawkes::ActionSkillMapping> action_skill_mapping_;
97
98 std::mutex exec_mutex_;
99
100 std::string skill_string_;
101 unsigned int skill_msgid_;
102
103 PLEXIL::Command *current_cmd_;
104
105 std::map<std::string, skill_config> cfg_skills_;
106};
107
108extern "C" {
109void initBehaviorEngineAdapter();
110}
111
112#endif
Interface adapter to provide logging facilities.
Definition: be_adapter.h:42
virtual ~BehaviorEnginePlexilAdapter()
Destructor.
Definition: be_adapter.cpp:61
void invokeAbort(PLEXIL::Command *cmd)
Abort currently running execution.
Definition: be_adapter.cpp:366
virtual bool shutdown()
Shut adapter down.
Definition: be_adapter.cpp:224
virtual bool reset()
Reset adapter.
Definition: be_adapter.cpp:215
virtual bool initialize()
Initialize adapter.
Definition: be_adapter.cpp:69
void executeCommand(PLEXIL::Command *cmd)
Perform given command.
Definition: be_adapter.cpp:332
virtual bool start()
Start adapter.
Definition: be_adapter.cpp:177
virtual bool stop()
Stop adapter.
Definition: be_adapter.cpp:206
virtual void bb_interface_data_refreshed(fawkes::Interface *interface) noexcept
BlackBoard data refreshed notification.
Definition: be_adapter.cpp:382
BehaviorEnginePlexilAdapter(PLEXIL::AdapterExecInterface &execInterface)
Constructor.
Definition: be_adapter.cpp:42
BlackBoard interface listener.
The BlackBoard abstract class.
Definition: blackboard.h:46
Interface for configuration handling.
Definition: config.h:68
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Interface for logging.
Definition: logger.h:42
SkillerInterface Fawkes BlackBoard Interface.
Fawkes library namespace.
PLEXIL::ValueType type
Expected type of skill argument.
Definition: be_adapter.h:76