Fawkes API
Fawkes Development Version
motion_thread.cpp
1
2
/***************************************************************************
3
* motion_thread.h - Katana one-time thread interface for motions
4
*
5
* Created: Wed Jun 10 11:41:36 2009
6
* Copyright 2006-2009 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 "motion_thread.h"
24
25
#include "controller.h"
26
27
/** @class KatanaMotionThread "motion_thread.h"
28
* Katana motion thread base class.
29
* Base class for motion threads for the Katana.
30
*
31
* When implementing a motion thread ensure that you read the sensor data
32
* during the communication with the arm. The main (act) thread will not do
33
* this as not to interfere with motion thread communication. You can use
34
* code like this:
35
* @code
36
* _katana->GetBase()->GetSCT()->arr[0].recvDAT(); // update sensor values
37
* @endcode
38
* @author Tim Niemueller.
39
*/
40
41
/** Constructor.
42
* @param thread_name name of the thread
43
* @param katana katana controller base class
44
* @param logger logger
45
*/
46
KatanaMotionThread::KatanaMotionThread
(
const
char
* thread_name,
47
fawkes::RefPtr<fawkes::KatanaController>
katana,
48
fawkes::Logger
* logger)
49
: Thread(thread_name, Thread::OPMODE_CONTINUOUS)
50
{
51
_katana
= katana;
52
_logger
= logger;
53
_finished
=
false
;
54
_error_code
= 0;
55
}
56
57
/** Did the motion finish already?
58
* @return true if the motion was finished, flase otherwise
59
*/
60
bool
61
KatanaMotionThread::finished
()
const
62
{
63
return
_finished
;
64
}
65
66
/** Error code.
67
* @return error code, one or more of the ERROR_* constants from the
68
* KatanaInterface or'ed.
69
*/
70
unsigned
int
71
KatanaMotionThread::error_code
()
const
72
{
73
return
_error_code
;
74
}
75
76
/** Reset for next execution.
77
* Resets _finished and _error_code. If you override this method call the base
78
* class method in your method. It should be used to do anything that is required
79
* to be able to run the thread again.
80
*/
81
void
82
KatanaMotionThread::reset
()
83
{
84
_finished
=
false
;
85
_error_code
= 0;
86
}
KatanaMotionThread::_logger
fawkes::Logger * _logger
Logger.
Definition:
motion_thread.h:51
KatanaMotionThread::error_code
unsigned int error_code() const
Error code.
Definition:
motion_thread.cpp:70
fawkes::RefPtr< fawkes::KatanaController >
KatanaMotionThread::_finished
bool _finished
Set to true when motion is finished, to false on reset.
Definition:
motion_thread.h:49
KatanaMotionThread::_error_code
unsigned int _error_code
Set to the desired error code on error.
Definition:
motion_thread.h:53
KatanaMotionThread::_katana
fawkes::RefPtr< fawkes::KatanaController > _katana
Katana object for interaction with the arm.
Definition:
motion_thread.h:47
fawkes::Logger
Definition:
logger.h:40
KatanaMotionThread::KatanaMotionThread
KatanaMotionThread(const char *thread_name, fawkes::RefPtr< fawkes::KatanaController > katana, fawkes::Logger *logger)
Constructor.
Definition:
motion_thread.cpp:45
KatanaMotionThread::finished
bool finished() const
Did the motion finish already?
Definition:
motion_thread.cpp:60
KatanaMotionThread::reset
virtual void reset()
Reset for next execution.
Definition:
motion_thread.cpp:81
src
plugins
katana
motion_thread.cpp
Generated by
1.8.16