GainCalculator.cpp
Go to the documentation of this file.
00001 #include "robodyn_controllers/GainCalculator.h"
00002 
00003 namespace GainCalculator
00004 {
00005     /***************************************************************************/
00018     void CalculateGains(JointGainsData& jg)
00019     {
00020         // Find stiffness and limit
00021         jg.stiffness = jg.naturalFreq * jg.naturalFreq * jg.mass;
00022 
00023         if (jg.stiffness > jg.maxK)
00024         {
00025             jg.stiffness = jg.maxK;
00026         }
00027 
00028         // Find damping and limit
00029         GainCalculator::CalculateDamping(jg);
00030     }
00031 
00032     /***************************************************************************/
00044     void CalculateDamping(JointGainsData& jg)
00045     {
00046         // Find damping and limit
00047         jg.damping = 2.0 * jg.dampingRatio * sqrt( jg.stiffness * jg.mass ) ;
00048 
00049         if (jg.damping > jg.maxD)
00050         {
00051             jg.damping = jg.maxD;
00052             // recalc stiffness if necessary to limit damping
00053             jg.stiffness = pow((jg.damping / (2.0 * jg.dampingRatio)), 2.0) / jg.mass;
00054         }
00055 
00056         if (jg.damping < jg.minD)
00057         {
00058             jg.damping = jg.minD;
00059 
00060             if (jg.dampingRatio != 0. && jg.mass != 0.)
00061             {
00062                 jg.stiffness = pow((jg.damping / (2.0 * jg.dampingRatio)), 2.0) / jg.mass;
00063             }
00064             else
00065             {
00066                 jg.stiffness = 0.0;
00067             }
00068 
00069             if (jg.stiffness > jg.maxK)
00070             {
00071                 jg.stiffness = jg.maxK;
00072             }
00073         }
00074     }
00075 }


robodyn_controllers
Author(s):
autogenerated on Sat Jun 8 2019 20:20:53