Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

robot/ControlInterface

Go to the documentation of this file.
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: ControlInterface 1039 2004-02-11 20:50:52Z jungd $
00019   $Revision: 1.9 $
00020   $Date: 2004-02-11 15:50:52 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _ROBOT_CONTROLINTERFACE_
00026 #define _ROBOT_CONTROLINTERFACE_
00027 
00028 #include <robot/robot>
00029 #include <base/ReferencedObject>
00030 #include <base/Named>
00031 
00032 #include <base/Vector>
00033 
00034 
00035 namespace robot {
00036 
00037 /**
00038  * The abstract interface through which Controller(s) can control
00039  *  Controllables.
00040  *
00041  * Each interface has a number of inputs and outputs.  The meaning
00042  *  of these depend on the specific interface type.  Interfaces are
00043  *  also named.  Both the type and name are Strings.  Type strings
00044  *  are title case with an initial capital letter and name strings are
00045  *  title case with an initial lower case letter.
00046  *
00047  *  An example specification of a ControlInterface:
00048  *   type: "ManipulatorForceControl"
00049  *   name: "titanJoints"
00050  *   outputs: i:[0..N-1] - N= num of joints: commanded joint force/torque 
00051  *   inputs:  i:[0..N-1] - N= num of joints: current joint position
00052  *    
00053  *  The inputs and outputs of each interface are also named.
00054  *  For example, getInputName(0) on the above interface might return
00055  *   "jointPosition1".
00056  *  ControlInterfaces are obtained via the Controllable method
00057  *   getControlInterface(String interfaceName) by name.
00058  *  e.g. ref<ControlInterface> titan( c->getControlInterface("titanJoints") );
00059  *  They can then be passed to a Contoller that is expecting a ControlInterface
00060  *   of that type.
00061  *  e.g. controller->setControlInterface(titan);
00062  *   will succeed if the controller was expecting an interface of type "ManipulatorForceControl"
00063  *   and will be silently ignored otherwise.  Use the Controller::isConnected() to
00064  *   query if a Controller has been connected to all the ControlInterfaces it needs.
00065  */
00066 class ControlInterface : public base::ReferencedObject, public base::Named
00067 {
00068 public:
00069   ControlInterface() {}
00070   ControlInterface(const String& name, const String& type)
00071     : base::Named(name), type(type) {}
00072   ControlInterface(const ControlInterface& ci)
00073     : base::Named(ci), type(ci.type) {}
00074 
00075   const String& getType() const { return type; }
00076 
00077   virtual Int           inputSize() const = 0;
00078   virtual String        inputName(Int i) const = 0;
00079   virtual Real          getInput(Int i) const = 0;
00080   virtual const Vector& getInputs() const = 0;
00081 
00082   virtual Int    outputSize() const = 0;
00083   virtual String outputName(Int i) const = 0;
00084   virtual void   setOutput(Int i, Real value) = 0;
00085   virtual void   setOutputs(const Vector& values) = 0;
00086 
00087 protected:
00088   void setType(const String& type) { this->type=type; }
00089 
00090 private:
00091   String type;
00092 };
00093 
00094 
00095 } // robot
00096 
00097 #endif

Generated on Thu Jul 29 15:56:36 2004 for OpenSim by doxygen 1.3.6