Libbarrett
1.2.4
|
00001 /* 00002 Copyright 2014, 2015 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 * modXYZ.h 00026 * 00027 * Created on: Mar 27, 2015 00028 * Author: hm 00029 */ 00030 #ifndef BARRETT_SYSTEMS_MODXYZ_H_ 00031 #define BARRETT_SYSTEMS_MODXYZ_H_ 00032 00033 #include <barrett/detail/ca_macro.h> 00034 #include <barrett/math/traits.h> 00035 #include <barrett/systems/abstract/system.h> 00036 #include <barrett/systems/abstract/single_io.h> 00037 00038 namespace barrett { 00039 namespace systems { 00040 00041 template <typename T> 00042 class modXYZ : public systems::SingleIO<T, T> { 00043 BARRETT_UNITS_FIXED_SIZE_TYPEDEFS; 00044 public: 00045 modXYZ(const std::string& sysName = "modXYZ") : systems::SingleIO<T, T>(sysName), x(false), y(false), z(false), off_x(0.0), off_y(0.0), off_z(0.0) {} 00046 00047 void negX(){ 00048 x = true; 00049 } 00050 void negY(){ 00051 y = true; 00052 } 00053 void negZ(){ 00054 z = true; 00055 } 00056 void xOffset(double val){ 00057 off_x = val; 00058 } 00059 void yOffset(double val){ 00060 off_y = val; 00061 } 00062 void zOffset(double val){ 00063 off_z = val; 00064 } 00065 protected: 00066 bool x, y, z; 00067 double off_x, off_y, off_z; 00068 T xyz, mod_xyz; 00069 00070 virtual void operate() { 00071 xyz = this->input.getValue(); 00072 mod_xyz = xyz; 00073 if(x) 00074 mod_xyz[0] = -xyz[0]; 00075 if(y) 00076 mod_xyz[1] = -xyz[1]; 00077 if(z) 00078 mod_xyz[2] = -xyz[2]; 00079 mod_xyz[0] = mod_xyz[0] + off_x; 00080 mod_xyz[1] = mod_xyz[1] + off_y; 00081 mod_xyz[2] = mod_xyz[2] + off_z; 00082 this->outputValue->setData(&mod_xyz); 00083 } 00084 private: 00085 DISALLOW_COPY_AND_ASSIGN(modXYZ); 00086 }; 00087 00088 } 00089 } 00090 00091 #endif /* BARRETT_SYSTEMS_MODXYZ_H_ */ 00092