SVHHomeSettings.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 
00004 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00005 // This file is part of the SCHUNK SVH Driver suite.
00006 //
00007 // This program is free software licensed under the LGPL
00008 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00009 // You can find a copy of this license in LICENSE folder in the top
00010 // directory of the source code.
00011 //
00012 // © Copyright 2014 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
00013 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00014 //
00015 // -- END LICENSE BLOCK ------------------------------------------------
00016 
00017 //----------------------------------------------------------------------
00027 //----------------------------------------------------------------------
00028 
00029 #ifndef SVHHOMESETTINGS_H
00030 #define SVHHOMESETTINGS_H
00031 
00032 namespace driver_svh {
00033 
00035 struct SVHHomeSettings
00036 {
00038   int   direction;
00040   float minimumOffset;
00042   float maximumOffset;
00044   float idlePosition;
00049   float rangeRad;
00051   float resetCurrentFactor;
00052 
00056   SVHHomeSettings():
00057     direction(+1),
00058     minimumOffset(0.0),
00059     maximumOffset(0.0),
00060     idlePosition(0.0),
00061     rangeRad(0.0),
00062     resetCurrentFactor(0.5)
00063   {}
00064 
00073   SVHHomeSettings(const int &direction_,const float &minimumOffset_,const float &maximumOffset_,const float &idlePosition_,const float &rangeRad_,const float &resetCurrentFactor_):
00074     minimumOffset(minimumOffset_),
00075     maximumOffset(maximumOffset_),
00076     idlePosition(idlePosition_),
00077     rangeRad(rangeRad_),
00078     resetCurrentFactor(resetCurrentFactor_)
00079   {
00080     // Limit the direction to just contain a factor rather than any multipliers
00081     direction = direction_ < 0 ? -1 : +1;
00082     // Limit the resetCurrentFactor to allowed bounds
00083     resetCurrentFactor = std::max(std::min(resetCurrentFactor,1.0f),0.0f);
00084 
00085   }
00086 
00091   SVHHomeSettings(const std::vector<float> & home_settings)
00092   {
00093     // maybe not the most beautifull way but it works.
00094     size_t size = home_settings.size();
00095     float temp_direction = 0.0;
00096 
00097     temp_direction = (size > 0) ? home_settings[0] : 0.0;
00098     direction = temp_direction < 0.0 ? -1 : +1;
00099 
00100     minimumOffset = (size > 1) ? home_settings[1] : 0.0;
00101     maximumOffset = (size > 2) ? home_settings[2] : 0.0;
00102     idlePosition  = (size > 3) ? home_settings[3] : 0.0;
00103     rangeRad  = (size > 4)     ? home_settings[4] : 0.0;
00104     resetCurrentFactor = (size >5) ? home_settings[5] : 0.5;
00105 
00106     // Limit the resetCurrentFactor to allowed bounds
00107     resetCurrentFactor = std::max(std::min(resetCurrentFactor,1.0f),0.0f);
00108   }
00109 
00110 };
00111 
00112 
00114 inline std::ostream& operator << (std::ostream& o, const SVHHomeSettings& hs)
00115 {
00116   o << "Direction " << hs.direction << " "
00117     << "Min offset " << hs.minimumOffset << " "
00118     << "Max offset "<< hs.maximumOffset << " "
00119     << "idle pos "  << hs.idlePosition  << " "
00120     << "Range Rad " << hs.rangeRad << " "
00121     << "Reset Curr Factor " << hs.resetCurrentFactor << " "
00122     << std::endl;
00123   return o;
00124 }
00125 
00126 
00127 }
00128 
00129 
00130 #endif // SVHHOMESETTINGS_H


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Thu Jun 6 2019 18:29:08