Fawkes API
Fawkes Development Version
test_plugin.cpp
1
/***************************************************************************
2
* test_plugin.cpp - SyncPoint Test plugin
3
*
4
* Created: Wed Mar 04 17:57:42 2015
5
* Copyright 2015 Till Hofmann
6
****************************************************************************/
7
8
/* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Library General Public License for more details.
17
*
18
* Read the full text in the LICENSE.GPL file in the doc directory.
19
*/
20
21
#include "test_thread.h"
22
23
#include <aspect/blocked_timing.h>
24
#include <core/plugin.h>
25
26
#include <algorithm>
27
#include <vector>
28
29
using namespace
fawkes
;
30
31
/** Plugin to test syncpoints
32
* @author Till Hofmann
33
*/
34
class
SyncPointTestPlugin
:
public
fawkes::Plugin
35
{
36
public
:
37
/** Constructor.
38
* @param config Fawkes configuration
39
*/
40
explicit
SyncPointTestPlugin
(
Configuration
*config) :
Plugin
(config)
41
{
42
std::vector<BlockedTimingAspect::WakeupHook> hooks;
43
hooks = {
44
BlockedTimingAspect::WAKEUP_HOOK_PRE_LOOP
,
/**< before each loop */
45
BlockedTimingAspect::WAKEUP_HOOK_SENSOR_ACQUIRE
,
/**< sensor acquisition thread,
46
* acquire data from sensor */
47
BlockedTimingAspect::WAKEUP_HOOK_SENSOR_PREPARE
,
/**< sensor data preparation thread,
48
* convert acquired data to usable format */
49
BlockedTimingAspect::WAKEUP_HOOK_SENSOR_PROCESS
,
/**< sensor data processing thread */
50
BlockedTimingAspect::WAKEUP_HOOK_WORLDSTATE
,
/**< world state thread */
51
BlockedTimingAspect::WAKEUP_HOOK_THINK
,
/**< think thread (agent) */
52
BlockedTimingAspect::WAKEUP_HOOK_SKILL
,
/**< skill thread (skill module) */
53
BlockedTimingAspect::WAKEUP_HOOK_ACT
,
/**< act thread (motor module etc.) */
54
BlockedTimingAspect::WAKEUP_HOOK_ACT_EXEC
,
/**< act execution thread */
55
BlockedTimingAspect::WAKEUP_HOOK_POST_LOOP
/**< run after loop */
56
};
57
58
for
(std::vector<BlockedTimingAspect::WakeupHook>::iterator it = hooks.begin();
59
it != hooks.end();
60
++it) {
61
std::string name =
"SyncPointTestThread-"
;
62
std::string hook_name =
BlockedTimingAspect::blocked_timing_hook_to_string
(*it);
63
std::transform(hook_name.begin(), hook_name.end(), hook_name.begin(), ::tolower);
64
name.append(hook_name);
65
thread_list.push_back(
new
SyncPointTestThread
(name.c_str(), *it));
66
}
67
}
68
};
69
70
PLUGIN_DESCRIPTION(
"Test SyncPoints and BlockedTimingAspect"
)
71
EXPORT_PLUGIN(
SyncPointTestPlugin
)
fawkes::BlockedTimingAspect::WAKEUP_HOOK_WORLDSTATE
world state thread
Definition:
blocked_timing.h:69
fawkes::BlockedTimingAspect::WAKEUP_HOOK_SENSOR_PREPARE
sensor data preparation thread, convert acquired data to usable format
Definition:
blocked_timing.h:66
SyncPointTestPlugin
Plugin to test syncpoints.
Definition:
test_plugin.cpp:34
fawkes::BlockedTimingAspect::WAKEUP_HOOK_THINK
think thread (agent)
Definition:
blocked_timing.h:70
SyncPointTestPlugin::SyncPointTestPlugin
SyncPointTestPlugin(Configuration *config)
Constructor.
Definition:
test_plugin.cpp:40
SyncPointTestThread
Definition:
test_thread.h:27
fawkes::Configuration
Definition:
config.h:68
fawkes::BlockedTimingAspect::WAKEUP_HOOK_SENSOR_PROCESS
sensor data processing thread
Definition:
blocked_timing.h:68
fawkes::BlockedTimingAspect::WAKEUP_HOOK_ACT_EXEC
act execution thread
Definition:
blocked_timing.h:73
fawkes
fawkes::BlockedTimingAspect::WAKEUP_HOOK_PRE_LOOP
before each loop
Definition:
blocked_timing.h:63
fawkes::BlockedTimingAspect::WAKEUP_HOOK_ACT
act thread (motor module etc.)
Definition:
blocked_timing.h:72
fawkes::BlockedTimingAspect::blocked_timing_hook_to_string
static const char * blocked_timing_hook_to_string(WakeupHook hook)
Get string for wakeup hook.
Definition:
blocked_timing.cpp:109
fawkes::BlockedTimingAspect::WAKEUP_HOOK_POST_LOOP
run after loop
Definition:
blocked_timing.h:74
fawkes::BlockedTimingAspect::WAKEUP_HOOK_SKILL
skill thread (skill module)
Definition:
blocked_timing.h:71
fawkes::BlockedTimingAspect::WAKEUP_HOOK_SENSOR_ACQUIRE
sensor acquisition thread, acquire data from sensor
Definition:
blocked_timing.h:64
fawkes::Plugin
Definition:
plugin.h:37
src
plugins
syncpoint-test
test_plugin.cpp
Generated by
1.8.16