path_circle.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Erwin Aertbelien Mon May 10 19:10:36 CEST 2004 path_circle.cxx
3 
4  path_circle.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  * \author
29  * Erwin Aertbelien, Div. PMA, Dep. of Mech. Eng., K.U.Leuven
30  *
31  * \version
32  * ORO_Geometry V0.2
33  *
34  * \par History
35  * - $log$
36  *
37  * \par Release
38  * $Id: path_circle.cpp,v 1.1.1.1.2.5 2003/07/24 13:26:15 psoetens Exp $
39  * $Name: $
40  ****************************************************************************/
41 
42 
43 #include "path_circle.hpp"
44 #include "utilities/error.h"
45 
46 namespace KDL {
47 
48 
49 
50 Path_Circle::Path_Circle(const Frame& F_base_start,
51  const Vector& _V_base_center,
52  const Vector& V_base_p,
53  const Rotation& R_base_end,
54  double alpha,
55  RotationalInterpolation* _orient,
56  double _eqradius,
57  bool _aggregate) :
58  orient(_orient) ,
59  eqradius(_eqradius),
60  aggregate(_aggregate)
61  {
62  F_base_center.p = _V_base_center;
63  orient->SetStartEnd(F_base_start.M,R_base_end);
64  double oalpha = orient->Angle();
65 
66  Vector x(F_base_start.p - F_base_center.p);
67  radius = x.Normalize();
69  Vector tmpv(V_base_p-F_base_center.p);
70  tmpv.Normalize();
71  Vector z( x * tmpv);
72  double n = z.Normalize();
74  F_base_center.M = Rotation(x,z*x,z);
75  double dist = alpha*radius;
76  // See what has the slowest eq. motion, and adapt
77  // the other to this slower motion
78  // use eqradius to transform between rot and transl.
79  // the same as for lineair motion
80  if (oalpha*eqradius > dist) {
81  // rotational_interpolation is the limitation
82  pathlength = oalpha*eqradius;
83  scalerot = 1/eqradius;
84  scalelin = dist/pathlength;
85  } else {
86  // translation is the limitation
87  pathlength = dist;
88  scalerot = oalpha/pathlength;
89  scalelin = 1;
90  }
91  }
92 
93 
94 
95 double Path_Circle::LengthToS(double length) {
96  return length/scalelin;
97 }
98 
99 
101  return pathlength;
102 }
103 
104 Frame Path_Circle::Pos(double s) const {
105  double p = s*scalelin / radius;
106  return Frame(orient->Pos(s*scalerot),
108  );
109 
110 }
111 
112 Twist Path_Circle::Vel(double s,double sd) const {
113  double p = s*scalelin / radius;
114  double v = sd*scalelin / radius;
115  return Twist( F_base_center.M*Vector(-radius*sin(p)*v,radius*cos(p)*v,0),
116  orient->Vel(s*scalerot,sd*scalerot)
117  );
118 }
119 
120 Twist Path_Circle::Acc(double s,double sd,double sdd) const {
121  double p = s*scalelin / radius;
122  double cp = cos(p);
123  double sp = sin(p);
124  double v = sd*scalelin / radius;
125  double a = sdd*scalelin / radius;
126  return Twist( F_base_center.M*Vector(
127  -radius*cp*v*v - radius*sp*a,
128  -radius*sp*v*v + radius*cp*a,
129  0
130  ),
131  orient->Acc(s*scalerot,sd*scalerot,sdd*scalerot)
132  );
133 }
134 
136  return new Path_Circle(
137  Pos(0),
142  orient->Clone(),
143  eqradius,
144  aggregate
145  );
146 }
147 
149  if (aggregate)
150  delete orient;
151 }
152 
153 
154 
155 void Path_Circle::Write(std::ostream& os) {
156  os << "CIRCLE[ ";
157  os << " " << Pos(0) << std::endl;
158  os << " " << F_base_center.p << std::endl;
159  os << " " << F_base_center.M.UnitY() << std::endl;
160  os << " " << orient->Pos(pathlength*scalerot) << std::endl;
161  os << " " << pathlength*scalelin/radius/deg2rad << std::endl;
162  os << " ";orient->Write(os);
163  os << " " << eqradius;
164  os << "]"<< std::endl;
165 }
166 
167 
168 }
169 
represents rotations in 3 dimensional space.
Definition: frames.hpp:301
virtual void Write(std::ostream &os)
Vector UnitY() const
Access to the underlying unitvectors of the rotation matrix.
Definition: frames.hpp:522
virtual double PathLength()
double Normalize(double eps=epsilon)
Definition: frames.cpp:148
virtual RotationalInterpolation * Clone() const =0
virtual Frame Pos(double s) const
double LengthToS(double length)
Definition: path_circle.cpp:95
Path_Circle(const Frame &F_base_start, const Vector &V_base_center, const Vector &V_base_p, const Rotation &R_base_end, double alpha, RotationalInterpolation *otraj, double eqradius, bool _aggregate=true)
Definition: path_circle.cpp:50
Rotation M
Orientation of the Frame.
Definition: frames.hpp:573
virtual Path * Clone()
represents both translational and rotational velocities.
Definition: frames.hpp:720
virtual Rotation Pos(double theta) const =0
virtual double Angle()=0
A concrete implementation of a 3 dimensional vector class.
Definition: frames.hpp:160
RotationalInterpolation * orient
Definition: path_circle.hpp:64
double epsilon
default precision while comparing with Equal(..,..) functions. Initialized at 0.0000001.
Vector p
origine of the Frame
Definition: frames.hpp:572
virtual Twist Acc(double s, double sd, double sdd) const
virtual Vector Vel(double theta, double thetad) const =0
virtual void SetStartEnd(Rotation start, Rotation end)=0
virtual ~Path_Circle()
represents a frame transformation in 3D space (rotation + translation)
Definition: frames.hpp:570
virtual void Write(std::ostream &os) const =0
virtual Vector Acc(double theta, double thetad, double thetadd) const =0
const double deg2rad
the value pi/180
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
Definition: rall1d.h:321
virtual Twist Vel(double s, double sd) const
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
Definition: rall1d.h:313


orocos_kdl
Author(s):
autogenerated on Sat Jun 15 2019 19:07:36