ParabolicRamp.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  * Copyright (c) 2010-2011, the Trustees of Indiana University
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions are met:
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of Indiana University nor the
00014  *       names of its contributors may be used to endorse or promote products
00015  *       derived from this software without specific prior written permission.
00016 
00017  * THIS SOFTWARE IS PROVIDED BY THE TRUSTEES OF INDIANA UNIVERSITY ''AS IS''
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OF INDIANA UNIVERSITY BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
00027  * THE POSSIBILITY OF SUCH DAMAGE.
00028  * 
00029  ***************************************************************************/
00030 
00031 #ifndef PARABOLIC_RAMP_H
00032 #define PARABOLIC_RAMP_H
00033 
00034 #include <math.h>
00035 #include "constraint_aware_spline_smoother/ParabolicPathSmooth/Math.h"
00036 
00037 namespace ParabolicRamp {
00038 
00050 class ParabolicRamp1D
00051 {
00052  public:
00054   void SetConstant(Real x,Real t=0);
00056   void SetLinear(Real x0,Real x1,Real t);
00058   bool SolveMinTime(Real amax,Real vmax);
00060   bool SolveMinTime2(Real amax,Real vmax,Real tLowerBound);
00062   bool SolveMinAccel(Real endTime,Real vmax);
00064   Real SolveMinAccel2(Real endTime,Real vmax);
00066   void SolveBraking(Real amax);
00068   Real Evaluate(Real t) const;
00070   Real Derivative(Real t) const;
00072   Real Accel(Real t) const;
00074   Real EndTime() const { return ttotal; }
00076   void Dilate(Real timeScale);
00078   void TrimFront(Real tcut);
00080   void TrimBack(Real tcut);
00082   void Bounds(Real& xmin,Real& xmax) const;
00084   void Bounds(Real ta,Real tb,Real& xmin,Real& xmax) const;
00086   void DerivBounds(Real& vmin,Real& vmax) const;
00088   void DerivBounds(Real ta,Real tb,Real& vmin,Real& vmax) const;
00090   bool IsValid() const;
00091 
00093   Real x0,dx0;
00094   Real x1,dx1;
00095 
00097   Real tswitch1,tswitch2;  //time to switch between ramp/flat/ramp
00098   Real ttotal;
00099   Real a1,v,a2;   // accel of first ramp, velocity of linear section, accel of second ramp
00100 };
00101 
00106 class ParabolicRampND
00107 {
00108  public:
00109   void SetConstant(const Vector& x,Real t=0);
00110   void SetLinear(const Vector& x0,const Vector& x1,Real t);
00111   bool SolveMinTimeLinear(const Vector& amax,const Vector& vmax);
00112   bool SolveMinTime(const Vector& amax,const Vector& vmax);
00113   bool SolveMinAccel(const Vector& vmax,Real time);
00114   bool SolveMinAccelLinear(const Vector& vmax,Real time);
00115   void SolveBraking(const Vector& amax);
00116   void Evaluate(Real t,Vector& x) const;
00117   void Derivative(Real t,Vector& dx) const;
00118   void Accel(Real t,Vector& ddx) const;
00119   void Output(Real dt,std::vector<Vector>& path) const;
00120   void Dilate(Real timeScale);
00121   void TrimFront(Real tcut);
00122   void TrimBack(Real tcut);
00123   void Bounds(Vector& xmin,Vector& xmax) const;
00124   void Bounds(Real ta,Real tb,Vector& xmin,Vector& xmax) const;
00125   void DerivBounds(Vector& vmin,Vector& vmax) const;
00126   void DerivBounds(Real ta,Real tb,Vector& vmin,Vector& vmax) const;
00127   bool IsValid() const;
00128 
00130   Vector x0,dx0;
00131   Vector x1,dx1;
00132 
00134   Real endTime;
00135   std::vector<ParabolicRamp1D> ramps;
00136 };
00137 
00140 bool SolveMinTimeBounded(Real x0,Real v0,Real x1,Real v1,
00141                          Real amax,Real vmax,Real xmin,Real xmax,
00142                          ParabolicRamp1D& ramp);
00143 
00147 bool SolveMinAccelBounded(Real x0,Real v0,Real x1,Real v1,
00148                           Real endTime,Real vmax,Real xmin,Real xmax,
00149                           std::vector<ParabolicRamp1D>& ramps);
00150 
00153 Real SolveMinTimeBounded(const Vector& x0,const Vector& v0,const Vector& x1,const Vector& v1,
00154                          const Vector& amax,const Vector& vmax,const Vector& xmin,const Vector& xmax,
00155                          std::vector<std::vector<ParabolicRamp1D> >& ramps);
00156 
00159 bool SolveMinAccelBounded(const Vector& x0,const Vector& v0,const Vector& x1,const Vector& v1,
00160                          Real endTime,const Vector& vmax,const Vector& xmin,const Vector& xmax,
00161                          std::vector<std::vector<ParabolicRamp1D> >& ramps);
00162 
00164 void CombineRamps(const std::vector<std::vector<ParabolicRamp1D> >& ramps,std::vector<ParabolicRampND>& ndramps);
00165 
00166 } //namespace ParabolicRamp
00167 
00168 #endif


constraint_aware_spline_smoother
Author(s): Sachin Chitta
autogenerated on Thu Dec 12 2013 11:10:27