23 #include "engine_thread.h" 24 #include "xabsl_tools.h" 25 #include "skill_wrapper.h" 27 #include <core/exceptions/software.h> 28 #include <utils/time/time.h> 29 #include <interfaces/SkillerInterface.h> 30 #include <interfaces/ObjectPositionInterface.h> 32 #include <XabslEngine/XabslEngine.h> 45 static unsigned long int 64 :
Thread(
"XabslEngineThread",
Thread::OPMODE_WAITFORWAKEUP),
74 throw Exception(
"Global XabslEngineThread has already been set.");
88 __xe =
new xabsl::Engine(*__xleh, &xet_current_time);
94 params.push_back(std::make_pair(
"x",
"double"));
95 params.push_back(std::make_pair(
"y",
"double"));
96 params.push_back(std::make_pair(
"ori",
"double"));
98 __wrappers[sw->
name()] = sw;
99 __xe->registerBasicBehavior(*sw);
101 __ball_ry = __ball_rx = NULL;
102 for (Interface::FieldIterator i = __wm_ball_if->
fields(); i != __wm_ball_if->
fields_end(); ++i) {
103 if ( strcmp(i.get_name(),
"relative_x") == 0 ) {
105 __xe->registerDecimalInputSymbol(
"ball.relative_x", __ball_rx,
107 }
else if ( strcmp(i.get_name(),
"relative_y") == 0 ) {
109 __xe->registerDecimalInputSymbol(
"ball.relative_y", __ball_ry,
115 __xe->createOptionGraph(xinput);
117 if ( __xleh->errorsOccurred ) {
119 throw Exception(
"Error while creating XABSL engine, see log for details");
176 for (__wit = __wrappers.begin(); __wit != __wrappers.end(); ++__wit) {
177 delete __wit->second;
198 logger->
log_error(
"XabslEngineThread",
"Cannot aquire exclusive skiller " 199 "control, exception follows");
209 __wm_ball_if->
read();
210 __skiller_if->
read();
214 std::string skill_string =
"";
215 for (__wit = __wrappers.begin(); __wit != __wrappers.end(); ++__wit) {
216 std::string css = __wit->second->skill_string();
218 skill_string += css +
"; ";
221 if ( skill_string !=
"" ) {
228 logger->
log_warn(
"XabslEngineThread",
"Executing skill failed, exception follows");
ObjectPositionInterface Fawkes BlackBoard Interface.
Fawkes library namespace.
unsigned long int current_time()
Get current time.
A class for handling time.
A NULL pointer was supplied where not allowed.
Thread class encapsulation of pthreads.
virtual void finalize()
Finalize the thread.
Logger * logger
This is the Logger member used to access the logger.
AcquireControlMessage Fawkes BlackBoard Interface Message.
Clock * clock
By means of this member access to the clock is given.
Thread aspect to use blocked timing.
long in_msec() const
Convert the stored time into milli-seconds.
Base class for exceptions in Fawkes.
void read()
Read from BlackBoard into local copy.
ExecSkillMessage Fawkes BlackBoard Interface Message.
const char * name() const
Get name of thread.
virtual void log_warn(const char *component, const char *format,...)=0
Log warning message.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.
virtual void once()
Execute an action exactly once.
unsigned int msgq_enqueue(Message *message)
Enqueue message at end of queue.
const char * name()
Get name of the skill.
std::list< std::pair< std::string, std::string > > ParameterList
Parameter list.
InterfaceFieldIterator fields_end()
Invalid iterator.
XabslEngineThread()
Constructor.
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
SkillerInterface Fawkes BlackBoard Interface.
Time & stamp()
Set this time to the current time.
Logging error handler for XABSL integration.
InterfaceFieldIterator fields()
Get iterator over all fields of this interface instance.
virtual void init()
Initialize the thread.
virtual void loop()
Code to execute in the thread.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
virtual void close(Interface *interface)=0
Close interface.