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");
Interface field iterator.
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.