23 #include "periodic_exec_thread.h"
25 #include <core/exceptions/software.h>
26 #include <core/exceptions/system.h>
27 #include <core/threading/mutex.h>
28 #include <logging/component.h>
30 #include <lua/context.h>
31 #include <lua/interface_importer.h>
33 #include <interfaces/SkillerInterface.h>
34 #include <interfaces/SkillerDebugInterface.h>
40 using namespace fawkes;
54 :
Thread(
"LuaAgentPeriodicExecutionThread",
Thread::OPMODE_WAITFORWAKEUP),
72 LuaAgentPeriodicExecutionThread::init_failure_cleanup()
88 "Fawkes is no longer in a clean state. Restart!");
100 e.
append(
"Insufficient configuration for LuaAgent");
104 logger->
log_debug(
"LuaAgentPeriodicExecutionThread",
"Agent: %s", __cfg_agent.c_str());
113 std::string reading_prefix =
"/luaagent/interfaces/" + __cfg_agent +
"/reading/";
114 std::string writing_prefix =
"/luaagent/interfaces/" + __cfg_agent +
"/writing/";
118 __skiller_if->
read();
120 throw Exception(
"Skiller already has an exclusive controller");
128 if (__cfg_watch_files) {
148 __lua->
set_string(
"AGENT", __cfg_agent.c_str());
150 __lua->
set_usertype(
"logger", __clog,
"ComponentLogger",
"fawkes");
153 __lua->
set_usertype(
"tf", tf_listener,
"Transformer",
"fawkes::tf");
163 init_failure_cleanup();
189 LuaAgentPeriodicExecutionThread::process_agdbg_messages()
195 std::string graphdir =
"TB";
197 case SkillerDebugInterface::GD_BOTTOM_TOP: graphdir =
"BT";
break;
198 case SkillerDebugInterface::GD_LEFT_RIGHT: graphdir =
"LR";
break;
199 case SkillerDebugInterface::GD_RIGHT_LEFT: graphdir =
"RL";
break;
202 __lua->
do_string(
"agentenv.set_graphdir(\"%s\")", graphdir.c_str());
204 logger->
log_warn(
"LuaAgentPeriodicExecutionThread",
"Failed to set graph direction, exception follows");
212 logger->
log_warn(
"LuaAgentPeriodicExecutionThread",
"Failed to set graph direction, exception follows");
229 process_agdbg_messages();
232 __skiller_if->
read();
238 logger->
log_error(
"LuaAgentPeriodicExecutionThread",
"Execution of %s.execute() failed, exception follows",
239 __cfg_agent.c_str());