Fawkes API  Fawkes Development Version
calib_thread.cpp
00001 
00002 /***************************************************************************
00003  *  calib_thread.cpp - Katana calibration one-time thread
00004  *
00005  *  Created: Tue Jun 09 18:37:02 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 "calib_thread.h"
00024 #include "controller.h"
00025 
00026 /** @class KatanaCalibrationThread "calib_thread.h"
00027  * Katana calibration thread.
00028  * This thread calibrates the arm when started and is finished when the calibration
00029  * is done.
00030  * @author Tim Niemueller
00031  */
00032 
00033 /** Constructor.
00034  * @param katana katana controller base class
00035  * @param logger logger
00036  */
00037 KatanaCalibrationThread::KatanaCalibrationThread(fawkes::RefPtr<fawkes::KatanaController> katana,
00038                                                  fawkes::Logger *logger)
00039   : KatanaMotionThread("KatanaCalibrationThread", katana, logger)
00040 {
00041 }
00042 
00043 void
00044 KatanaCalibrationThread::once()
00045 {
00046   try {
00047     _katana->calibrate();
00048     _logger->log_debug(name(), "Calibration successful");
00049   } catch (fawkes::Exception &e) {
00050     _logger->log_warn(name(), "Calibration failed (ignoring error): %s", e.what());
00051     _error_code = fawkes::KatanaInterface::ERROR_CMD_START_FAILED;
00052   }
00053   _finished = true;
00054 }