penalties.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  *
00003  * Software License Agreement (BSD License)
00004  *
00005  *  Copyright (c) 2016,
00006  *  TU Dortmund - Institute of Control Theory and Systems Engineering.
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of the institute nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  * Author: Christoph Rösmann
00037  *********************************************************************/
00038 
00039 #ifndef PENALTIES_H
00040 #define PENALTIES_H
00041 
00042 #include <cmath>
00043 #include <Eigen/Core>
00044 #include <g2o/stuff/misc.h>
00045 
00046 namespace teb_local_planner
00047 {
00048 
00057 inline double penaltyBoundToInterval(const double& var,const double& a,const double& epsilon)
00058 {
00059   if (var < -a+epsilon)
00060   {
00061     return (-var - (a - epsilon));
00062   }
00063   if (var <= a-epsilon)
00064   {
00065     return 0.;
00066   }
00067   else
00068   {
00069     return (var - (a - epsilon));
00070   }
00071 }
00072 
00082 inline double penaltyBoundToInterval(const double& var,const double& a, const double& b, const double& epsilon)
00083 {
00084   if (var < a+epsilon)
00085   {
00086     return (-var + (a + epsilon));
00087   }
00088   if (var <= b-epsilon)
00089   {
00090     return 0.;
00091   }
00092   else
00093   {
00094     return (var - (b - epsilon));
00095   }
00096 }
00097 
00098 
00107 inline double penaltyBoundFromBelow(const double& var, const double& a,const double& epsilon)
00108 {
00109   if (var >= a+epsilon)
00110   {
00111     return 0.;
00112   }
00113   else
00114   {
00115     return (-var + (a+epsilon));
00116   }
00117 }
00118 
00127 inline double penaltyBoundToIntervalDerivative(const double& var,const double& a, const double& epsilon)
00128 {
00129   if (var < -a+epsilon)
00130   {
00131     return -1;
00132   }
00133   if (var <= a-epsilon)
00134   {
00135     return 0.;
00136   }
00137   else
00138   {
00139     return 1;           
00140   }
00141 }
00142 
00152 inline double penaltyBoundToIntervalDerivative(const double& var,const double& a, const double& b, const double& epsilon)
00153 {
00154   if (var < a+epsilon)
00155   {
00156     return -1;
00157   }
00158   if (var <= b-epsilon)
00159   {
00160     return 0.;
00161   }
00162   else
00163   {
00164     return 1;           
00165   }
00166 }
00167 
00168 
00177 inline double penaltyBoundFromBelowDerivative(const double& var, const double& a,const double& epsilon)
00178 {
00179   if (var >= a+epsilon)
00180   {
00181     return 0.;
00182   }
00183   else
00184   {
00185     return -1;
00186   }
00187 }
00188 
00189 
00190 } // namespace teb_local_planner
00191 
00192 
00193 #endif // PENALTIES_H


teb_local_planner
Author(s): Christoph Rösmann
autogenerated on Mon Oct 24 2016 05:31:15