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 * gravity_compensator.h 00026 * 00027 * Created on: Feb 9, 2010 00028 * Author: dc 00029 */ 00030 00031 #ifndef BARRETT_SYSTEMS_GRAVITY_COMPENSATOR_H_ 00032 #define BARRETT_SYSTEMS_GRAVITY_COMPENSATOR_H_ 00033 00034 00035 #include <Eigen/Core> 00036 #include <libconfig.h++> 00037 00038 #include <barrett/detail/ca_macro.h> 00039 #include <barrett/units.h> 00040 #include <barrett/cdlbt/calgrav.h> 00041 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 template<size_t DOF> 00052 class GravityCompensator : public System, 00053 public KinematicsInput<DOF>, 00054 public SingleOutput<typename units::JointTorques<DOF>::type> { 00055 00056 BARRETT_UNITS_TEMPLATE_TYPEDEFS(DOF); 00057 00058 public: 00059 explicit GravityCompensator(const libconfig::Setting& setting, 00060 const std::string& sysName = "GravityCompensator") : 00061 System(sysName), KinematicsInput<DOF>(this), SingleOutput<jt_type>(this), impl(NULL), data() 00062 { 00063 bt_calgrav_create(&impl, setting.getCSetting(), DOF); 00064 } 00065 00066 bool setGravity(double new_grav) { 00067 return(!bt_calgrav_update(impl, new_grav)); 00068 } 00069 virtual ~GravityCompensator() { 00070 mandatoryCleanUp(); 00071 00072 bt_calgrav_destroy(impl); 00073 impl = NULL; 00074 } 00075 00076 protected: 00077 virtual void operate() { 00078 bt_calgrav_eval(impl, this->kinInput.getValue().impl, data.asGslType()); 00079 this->outputValue->setData(&data); 00080 } 00081 00082 struct bt_calgrav* impl; 00083 jt_type data; 00084 00085 private: 00086 DISALLOW_COPY_AND_ASSIGN(GravityCompensator); 00087 00088 public: 00089 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00090 }; 00091 00092 00093 } 00094 } 00095 00096 00097 #endif /* BARRETT_SYSTEMS_GRAVITY_COMPENSATOR_H_ */