Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * motion_thread.h - Katana one-time thread interface for motions 00004 * 00005 * Created: Wed Jun 10 11:41:36 2009 00006 * Copyright 2006-2009 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #include "motion_thread.h" 00024 #include "controller.h" 00025 00026 /** @class KatanaMotionThread "motion_thread.h" 00027 * Katana motion thread base class. 00028 * Base class for motion threads for the Katana. 00029 * 00030 * When implementing a motion thread ensure that you read the sensor data 00031 * during the communication with the arm. The main (act) thread will not do 00032 * this as not to interfere with motion thread communication. You can use 00033 * code like this: 00034 * @code 00035 * _katana->GetBase()->GetSCT()->arr[0].recvDAT(); // update sensor values 00036 * @endcode 00037 * @author Tim Niemueller. 00038 */ 00039 00040 /** Constructor. 00041 * @param thread_name name of the thread 00042 * @param katana katana controller base class 00043 * @param logger logger 00044 */ 00045 KatanaMotionThread::KatanaMotionThread(const char * thread_name, 00046 fawkes::RefPtr<fawkes::KatanaController> katana, 00047 fawkes::Logger *logger) 00048 : Thread(thread_name, Thread::OPMODE_CONTINUOUS) 00049 { 00050 _katana = katana; 00051 _logger = logger; 00052 _finished = false; 00053 _error_code = 0; 00054 } 00055 00056 00057 /** Did the motion finish already? 00058 * @return true if the motion was finished, flase otherwise 00059 */ 00060 bool 00061 KatanaMotionThread::finished() const 00062 { 00063 return _finished; 00064 } 00065 00066 00067 /** Error code. 00068 * @return error code, one or more of the ERROR_* constants from the 00069 * KatanaInterface or'ed. 00070 */ 00071 unsigned int 00072 KatanaMotionThread::error_code() const 00073 { 00074 return _error_code; 00075 } 00076 00077 00078 /** Reset for next execution. 00079 * Resets _finished and _error_code. If you override this method call the base 00080 * class method in your method. It should be used to do anything that is required 00081 * to be able to run the thread again. 00082 */ 00083 void 00084 KatanaMotionThread::reset() 00085 { 00086 _finished = false; 00087 _error_code = 0; 00088 }