23 #include "engine_thread.h"
25 #include "skill_wrapper.h"
26 #include "xabsl_tools.h"
28 #include <XabslEngine/XabslEngine.h>
29 #include <core/exceptions/software.h>
30 #include <interfaces/ObjectPositionInterface.h>
31 #include <interfaces/SkillerInterface.h>
32 #include <utils/time/time.h>
44 static unsigned long int
62 :
Thread(
"XabslEngineThread",
Thread::OPMODE_WAITFORWAKEUP),
71 throw Exception(
"Global XabslEngineThread has already been set.");
85 xe_ =
new xabsl::Engine(*xleh_, &xet_current_time);
91 params.push_back(std::make_pair(
"x",
"double"));
92 params.push_back(std::make_pair(
"y",
"double"));
93 params.push_back(std::make_pair(
"ori",
"double"));
95 wrappers_[sw->
name()] = sw;
96 xe_->registerBasicBehavior(*sw);
98 ball_ry_ = ball_rx_ = NULL;
100 if (strcmp(i.get_name(),
"relative_x") == 0) {
103 (
float *)i.get_value());
104 xe_->registerDecimalInputSymbol(
"ball.relative_x",
106 (
double (xabsl::FunctionProvider::*)())
108 }
else if (strcmp(i.get_name(),
"relative_y") == 0) {
111 (
float *)i.get_value());
112 xe_->registerDecimalInputSymbol(
"ball.relative_y",
114 (
double (xabsl::FunctionProvider::*)())
120 xe_->createOptionGraph(xinput);
122 if (xleh_->errorsOccurred) {
124 throw Exception(
"Error while creating XABSL engine, see log for details");
180 for (wit_ = wrappers_.begin(); wit_ != wrappers_.end(); ++wit_) {
204 "Cannot aquire exclusive skiller "
205 "control, exception follows");
220 std::string skill_string =
"";
221 for (wit_ = wrappers_.begin(); wit_ != wrappers_.end(); ++wit_) {
222 std::string css = wit_->second->skill_string();
224 skill_string += css +
"; ";
227 if (skill_string !=
"") {
234 logger->
log_warn(
"XabslEngineThread",
"Executing skill failed, exception follows");
virtual void once()
Execute an action exactly once.
virtual void init()
Initialize the thread.
virtual void loop()
Code to execute in the thread.
virtual void finalize()
Finalize the thread.
XabslEngineThread()
Constructor.
unsigned long int current_time()
Get current time.
Logging error handler for XABSL integration.
std::list< std::pair< std::string, std::string > > ParameterList
Parameter list.
const char * name()
Get name of the skill.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
virtual void close(Interface *interface)=0
Close interface.
Thread aspect to use blocked timing.
Clock * clock
By means of this member access to the clock is given.
Base class for exceptions in Fawkes.
Interface field iterator.
InterfaceFieldIterator fields_end()
Invalid iterator.
InterfaceFieldIterator fields()
Get iterator over all fields of this interface instance.
void read()
Read from BlackBoard into local copy.
unsigned int msgq_enqueue(Message *message)
Enqueue message at end of queue.
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
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.
Logger * logger
This is the Logger member used to access the logger.
A NULL pointer was supplied where not allowed.
ObjectPositionInterface Fawkes BlackBoard Interface.
AcquireControlMessage Fawkes BlackBoard Interface Message.
ExecSkillMessage Fawkes BlackBoard Interface Message.
SkillerInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
const char * name() const
Get name of thread.
A class for handling time.
Time & stamp()
Set this time to the current time.
long in_msec() const
Convert the stored time into milli-seconds.
Fawkes library namespace.