motion_thread.cpp

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 
00025 #include <kniBase.h>
00026 
00027 /** @class KatanaMotionThread "motion_thread.h"
00028  * Katana motion thread base class.
00029  * Base class for motion threads for the Katana.
00030  *
00031  * When implementing a motion thread ensure that you read the sensor data
00032  * during the communication with the arm. The main (act) thread will not do
00033  * this as not to interfere with motion thread communication. You can use
00034  * code like this:
00035  * @code
00036  * _katana->GetBase()->GetSCT()->arr[0].recvDAT(); // update sensor values
00037  * @endcode
00038  * @author Tim Niemueller.
00039  */
00040 
00041 /** Constructor.
00042  * @param thread_name name of the thread
00043  * @param katana katana linear motion base class
00044  * @param logger logger
00045  */
00046 KatanaMotionThread::KatanaMotionThread(const char * thread_name,
00047                                        fawkes::RefPtr<CLMBase> katana,
00048                                        fawkes::Logger *logger)
00049   : Thread(thread_name, Thread::OPMODE_CONTINUOUS)
00050 {
00051   _katana     = katana;
00052   _logger     = logger;
00053   _finished   = false;
00054   _error_code = 0;
00055 }
00056 
00057 
00058 /** Did the motion finish already?
00059  * @return true if the motion was finished, flase otherwise
00060  */
00061 bool
00062 KatanaMotionThread::finished() const
00063 {
00064   return _finished;
00065 }
00066 
00067 
00068 /** Error code.
00069  * @return error code, one or more of the ERROR_* constants from the
00070  * KatanaInterface or'ed.
00071  */
00072 unsigned int
00073 KatanaMotionThread::error_code() const
00074 {
00075   return _error_code;
00076 }
00077 
00078 
00079 /** Reset for next execution.
00080  * Resets _finished and _error_code. If you override this method call the base
00081  * class method in your method. It should be used to do anything that is required
00082  * to be able to run the thread again.
00083  */
00084 void
00085 KatanaMotionThread::reset()
00086 {
00087   _finished   = false;
00088   _error_code = 0;
00089 }

Generated on Tue Feb 22 13:31:29 2011 for Fawkes API by  doxygen 1.4.7