RefValJS_PTP.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 
00018 #ifndef _REFVALSJS_PTP_H_
00019 #define _REFVALSJS_PTP_H_
00020 
00021 #include "RefVal_JS.h"
00022 #include <cmath>
00023 #include <iostream>
00024 
00025 
00026 class RefValJS_PTP : public RefVal_JS
00027 {
00028         public:
00029                 RefValJS_PTP(const std::vector<double>& start, const std::vector<double>& ziel, double v_rad_s, double a_rad_s2);
00030 
00031                 virtual std::vector<double> r(double s) const;
00032                 virtual double s(double t) const;
00033 
00034                 virtual std::vector<double> dr_ds(double s) const;
00035                 virtual double ds_dt(double t) const;
00036 
00037                 double getTotalTime() const { std::cout << m_T1 << "\n"; return m_T1 + m_T2 + m_T3; }
00038 
00039         protected:
00040                 double norm(const std::vector<double>& j);
00041                 double norm_max(const std::vector<double>& j);
00042                 double norm_sqr(const std::vector<double>& j);
00043                 double norm_weighted(const std::vector<double>& j);
00044 
00045                 std::vector<double> m_start;
00046                 std::vector<double> m_ziel;
00047                 std::vector<double> m_direction;
00048 
00049                 double m_length;
00050 
00051                 double m_v_rad_s;
00052                 double m_a_rad_s2;
00053 
00054                 double m_T1;    // Dauer der Phase konst. Beschl.
00055                 double m_T2;    // Dauer der Phase konst. Geschw.
00056                 double m_T3;    // Dauer der Phase konst. Verzög.
00057 
00058                 double m_sa1;   // "Beschl." des Wegparameters s in Phase 1
00059                 double m_sv2;   // "Geschw." des Wegparameters s in Phase 2
00060                 double m_sa3;   // "Verzög." des Wegparameters s in Phase 3
00061 
00062                 static const double weigths[];
00063 
00064 };
00065 
00066 inline double RefValJS_PTP::norm(const std::vector<double>& j)
00067 {
00068         // which norm should be used?
00069         return norm_weighted(j);
00070 }
00071 
00072 inline double RefValJS_PTP::norm_max(const std::vector<double>& j)
00073 {
00074         double max = j.at(0);
00075         for     (unsigned int i = 0; i<j.size(); i++)
00076         {
00077                 if(j.at(i) < max)
00078                         max = j.at(i);
00079         }
00080         return max;
00081 }
00082 
00083 inline double RefValJS_PTP::norm_sqr(const std::vector<double>& j)
00084 {
00085         double l = 0;
00086         for (unsigned int i = 0; i < j.size(); i++)
00087         {
00088                 l += j[i] * j[i];
00089         }
00090         return sqrt(l);
00091 }
00092 
00093 inline double RefValJS_PTP::norm_weighted(const std::vector<double>& j)
00094 {
00095         double l = 0;
00096         if ( j.size() == 7 )
00097         {
00098                 for (unsigned int i = 0; i < j.size(); i++)
00099                 {
00100                         l += j[i]* weigths[i] * j[i] * weigths[i];
00101                 }
00102         }
00103         else
00104         {
00105                 for (unsigned int i = 0; i < j.size(); i++)
00106                 {
00107                         l += j[i] * j[i];
00108                 }
00109         }
00110         return sqrt(l);
00111 }
00112 
00113 
00114 #endif
00115 


cob_trajectory_controller
Author(s): Alexander Bubeck
autogenerated on Thu Jun 6 2019 21:19:22