Fawkes API
Fawkes Development Version
|
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");
long in_msec() const
Convert the stored time into milli-seconds.
InterfaceFieldIterator fields_end()
Invalid iterator.
unsigned long int current_time()
Get current time.
void read()
Read from BlackBoard into local copy.
Thread aspect to use blocked timing.
const char * name() const
Get name of thread.
Clock * clock
By means of this member access to the clock is given.
virtual void finalize()
Finalize the thread.
Interface field iterator.
const char * name()
Get name of the skill.
AcquireControlMessage Fawkes BlackBoard Interface Message.
std::list< std::pair< std::string, std::string > > ParameterList
Parameter list.
ExecSkillMessage Fawkes BlackBoard Interface Message.
Logger * logger
This is the Logger member used to access the logger.
virtual void close(Interface *interface)=0
Close interface.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.
Fawkes library namespace.
Logging error handler for XABSL integration.
virtual void log_warn(const char *component, const char *format,...)=0
Log warning message.
virtual void once()
Execute an action exactly once.
SkillerInterface Fawkes BlackBoard Interface.
InterfaceFieldIterator fields()
Get iterator over all fields of this interface instance.
A class for handling time.
Thread class encapsulation of pthreads.
BlackBoard * blackboard
This is the BlackBoard instance you can use to interact with the BlackBoard.
XabslEngineThread()
Constructor.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
Time & stamp()
Set this time to the current time.
virtual void init()
Initialize the thread.
A NULL pointer was supplied where not allowed.
unsigned int msgq_enqueue(Message *message)
Enqueue message at end of queue.
virtual void loop()
Code to execute in the thread.
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
ObjectPositionInterface Fawkes BlackBoard Interface.
Base class for exceptions in Fawkes.