Fawkes API Fawkes Development Version
remote_skiller_executor.cpp
1/***************************************************************************
2 * remote_skiller_executor.cpp - Execute Golog++ actions as skills remotely
3 *
4 * Created: Tue 03 Dec 2019 14:33:43 CET 14:33
5 * Copyright 2019 Till Hofmann <hofmann@kbsg.rwth-aachen.de>
6 ****************************************************************************/
7
8/* This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Library General Public License for more details.
17 *
18 * Read the full text in the LICENSE.GPL file in the doc directory.
19 */
20
21#include "remote_skiller_executor.h"
22
23#include <blackboard/remote.h>
24#include <golog++/model/activity.h>
25
26namespace fawkes {
27namespace gpp {
28
29/** @class RemoteSkillerActionExecutor
30 * An ActionExecutor that executes an activity using a Skiller on a remote.
31 * The executor connects to a remote blackboard and instructs the remote to execute the respective skill.
32 * The mapping of an activity to a skill works the same way as for local skills.
33 * @author Till Hofmann
34 * @see SkillerActionExecutor
35 * @see ActionSkillMapping
36 */
37
38/** Constructor.
39 * Connect to the given remote host and use that host's skiller interface.
40 * @param logger The logger instance to use
41 * @param agent_param_name The parameter key to use for checking if this action should be executed on this agent
42 * @param agent_param_value The name of the remote agent; only execute the action if it matches this agent name
43 * @param hostname The remote hostname to connect to
44 * @param port The port to connect to
45 * @param config The config to read the skill mapping from
46 * @param cfg_prefix The spec-specific config prefix to use
47 */
49 const std::string &agent_param_name,
50 const std::string &agent_param_value,
51 const std::string &hostname,
52 unsigned short int port,
53 Configuration * config,
54 const std::string &cfg_prefix)
55: SkillerActionExecutor(logger, new RemoteBlackBoard(hostname.c_str(), port), config, cfg_prefix),
56 agent_param_name_(agent_param_name),
57 agent_param_value_(agent_param_value)
58{
59 blackboard_owner_ = true;
60}
61
62RemoteSkillerActionExecutor::~RemoteSkillerActionExecutor()
63{
64}
65
66bool
67RemoteSkillerActionExecutor::can_execute_activity(std::shared_ptr<gologpp::Activity> activity) const
68{
70 return false;
71 }
72 if (!activity->target()->mapping().is_mapped(agent_param_name_)) {
73 return false;
74 }
75 return (static_cast<std::string>(activity->mapped_arg_value(agent_param_name_))
76 == agent_param_value_);
77}
78
79/** Get the name of the executor; mainly used for logging.
80 * @return The human-readable name of the executor
81 */
82const char *
84{
85 return "RemoteSkillerActionExecutor";
86}
87
88} // namespace gpp
89} // namespace fawkes
Interface for configuration handling.
Definition: config.h:68
Interface for logging.
Definition: logger.h:42
Remote BlackBoard.
Definition: remote.h:50
RemoteSkillerActionExecutor(Logger *logger, const std::string &agent_name_key, const std::string &agent_name_value, const std::string &hostname, unsigned short int port, Configuration *config, const std::string &cfg_prefix)
Constructor.
const char * name() const
Get the name of the executor; mainly used for logging.
bool can_execute_activity(std::shared_ptr< gologpp::Activity > activity) const override
Determine if this executor can execute the given activity.
An ActionExecutor that executes an activity using the Skiller.
bool blackboard_owner_
True if this executor is owning its blackboard.
bool can_execute_activity(std::shared_ptr< gologpp::Activity > activity) const override
Check if we can execute the given activity.
Fawkes library namespace.