00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _ROBOT_SERIALMANIPULATOR_
00026 #define _ROBOT_SERIALMANIPULATOR_
00027
00028 #include <robot/robot>
00029
00030 #include <base/array>
00031 #include <base/Serializer>
00032 #include <robot/Manipulator>
00033
00034
00035 namespace robot {
00036
00037
00038
00039
00040
00041
00042 class SerialManipulator : public Manipulator
00043 {
00044 public:
00045
00046 virtual Type type() const { return Serial; }
00047
00048
00049 class JointParameters : public base::Serializable
00050 {
00051 public:
00052 enum JointType { Prismatic, Revolute };
00053
00054 JointParameters() {}
00055 JointParameters(JointType type, Real alpha, Real a, Real d, Real theta,
00056 Real minLimit, Real MaxLimit, Real minAccel=0, Real maxAccel=0,
00057 bool active=true)
00058 : type(type), alpha(alpha), a(a), d(d), theta(theta),
00059 minLimit(minLimit), maxLimit(maxLimit), minAccel(minAccel), maxAccel(maxAccel),
00060 active(active)
00061 {}
00062 ~JointParameters() {}
00063
00064 virtual String className() const { return String("JointParameters"); }
00065
00066
00067 JointType type;
00068
00069
00070 Real alpha;
00071 Real a;
00072 Real d;
00073 Real theta;
00074
00075 Real minLimit, maxLimit;
00076 Real minAccel, maxAccel;
00077
00078 bool active;
00079
00080 bool operator==(const JointParameters& p)
00081 { return (type==p.type)
00082 && Math::equals(alpha,p.alpha) && Math::equals(theta,p.theta)
00083 && Math::equals(d,p.d) && Math::equals(a,p.a)
00084 && (active==p.active);
00085 }
00086
00087 bool operator!=(const JointParameters& p) { return !(*this == p); }
00088
00089 virtual void serialize(base::Serializer& s)
00090 {
00091 s(type,"type");
00092 s(alpha,"alpha")(a,"a")(d,"d")(theta,"theta");
00093 s(minLimit,"minLimit")(maxLimit,"maxLimit");
00094 s(minAccel,"minAccel")(maxAccel,"maxAccel");
00095 s(active,"active");
00096 }
00097 };
00098
00099
00100 typedef base::array<JointParameters> Parameters;
00101
00102 virtual const Parameters& getParameters() const = 0;
00103 virtual Parameters& getParameters() = 0;
00104
00105 virtual void serialize(base::Serializer& s)
00106 {
00107 s(getName(),"name");
00108 s(getParameters(),"serialManipulatorParameters");
00109 }
00110
00111 protected:
00112 SerialManipulator() {}
00113 SerialManipulator(const SerialManipulator& sm) : Manipulator(sm) {}
00114 SerialManipulator(String name) : Manipulator(name) {}
00115
00116 };
00117
00118
00119
00120 inline std::ostream& operator<<(std::ostream& out, const robot::SerialManipulator& m)
00121 {
00122 out << "D-H parameters for each joint: (* marks variable)\n";
00123 const robot::SerialManipulator::Parameters& p = m.getParameters();
00124
00125 for(Int i=0; i<p.size(); i++) {
00126 const robot::SerialManipulator::JointParameters& j(p[i]);
00127 out << i << " - ";
00128
00129 switch(j.type){
00130 case SerialManipulator::JointParameters::Revolute:
00131 out << "Revolute :" << " alpha:" << Math::radToDeg(j.alpha) << ", a:" << j.a << ", d:" << j.d << ", theta:" << Math::radToDeg(j.theta) << "*\n";
00132 break;
00133 case SerialManipulator::JointParameters::Prismatic:
00134 out << "Prismatic:" << " alpha:" << Math::radToDeg(j.alpha) << ", a:" << j.a << ", d:" << j.d << "*, theta:" << Math::radToDeg(j.theta) << "\n";
00135 break;
00136 }
00137 }
00138 return out;
00139 }
00140
00141
00142 inline std::ostream& operator<<(std::ostream& out, const robot::SerialManipulator::Parameters& p)
00143 {
00144 out << "D-H parameters for each joint: (* marks variable)\n";
00145
00146 for(Int i=0; i<p.size(); i++) {
00147 out << i << " - ";
00148
00149 switch(p[i].type){
00150 case SerialManipulator::JointParameters::Revolute:
00151 out << "Revolute :" << " alpha:" << Math::radToDeg(p[i].alpha) << ", a:" << p[i].a << ", d:" << p[i].d << ", theta:" << " * " << "\n";
00152 break;
00153 case SerialManipulator::JointParameters::Prismatic:
00154 out << "Prismatic:" << " alpha:" << Math::radToDeg(p[i].alpha) << ", a:" << p[i].a << ", d:" << " * " << ", theta:" << Math::radToDeg(p[i].theta) << "\n";
00155 break;
00156 }
00157 }
00158 return out;
00159 }
00160
00161
00162
00163 inline std::ostream& operator<<(std::ostream& out, const robot::SerialManipulator::JointParameters& j)
00164 {
00165
00166 out << "D-H parameters for joint: (* marks variable)\n";
00167
00168 switch(j.type){
00169 case SerialManipulator::JointParameters::Revolute:
00170 out << "Revolute :" << " alpha:" << Math::radToDeg(j.alpha) << ", a:" << j.a << ", d:" << j.d << ", theta:" << " * " << "\n";
00171 break;
00172 case SerialManipulator::JointParameters::Prismatic:
00173 out << "Prismatic:" << " alpha:" << Math::radToDeg(j.alpha) << ", a:" << j.a << ", d:" << " * " << ", theta:" << Math::radToDeg(j.theta) << "\n";
00174 break;
00175 }
00176 return out;
00177 }
00178
00179 }
00180
00181 #endif