Libbarrett
1.2.4
|
00001 /* 00002 Copyright 2009, 2010 Barrett Technology <support@barrett.com> 00003 00004 This file is part of libbarrett. 00005 00006 This version of libbarrett is free software: you can redistribute it 00007 and/or modify it under the terms of the GNU General Public License as 00008 published by the Free Software Foundation, either version 3 of the 00009 License, or (at your option) any later version. 00010 00011 This version of libbarrett is distributed in the hope that it will be 00012 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License along 00017 with this version of libbarrett. If not, see 00018 <http://www.gnu.org/licenses/>. 00019 00020 Further, non-binding information about licensing is available at: 00021 <http://wiki.barrett.com/libbarrett/wiki/LicenseNotes> 00022 */ 00023 00024 /* 00025 * tool_orientation.h 00026 * 00027 * Created on: Jan 21, 2010 00028 * Author: dc 00029 */ 00030 00031 #ifndef BARRETT_SYSTEMS_TOOL_ORIENTATION_H_ 00032 #define BARRETT_SYSTEMS_TOOL_ORIENTATION_H_ 00033 00034 #include <iostream> 00035 00036 #include <Eigen/Core> 00037 #include <Eigen/Geometry> 00038 #include <gsl/gsl_matrix.h> 00039 00040 #include <barrett/detail/ca_macro.h> 00041 #include <barrett/units.h> 00042 #include <barrett/systems/abstract/system.h> 00043 #include <barrett/systems/abstract/single_io.h> 00044 #include <barrett/systems/kinematics_base.h> 00045 00046 00047 namespace barrett { 00048 namespace systems { 00049 00050 00051 // yields a quaternion representing the rotation from the world frame to the tool frame. 00052 template<size_t DOF> 00053 class ToolOrientation : public System, public KinematicsInput<DOF>, 00054 public SingleOutput<Eigen::Quaterniond> { 00055 public: 00056 ToolOrientation(const std::string& sysName = "ToolOrientation") : 00057 System(sysName), KinematicsInput<DOF>(this), 00058 SingleOutput<Eigen::Quaterniond>(this), rot(), data() {} 00059 virtual ~ToolOrientation() { mandatoryCleanUp(); } 00060 00061 protected: 00062 virtual void operate() { 00063 rot.copyFrom(this->kinInput.getValue().impl->tool->rot_to_world); 00064 data = rot.transpose(); // Transpose to get world-to-tool rotation 00065 00066 this->outputValue->setData(&data); 00067 } 00068 00069 math::Matrix<3,3> rot; 00070 Eigen::Quaterniond data; 00071 00072 private: 00073 DISALLOW_COPY_AND_ASSIGN(ToolOrientation); 00074 00075 public: 00076 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00077 }; 00078 00079 00080 } 00081 } 00082 00083 00084 #endif /* BARRETT_SYSTEMS_TOOL_ORIENTATION_H_ */