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 * kinematics_base.h 00026 * 00027 * Created on: Jan 15, 2010 00028 * Author: dc 00029 */ 00030 00031 #ifndef BARRETT_SYSTEMS_KINEMATICS_BASE_H_ 00032 #define BARRETT_SYSTEMS_KINEMATICS_BASE_H_ 00033 00034 00035 #include <libconfig.h++> 00036 00037 #include <barrett/detail/ca_macro.h> 00038 #include <barrett/units.h> 00039 #include <barrett/math/kinematics.h> 00040 #include <barrett/systems/abstract/system.h> 00041 00042 00043 namespace barrett { 00044 namespace systems { 00045 00046 00047 template<size_t DOF> 00048 class KinematicsInput { // not a System in order to avoid diamond inheritance 00049 // IO 00050 public: System::Input<math::Kinematics<DOF> > kinInput; 00051 00052 00053 public: 00054 explicit KinematicsInput(System* parentSys) : 00055 kinInput(parentSys) {} 00056 00057 private: 00058 DISALLOW_COPY_AND_ASSIGN(KinematicsInput); 00059 }; 00060 00061 00062 template<size_t DOF> 00063 class KinematicsBase : public System { 00064 // IO 00065 public: Input<typename units::JointPositions<DOF>::type> jpInput; 00066 public: Input<typename units::JointVelocities<DOF>::type> jvInput; 00067 public: Output<math::Kinematics<DOF> > kinOutput; 00068 protected: typename Output<math::Kinematics<DOF> >::Value* kinOutputValue; 00069 00070 00071 public: 00072 explicit KinematicsBase(const libconfig::Setting& setting, const std::string& sysName = "KinematicsBase") : 00073 System(sysName), 00074 jpInput(this), jvInput(this), 00075 kinOutput(this, &kinOutputValue), kin(setting) {} 00076 virtual ~KinematicsBase() { mandatoryCleanUp(); } 00077 00078 protected: 00079 virtual void operate() { 00080 kin.eval(jpInput.getValue(), jvInput.getValue()); 00081 kinOutputValue->setData(&kin); 00082 } 00083 00084 math::Kinematics<DOF> kin; 00085 00086 private: 00087 DISALLOW_COPY_AND_ASSIGN(KinematicsBase); 00088 }; 00089 00090 00091 } 00092 } 00093 00094 00095 #endif /* BARRETT_SYSTEMS_KINEMATICS_BASE_H_ */