path.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Erwin Aertbelien  Mon May 10 19:10:36 CEST 2004  path.cxx
00003 
00004                         path.cxx -  description
00005                            -------------------
00006     begin                : Mon May 10 2004
00007     copyright            : (C) 2004 Erwin Aertbelien
00008     email                : erwin.aertbelien@mech.kuleuven.ac.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place,                                    *
00024  *   Suite 330, Boston, MA  02111-1307  USA                                *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 /*****************************************************************************
00029  *  \author
00030  *      Erwin Aertbelien, Div. PMA, Dep. of Mech. Eng., K.U.Leuven
00031  *
00032  *  \version
00033  *              ORO_Geometry V0.2
00034  *
00035  *      \par History
00036  *              - $log$
00037  *
00038  *      \par Release
00039  *              $Id: path.cpp,v 1.1.1.1.2.4 2003/07/18 14:49:50 psoetens Exp $
00040  *              $Name:  $
00041  ****************************************************************************/
00042 
00043 
00044 #include "utilities/error.h"
00045 #include "utilities/error_stack.h"
00046 #include "path.hpp"
00047 #include "path_line.hpp"
00048 #include "path_point.hpp"
00049 #include "path_circle.hpp"
00050 #include "path_composite.hpp"
00051 #include "path_roundedcomposite.hpp"
00052 #include "path_cyclic_closed.hpp"
00053 #include <memory>
00054 #include <string.h>
00055 
00056 namespace KDL {
00057 
00058 using namespace std;
00059 
00060 
00061 Path* Path::Read(istream& is) {
00062         // auto_ptr because exception can be thrown !
00063         IOTrace("Path::Read");
00064         char storage[64];
00065         EatWord(is,"[",storage,sizeof(storage));
00066         Eat(is,'[');
00067         if (strcmp(storage,"POINT")==0) {
00068                 IOTrace("POINT");
00069                 Frame startpos;
00070                 is >> startpos;
00071                 EatEnd(is,']');
00072                 IOTracePop();
00073                 IOTracePop();
00074                 return new Path_Point(startpos);
00075         } else  if (strcmp(storage,"LINE")==0) {
00076                 IOTrace("LINE");
00077                 Frame startpos;
00078                 Frame endpos;
00079                 is >> startpos;
00080                 is >> endpos;
00081                 auto_ptr<RotationalInterpolation> orient( RotationalInterpolation::Read(is) );
00082                 double eqradius;
00083                 is >> eqradius;
00084                 EatEnd(is,']');
00085                 IOTracePop();
00086                 IOTracePop();
00087                 return new Path_Line(startpos,endpos,orient.release(),eqradius);
00088         } else if (strcmp(storage,"CIRCLE")==0) {
00089                 IOTrace("CIRCLE");
00090                 Frame F_base_start;
00091                 Vector V_base_center;
00092                 Vector V_base_p;
00093                 Rotation R_base_end;
00094                 double alpha;
00095                 double eqradius;
00096                 is >> F_base_start;
00097                 is >> V_base_center;
00098                 is >> V_base_p;
00099                 is >> R_base_end;
00100                 is >> alpha;
00101                 alpha *= deg2rad;
00102                 auto_ptr<RotationalInterpolation> orient( RotationalInterpolation::Read(is) );
00103                 is >> eqradius;
00104                 EatEnd(is,']');
00105                 IOTracePop();
00106                 IOTracePop();
00107                 return new Path_Circle(
00108                                                 F_base_start,
00109                                                 V_base_center,
00110                                                 V_base_p,
00111                                                 R_base_end,
00112                                                 alpha,
00113                                                 orient.release() ,
00114                                                 eqradius
00115                                         );
00116         } else if (strcmp(storage,"ROUNDEDCOMPOSITE")==0) {
00117                 IOTrace("ROUNDEDCOMPOSITE");
00118                 double radius;
00119                 is >> radius;
00120                 double eqradius;
00121                 is >> eqradius;
00122                 auto_ptr<RotationalInterpolation> orient( RotationalInterpolation::Read(is) );
00123                 auto_ptr<Path_RoundedComposite> tr(
00124                         new Path_RoundedComposite(radius,eqradius,orient.release())
00125                 );
00126                 int size;
00127                 is >> size;
00128                 int i;
00129                 for (i=0;i<size;i++) {
00130                         Frame f;
00131                         is >> f;
00132                         tr->Add(f);
00133                 }
00134                 tr->Finish();
00135                 EatEnd(is,']');
00136                 IOTracePop();
00137                 IOTracePop();
00138                 return tr.release();
00139         } else if (strcmp(storage,"COMPOSITE")==0) {
00140                 IOTrace("COMPOSITE");
00141                 int size;
00142                 auto_ptr<Path_Composite> tr( new Path_Composite() );
00143                 is >> size;
00144                 int i;
00145                 for (i=0;i<size;i++) {
00146                         tr->Add(Path::Read(is));
00147                 }
00148                 EatEnd(is,']');
00149                 IOTracePop();
00150                 IOTracePop();
00151                 return tr.release();
00152         } else if (strcmp(storage,"CYCLIC_CLOSED")==0) {
00153                 IOTrace("CYCLIC_CLOSED");
00154                 int times;
00155                 auto_ptr<Path> tr( Path::Read(is) );
00156                 is >> times;
00157                 EatEnd(is,']');
00158                 IOTracePop();
00159                 IOTracePop();
00160                 return new Path_Cyclic_Closed(tr.release(),times);
00161         } else {
00162                 throw Error_MotionIO_Unexpected_Traj();
00163         }
00164         return NULL; // just to avoid the warning;
00165 }
00166 
00167 
00168 
00169 }
00170 


orocos_kdl
Author(s):
autogenerated on Sat Oct 7 2017 03:04:28