Fawkes API
Fawkes Development Version
sensor_thread.cpp
1
2
/***************************************************************************
3
* sensor_thread.cpp - Roomba plugin sensor thread
4
*
5
* Created: Mon Jan 03 00:05:32 2011
6
* Copyright 2006-2010 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 "sensor_thread.h"
24
25
#include "thread_roomba_500.h"
26
27
using namespace
fawkes
;
28
29
/** @class RoombaSensorThread "sensor_thread.h"
30
* Roomba sensor hook integration thread.
31
* This thread integrates into the Fawkes main loop at the SENSOR hook and
32
* triggers the Roomba thread to write new sensor data.
33
* @author Tim Niemueller
34
*/
35
36
/** Constructor.
37
* @param roomba500_thread Roomba 500 thread to trigger to write to blackboard.
38
*/
39
RoombaSensorThread::RoombaSensorThread
(
Roomba500Thread
*roomba500_thread)
40
:
Thread
(
"RoombaSensorThread"
,
Thread
::OPMODE_WAITFORWAKEUP),
41
BlockedTimingAspect
(
BlockedTimingAspect
::WAKEUP_HOOK_SENSOR_ACQUIRE)
42
{
43
roomba500_thread_ = roomba500_thread;
44
}
45
46
void
47
RoombaSensorThread::loop
()
48
{
49
try
{
50
roomba500_thread_->
write_blackboard
();
51
}
catch
(
Exception
&e) {
52
logger
->
log_warn
(
name
(),
53
"%s failed to write to BB, exception follows."
,
54
roomba500_thread_->
name
());
55
logger
->
log_warn
(
name
(), e);
56
}
57
}
RoombaSensorThread::loop
virtual void loop()
Code to execute in the thread.
Definition:
sensor_thread.cpp:47
RoombaSensorThread::RoombaSensorThread
RoombaSensorThread(Roomba500Thread *roomba500_thread)
Constructor.
Definition:
sensor_thread.cpp:39
fawkes::BlockedTimingAspect
Definition:
blocked_timing.h:56
fawkes::Thread::name
const char * name() const
Definition:
thread.h:100
Roomba500Thread
Definition:
thread_roomba_500.h:45
fawkes::LoggingAspect::logger
Logger * logger
Definition:
logging.h:53
fawkes
Roomba500Thread::write_blackboard
void write_blackboard()
Write data to blackboard.
Definition:
thread_roomba_500.cpp:557
fawkes::Logger::log_warn
virtual void log_warn(const char *component, const char *format,...)=0
fawkes::Thread
Definition:
thread.h:45
fawkes::Exception
Definition:
exception.h:41
src
plugins
roomba
sensor_thread.cpp
Generated by
1.8.17