Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
thread.cpp
1
2
/***************************************************************************
3
* thread.cpp - Fawkes ball position logger - for demonstration
4
*
5
* Created: Thu Jan 24 17:03:56 2008
6
* Copyright 2008 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#include <plugins/examples/ballposlog/thread.h>
24
#include <interfaces/ObjectPositionInterface.h>
25
26
/** @class BallPosLogThread thread.h "thread.h"
27
* Main thread of ball position logger plugin.
28
* @author Tim Niemueller
29
*/
30
31
using namespace
fawkes;
32
33
/** Constructor.
34
*/
35
BallPosLogThread::BallPosLogThread
()
36
:
Thread
(
"BallPosLogThread"
,
37
Thread
::OPMODE_WAITFORWAKEUP),
38
BlockedTimingAspect
(
39
BlockedTimingAspect
::WAKEUP_HOOK_THINK)
40
{
41
}
42
43
44
/** Destructor. */
45
BallPosLogThread::~BallPosLogThread
()
46
{
47
}
48
49
50
void
51
BallPosLogThread::init
()
52
{
53
wm_ball_interface = NULL;
54
try
{
55
wm_ball_interface =
56
blackboard
->
open_for_reading
<
ObjectPositionInterface
>(
"WM Ball"
);
57
log_level = (
Logger::LogLevel
)
config
->
58
get_uint(
"/ballposlog/log_level"
);
59
}
catch
(
Exception
&e) {
60
blackboard
->
close
(wm_ball_interface);
61
throw
;
62
}
63
}
64
65
66
void
67
BallPosLogThread::finalize
()
68
{
69
blackboard
->
close
(wm_ball_interface);
70
}
71
72
73
void
74
BallPosLogThread::loop
()
75
{
76
wm_ball_interface->
read
();
77
78
logger
->
log
(log_level,
"BallPosLog"
,
79
"Ball is at global (x,y) = (%f,%f)"
,
80
wm_ball_interface->
world_x
(),
81
wm_ball_interface->
world_y
());
82
}
src
plugins
examples
ballposlog
thread.cpp
Generated by
1.8.1.2