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_MANIPULATORDESCRIPTION_
00026 #define _ROBOT_MANIPULATORDESCRIPTION_
00027
00028 #include <robot/robot>
00029
00030 #include <base/Named>
00031 #include <base/Externalizable>
00032 #include <base/ReferencedObject>
00033 #include <base/DOM>
00034 #include <robot/KinematicChain>
00035
00036
00037 namespace robot {
00038
00039
00040
00041
00042 class ManipulatorDescription : public base::Named, public base::Externalizable, public base::ReferencedObject
00043 {
00044 public:
00045 enum Type { Serial, Parallel };
00046
00047 ManipulatorDescription() : mtype(Serial) {}
00048 ManipulatorDescription(String name, Matrix4 baseTransform, KinematicChain kinematicChain)
00049 : Named(name), mtype(Serial), baseTransform(baseTransform), kinematicChain(kinematicChain) {}
00050 ManipulatorDescription(const ManipulatorDescription& md)
00051 : Named(md), mtype(md.mtype), baseTransform(md.baseTransform), kinematicChain(md.kinematicChain) {}
00052
00053 ManipulatorDescription& operator=(const ManipulatorDescription& md)
00054 {
00055 setName(md.getName());
00056 mtype = md.mtype;
00057 baseTransform = md.baseTransform;
00058 kinematicChain = md.kinematicChain;
00059 return *this;
00060 }
00061
00062 virtual String className() const { return String("ManipulatorDescription"); }
00063
00064 void set(String name, Matrix4 baseTransform, KinematicChain kinematicChain)
00065 {
00066 setType(Serial);
00067 setName(name);
00068 setBaseTransform(baseTransform);
00069 setKinematicChain(kinematicChain);
00070 }
00071
00072
00073 virtual Type type() const { return mtype; }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 virtual const KinematicChain& getKinematicChain(Int p=0) const
00085 { return kinematicChain; }
00086
00087
00088 virtual Matrix4 getBaseTransform() const { return baseTransform; }
00089
00090
00091 bool operator==(const ManipulatorDescription& md)
00092 {
00093 if (&md == this) return true;
00094 return (getName()==md.getName()) && (mtype==md.mtype)
00095 && (baseTransform==md.baseTransform) && (kinematicChain==md.kinematicChain);
00096 }
00097
00098 bool operator!=(const ManipulatorDescription& md) { return !(*this == md); }
00099
00100
00101
00102
00103 virtual bool formatSupported(const String format, Real version = 1.0, ExternalizationType type = IO) const
00104 { return ( (format=="xml") && (version==1.0) ); }
00105 virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0);
00106 virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0) const
00107 { Externalizable::externalize(e,format,version); }
00108
00109 protected:
00110 ManipulatorDescription(String name) : Named(name) {}
00111
00112 virtual void setType(Type type) { mtype=type; }
00113 virtual void setBaseTransform(const Matrix4& m) { baseTransform=m; }
00114 virtual void setKinematicChain(const KinematicChain& kc) { kinematicChain=kc; }
00115
00116
00117 virtual void outputElementXML(base::Externalizer& e, base::dom::DOMElement* manipElem, String format, Real version) const;
00118 virtual void inputElementXML(base::Externalizer& e, base::dom::DOMElement* manipElem, String format, Real version);
00119
00120 Type mtype;
00121 Matrix4 baseTransform;
00122 KinematicChain kinematicChain;
00123
00124 friend class Robot;
00125 };
00126
00127
00128 }
00129
00130 #endif