00001 /* **-*-c++-*-************************************************************** 00002 Copyright (C)2002 David Jung <opensim@pobox.com> 00003 00004 This program/file is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. (http://www.gnu.org) 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 $Id: Robot 1039 2004-02-11 20:50:52Z jungd $ 00019 $Revision: 1.14 $ 00020 $Date: 2004-02-11 15:50:52 -0500 (Wed, 11 Feb 2004) $ 00021 $Author: jungd $ 00022 00023 ****************************************************************************/ 00024 00025 #ifndef _ROBOT_ROBOT_ 00026 #define _ROBOT_ROBOT_ 00027 00028 #include <robot/robot> 00029 00030 #include <base/array> 00031 00032 #include <robot/Controllable> 00033 #include <robot/RobotDescription> 00034 #include <robot/ToolDescription> 00035 00036 00037 namespace robot { 00038 00039 /** 00040 * An abstract Robot 00041 */ 00042 class Robot : public Controllable 00043 { 00044 public: 00045 00046 /** 00047 * A Robot provides a number of ControlInterfaces for various parts, such as 00048 * its drive platform, manipulators and other sensors etc. 00049 * Refer to documentation for specific concrete Robot implementation for specific 00050 * ControlInterface names and descriptions. 00051 * This method enumerates the ControlInterface names and their types. The interfaces 00052 * can be obtained by passing the name to the getControlInterface() method. 00053 */ 00054 virtual array<std::pair<String,String> > controlInterfaces() const; 00055 00056 /// get a ControlInterface by name (or throw if the name isn't a valid interface) 00057 virtual ref<ControlInterface> getControlInterface(String interfaceName="") throw(std::invalid_argument) = 0; 00058 00059 00060 /// is there a description of this robot available? 00061 virtual bool isDescriptionProvided() const { return false; } 00062 00063 /// get a description of the robot, if provided. Throws an exception if no description can be provided. 00064 virtual ref<const RobotDescription> getRobotDescription() const throw(std::logic_error) 00065 { 00066 if (isDescriptionProvided()) 00067 return robotDescription; 00068 else 00069 throw std::logic_error(Exception("no description available")); 00070 } 00071 00072 00073 // factory 00074 virtual ref<RobotDescription> newRobotDescription() const { return ref<RobotDescription>(NewObj RobotDescription()); } 00075 virtual ref<PlatformDescription> newPlatformDescription() const { return ref<PlatformDescription>(NewObj PlatformDescription()); } 00076 virtual ref<ManipulatorDescription> newManipulatorDescription() const { return ref<ManipulatorDescription>(NewObj ManipulatorDescription()); } 00077 virtual ref<ToolDescription> newToolDescription() const { return ref<ToolDescription>(NewObj ToolDescription()); } 00078 00079 00080 // various coordinate frames in which points are often expressed 00081 enum CoordFrame { 00082 UnknownFrame, // "" the coord frame is unknown 00083 EndEffectorFrame, // "ee" frame of a manipulator end-effector 00084 EndEffectorBaseFrame, // "eebase" frame with origin at a manipulator end-effector but axes alighed with the manipulator base frame 00085 BaseFrame, // "base" frame of a manipulator's base link 00086 MountFrame, // "mount" frame of a manipulator's mount (other end of base link - where manipulator is mounted to the robot platform) 00087 PlatformFrame, // "platform" frame of a robot platform 00088 WorldFrame // "world" the global world frame 00089 }; 00090 00091 // utility methods for converting between coordinate frames 00092 00093 /// Obtain transformation that will transform between coordinate frames 00094 /// Some transformations will require further information, such as specifying the forward kinematics 00095 /// transform from the base frame to the end-effector frame, or which manipulator 00096 /// (EndEffector[Base]Frame, BaseFrame & MountFrame) 00097 /// Transformations involving the WorldFrame require the platform position and orientation. 00098 base::Matrix4 coordFrameTransform(CoordFrame from, CoordFrame to = PlatformFrame, 00099 Int manipulatorIndex=0, 00100 const base::Matrix4& T = base::Matrix4(), 00101 const base::Point3& platformPosition = base::Point3(), 00102 const base::Orient& platformOrientation = base::Orient()) const; 00103 00104 /// convert String coord. frame specifier to CoordFrame 00105 static CoordFrame coordFrame(const String& frameString); 00106 00107 /// convert coord. frame specifier to String 00108 static String coordFrame(CoordFrame coordFrame); 00109 00110 protected: 00111 Robot() {} 00112 Robot(const Robot& r) 00113 : robotDescription(r.robotDescription) {} 00114 00115 void setRobotDescription(ref<const RobotDescription> robotDescription) { this->robotDescription=robotDescription; } 00116 00117 private: 00118 ref<const RobotDescription> robotDescription; ///< the description 00119 }; 00120 00121 00122 } // robot 00123 00124 #endif