Fawkes API
Fawkes Development Version
|
25 #include <aspect/blocked_timing.h>
26 #include <core/exception.h>
27 #include <core/threading/thread.h>
53 : SyncPointAspect(SyncPoint::WAIT_FOR_ALL,
54 blocked_timing_hook_to_start_syncpoint(wakeup_hook),
55 blocked_timing_hook_to_end_syncpoint(wakeup_hook))
57 add_aspect(
"BlockedTimingAspect");
58 wakeup_hook_ = wakeup_hook;
65 delete loop_listener_;
118 default:
throw Exception(
"Unknown blocked timing wakeup hook");
122 const std::map<const BlockedTimingAspect::WakeupHook, const std::string>
124 {WAKEUP_HOOK_SENSOR_ACQUIRE,
"/sensors/acquire"},
125 {WAKEUP_HOOK_SENSOR_PREPARE,
"/sensors/prepare"},
126 {WAKEUP_HOOK_SENSOR_PROCESS,
"/sensors/process"},
127 {WAKEUP_HOOK_WORLDSTATE,
"/worldstate"},
128 {WAKEUP_HOOK_THINK,
"/agent"},
129 {WAKEUP_HOOK_SKILL,
"/skill"},
130 {WAKEUP_HOOK_ACT,
"/act/main"},
131 {WAKEUP_HOOK_ACT_EXEC,
"/act/exec"},
132 {WAKEUP_HOOK_POST_LOOP,
"/postloop"}};
144 }
catch (
const std::out_of_range &e) {
145 throw Exception(
"Unknown blocked timing wakeup hook. Error: %s", e.what());
159 }
catch (
const std::out_of_range &e) {
160 throw Exception(
"Unknown blocked timing wakeup hook. Error: %s", e.what());
@ WAKEUP_HOOK_WORLDSTATE
world state thread
void init_BlockedTimingAspect(Thread *thread)
Init BlockedTiming aspect.
static std::string blocked_timing_hook_to_start_syncpoint(WakeupHook hook)
Get the syncpoint identifier corresponding to the start of a wakeup hook.
@ WAKEUP_HOOK_SENSOR_PREPARE
sensor data preparation thread, convert acquired data to usable format
void finalize_BlockedTimingAspect(Thread *thread)
Finalize BlockedTiming aspect.
void wakeup()
Wake up thread.
static const std::map< const WakeupHook, const std::string > hook_to_syncpoint
Translation from WakeupHooks to SyncPoints.
@ WAKEUP_HOOK_THINK
think thread (agent)
void add_loop_listener(ThreadLoopListener *loop_listener)
Add loop listener.
@ WAKEUP_HOOK_SENSOR_PROCESS
sensor data processing thread
@ WAKEUP_HOOK_ACT_EXEC
act execution thread
@ WAKEUP_HOOK_PRE_LOOP
before each loop
@ WAKEUP_HOOK_ACT
act thread (motor module etc.)
WakeupHook blockedTimingAspectHook() const
Get the wakeup hook.
WakeupHook
Type to define at which hook the thread is woken up.
void post_loop(Thread *thread)
The post loop function of the BlockedTimingAspect This function is called right after the loop of the...
BlockedTimingAspect(WakeupHook wakeup_hook)
Constructor.
static std::string blocked_timing_hook_to_end_syncpoint(WakeupHook hook)
Get the syncpoint identifier corresponding to the end of a wakeup hook.
static const char * blocked_timing_hook_to_string(WakeupHook hook)
Get string for wakeup hook.
@ WAKEUP_HOOK_POST_LOOP
run after loop
@ WAKEUP_HOOK_SKILL
skill thread (skill module)
void remove_loop_listener(ThreadLoopListener *loop_listener)
Remove loop listener.
@ WAKEUP_HOOK_SENSOR_ACQUIRE
sensor acquisition thread, acquire data from sensor
virtual ~BlockedTimingAspect()
Virtual empty destructor.