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_ROBOTDESCRIPTION_
00026 #define _ROBOT_ROBOTDESCRIPTION_
00027
00028 #include <robot/robot>
00029
00030 #include <base/array>
00031 #include <base/Named>
00032 #include <base/Externalizable>
00033 #include <base/ReferencedObject>
00034
00035 #include <robot/PlatformDescription>
00036 #include <robot/ManipulatorDescription>
00037 #include <robot/KinematicChain>
00038
00039
00040 namespace robot {
00041
00042
00043
00044
00045 class RobotDescription : public base::Named, public base::Externalizable, public base::ReferencedObject
00046 {
00047 public:
00048 RobotDescription() {}
00049 RobotDescription(String name, ref<const PlatformDescription> platformDescription,
00050 array<ref<const ManipulatorDescription> > manipulatorDescriptions,
00051 array<Vector3> manipulatorOffsets)
00052 : Named(name), platformDescr(platformDescription),
00053 manipulatorDescrs(manipulatorDescriptions), manipOffsets(manipulatorOffsets)
00054 {}
00055
00056 RobotDescription(const RobotDescription& r)
00057 : Named(r), platformDescr(r.platformDescr),
00058 manipulatorDescrs(r.manipulatorDescrs),
00059 manipOffsets(r.manipOffsets)
00060 {}
00061
00062 virtual String className() const { return String("RobotDescription"); }
00063
00064
00065 void set(String name, ref<const PlatformDescription> platformDescription,
00066 array<ref<const ManipulatorDescription> > manipulatorDescriptions,
00067 array<Vector3> manipulatorOffsets)
00068 {
00069 setName(name);
00070 setPlatformDescription(platformDescription);
00071 setManipulatorDescriptions(manipulatorDescriptions);
00072 setManipulatorOffsets(manipulatorOffsets);
00073 }
00074
00075
00076
00077 virtual ref<PlatformDescription> newPlatformDescription() const { return ref<PlatformDescription>(NewObj PlatformDescription()); }
00078 virtual ref<ManipulatorDescription> newManipulatorDescription() const { return ref<ManipulatorDescription>(NewObj ManipulatorDescription()); }
00079
00080
00081 RobotDescription& operator=(const RobotDescription& r)
00082 {
00083 setName(r.getName());
00084 platformDescr = r.platformDescr;
00085 manipulatorDescrs = r.manipulatorDescrs;
00086 manipOffsets = r.manipOffsets;
00087 return *this;
00088 }
00089
00090
00091 virtual ref<const PlatformDescription> platform() const { return platformDescr; }
00092
00093
00094 virtual const array<ref<const ManipulatorDescription> >& manipulators() const { return manipulatorDescrs; }
00095
00096
00097 virtual const array<Vector3>& manipulatorOffsets() const { return manipOffsets; }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 virtual KinematicChain getKinematicChain(Int platformDOF=0, const base::Matrix4& platformTransform = base::Matrix4(),
00111 Int manipIndex=0, Int manipChainIndex=0) const;
00112
00113
00114
00115 virtual bool formatSupported(const String format, Real version = 1.0, ExternalizationType type = IO) const
00116 { return ( (format=="xml") && (version==1.0) ); }
00117 virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0);
00118 virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0) const
00119 { Externalizable::externalize(e,format,version); }
00120
00121
00122 protected:
00123 RobotDescription(const String& name) : Named(name) {}
00124
00125 void setPlatformDescription(ref<const PlatformDescription> pd) { platformDescr = pd; }
00126 void setManipulatorDescriptions(const array<ref<const ManipulatorDescription> >& mds) { manipulatorDescrs = mds; }
00127 void setManipulatorOffsets(const array<Vector3> offsets) { manipOffsets=offsets; }
00128
00129 private:
00130 ref<const PlatformDescription> platformDescr;
00131 array<ref<const ManipulatorDescription> > manipulatorDescrs;
00132 array<Vector3> manipOffsets;
00133
00134 friend class Robot;
00135 };
00136
00137
00138 }
00139
00140 #endif