path.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Erwin Aertbelien Mon May 10 19:10:36 CEST 2004 path.cxx
3 
4  path.cxx - description
5  -------------------
6  begin : Mon May 10 2004
7  copyright : (C) 2004 Erwin Aertbelien
8  email : erwin.aertbelien@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2.1 of the License, or (at your option) any later version. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19  * Lesser General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library; if not, write to the Free Software *
23  * Foundation, Inc., 59 Temple Place, *
24  * Suite 330, Boston, MA 02111-1307 USA *
25  * *
26  ***************************************************************************/
27 
28 /*****************************************************************************
29  * \author
30  * Erwin Aertbelien, Div. PMA, Dep. of Mech. Eng., K.U.Leuven
31  *
32  * \version
33  * ORO_Geometry V0.2
34  *
35  * \par History
36  * - $log$
37  *
38  * \par Release
39  * $Id: path.cpp,v 1.1.1.1.2.4 2003/07/18 14:49:50 psoetens Exp $
40  * $Name: $
41  ****************************************************************************/
42 
43 
44 #include "utilities/error.h"
45 #include "utilities/error_stack.h"
46 #include "utilities/scoped_ptr.hpp"
47 #include "path.hpp"
48 #include "path_line.hpp"
49 #include "path_point.hpp"
50 #include "path_circle.hpp"
51 #include "path_composite.hpp"
53 #include "path_cyclic_closed.hpp"
54 #include <memory>
55 #include <string.h>
56 
57 namespace KDL {
58 
59 
60 Path* Path::Read(std::istream& is) {
61  // auto_ptr because exception can be thrown !
62  IOTrace("Path::Read");
63  char storage[64];
64  EatWord(is,"[",storage,sizeof(storage));
65  Eat(is,'[');
66  if (strcmp(storage,"POINT")==0) {
67  IOTrace("POINT");
68  Frame startpos;
69  is >> startpos;
70  EatEnd(is,']');
71  IOTracePop();
72  IOTracePop();
73  return new Path_Point(startpos);
74  } else if (strcmp(storage,"LINE")==0) {
75  IOTrace("LINE");
76  Frame startpos;
77  Frame endpos;
78  is >> startpos;
79  is >> endpos;
81  double eqradius;
82  is >> eqradius;
83  EatEnd(is,']');
84  IOTracePop();
85  IOTracePop();
86  return new Path_Line(startpos,endpos,orient.release(),eqradius);
87  } else if (strcmp(storage,"CIRCLE")==0) {
88  IOTrace("CIRCLE");
89  Frame F_base_start;
90  Vector V_base_center;
91  Vector V_base_p;
92  Rotation R_base_end;
93  double alpha;
94  double eqradius;
95  is >> F_base_start;
96  is >> V_base_center;
97  is >> V_base_p;
98  is >> R_base_end;
99  is >> alpha;
100  alpha *= deg2rad;
102  is >> eqradius;
103  EatEnd(is,']');
104  IOTracePop();
105  IOTracePop();
106  return new Path_Circle(
107  F_base_start,
108  V_base_center,
109  V_base_p,
110  R_base_end,
111  alpha,
112  orient.release() ,
113  eqradius
114  );
115  } else if (strcmp(storage,"ROUNDEDCOMPOSITE")==0) {
116  IOTrace("ROUNDEDCOMPOSITE");
117  double radius;
118  is >> radius;
119  double eqradius;
120  is >> eqradius;
123  new Path_RoundedComposite(radius,eqradius,orient.release())
124  );
125  int size;
126  is >> size;
127  int i;
128  for (i=0;i<size;i++) {
129  Frame f;
130  is >> f;
131  tr->Add(f);
132  }
133  tr->Finish();
134  EatEnd(is,']');
135  IOTracePop();
136  IOTracePop();
137  return tr.release();
138  } else if (strcmp(storage,"COMPOSITE")==0) {
139  IOTrace("COMPOSITE");
140  int size;
142  is >> size;
143  int i;
144  for (i=0;i<size;i++) {
145  tr->Add(Path::Read(is));
146  }
147  EatEnd(is,']');
148  IOTracePop();
149  IOTracePop();
150  return tr.release();
151  } else if (strcmp(storage,"CYCLIC_CLOSED")==0) {
152  IOTrace("CYCLIC_CLOSED");
153  int times;
154  scoped_ptr<Path> tr( Path::Read(is) );
155  is >> times;
156  EatEnd(is,']');
157  IOTracePop();
158  IOTracePop();
159  return new Path_Cyclic_Closed(tr.release(),times);
160  } else {
162  }
163  return NULL; // just to avoid the warning;
164 }
165 
166 }
167 
represents rotations in 3 dimensional space.
Definition: frames.hpp:303
void IOTracePop()
pops a description of the IO-stack
Definition: error_stack.cxx:38
void EatEnd(std::istream &is, int delim)
Definition: utility_io.cxx:122
void EatWord(std::istream &is, const char *delim, char *storage, int maxsize)
Definition: utility_io.cxx:182
static Path * Read(std::istream &is)
Definition: path.cpp:60
static RotationalInterpolation * Read(std::istream &is)
void Eat(std::istream &is, int delim)
Definition: utility_io.cxx:108
A concrete implementation of a 3 dimensional vector class.
Definition: frames.hpp:162
represents a frame transformation in 3D space (rotation + translation)
Definition: frames.hpp:572
void IOTrace(const std::string &description)
Definition: error_stack.cxx:33
const double deg2rad
the value pi/180
Definition: utility.cxx:19


orocos_kdl
Author(s):
autogenerated on Thu Apr 13 2023 02:19:14