Fawkes API  Fawkes Development Version
controller.h
00001 
00002 /***************************************************************************
00003  *  controller.h - Controller class for katana arm
00004  *
00005  *  Created: Tue Jan 03 11:40:31 2012
00006  *  Copyright  2012  Bahram Maleki-Fard, AllemaniACs RoboCup Team
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #ifndef __PLUGINS_KATANA_CONTROLLER_H_
00024 #define __PLUGINS_KATANA_CONTROLLER_H_
00025 
00026 #include <vector>
00027 
00028 namespace fawkes {
00029 #if 0 /* just to make Emacs auto-indent happy */
00030 }
00031 #endif
00032 
00033 /** @class KatanaController <plugins/katana/controller.h>
00034  * Abstract class for a Neuronics Katana controller.
00035  * @author Bahram Maleki-Fard
00036  */
00037 class KatanaController
00038 {
00039  public:
00040   /** Virtual empty destructor. */
00041   virtual ~KatanaController() {}
00042 
00043   // setup
00044   /** Initialize controller */
00045   virtual void init() = 0;
00046 
00047   /** Set maximum velocity.
00048   * @param vel velocity
00049   */
00050   virtual void set_max_velocity(unsigned int vel) = 0;
00051 
00052 
00053 
00054   // status checking
00055   /** Check if movement is final.
00056   * @return movement is final
00057   */
00058   virtual bool final() = 0;
00059 
00060   /** Check if controller provides joint angle values.
00061   * @return can get angle values
00062   */
00063   virtual bool joint_angles() = 0;
00064 
00065   /** Check if controller provides joint encoder values.
00066   * @return can get encoder values
00067   */
00068   virtual bool joint_encoders() = 0;
00069 
00070 
00071 
00072   // commands
00073   /** Calibrate the arm. */
00074   virtual void calibrate() = 0;
00075 
00076   /** Turn on arm/motors. */
00077   virtual void turn_on() = 0;
00078 
00079   /** Turn off arm/motors. */
00080   virtual void turn_off() = 0;
00081 
00082   /** Stop movement immediately. */
00083   virtual void stop() = 0;
00084 
00085   /** Store current coordinates of endeeffctor.
00086   * @param refresh fetch new joint data from device (update data in controller library).
00087   * No need to set to 'true' if 'read_motor_data()' is being called regularly.
00088   */
00089   virtual void read_coordinates(bool refresh = false) = 0;
00090 
00091   /** Read motor data of currently active joints from device into controller libray. */
00092   virtual void read_motor_data() = 0;
00093 
00094   /** Read all sensor data from device into controller libray. */
00095   virtual void read_sensor_data() = 0;
00096 
00097   /** Open Gripper.
00098   * @param blocking Is this a blocking call?
00099   */
00100   virtual void gripper_open(bool blocking = false) = 0;
00101 
00102   /** Close Gripper.
00103   * @param blocking Is this a blocking call?
00104   */
00105   virtual void gripper_close(bool blocking = false) = 0;
00106 
00107   /** Move endeffctor to given coordinates.
00108   * @param x translation on x-axis.
00109   * @param y translation on y-axis.
00110   * @param z translation on z-axis.
00111   * @param phi 1st rotation of euler-ZXZ-rotation
00112   * @param theta 2nd rotation of euler-ZXZ-rotation
00113   * @param psi 3rd rotation of euler-ZXZ-rotation
00114   * @param blocking Is this a blocking call?
00115   */
00116   virtual void move_to(float x, float y, float z, float phi, float theta, float psi, bool blocking = false) = 0;
00117 
00118   /** Move joints to encoder values.
00119   * @param encoders vector containing encoder values for all joints.
00120   * @param blocking Is this a blocking call?
00121   */
00122   virtual void move_to(std::vector<int> encoders, bool blocking = false) = 0;
00123 
00124   /** Move joints to angle values.
00125   * @param angles vector containing angle values for all joints.
00126   * @param blocking Is this a blocking call?
00127   */
00128   virtual void move_to(std::vector<float> angles, bool blocking = false) = 0;
00129 
00130   /** Move single joint/motor to encoder value.
00131   * @param id id of the joint/motor.
00132   * @param enc target encoder value.
00133   * @param blocking Is this a blocking call?
00134   */
00135   virtual void move_motor_to(unsigned short id, int enc, bool blocking = false) = 0;
00136 
00137   /** Move single joint/motor to angle value.
00138   * @param id id of the joint/motor.
00139   * @param angle target angle value.
00140   * @param blocking Is this a blocking call?
00141   */
00142   virtual void move_motor_to(unsigned short id, float angle, bool blocking = false) = 0;
00143 
00144   /** Move single joint/motor by encoder value (i.e. increase/decrease).
00145   * @param id id of the joint/motor.
00146   * @param enc increase/decrease by encoder value.
00147   * @param blocking Is this a blocking call?
00148   */
00149   virtual void move_motor_by(unsigned short id, int enc, bool blocking = false) = 0;
00150 
00151   /** Move single joint/motor by angle value (i.e. increase/decrease).
00152   * @param id id of the joint/motor.
00153   * @param angle increase/decrease by angle value.
00154   * @param blocking Is this a blocking call?
00155   */
00156   virtual void move_motor_by(unsigned short id, float angle, bool blocking = false) = 0;
00157 
00158 
00159 
00160 
00161   // getters
00162   /** Get x-coordinate of latest endeffector position.
00163    * Call 'read_coordinates()' to read latest position.
00164    * @return x-coordinate
00165    */
00166   virtual double x() = 0;
00167 
00168   /** Get y-coordinate of latest endeffector position.
00169    * Call 'read_coordinates()' to read latest position.
00170    * @return y-coordinate
00171    */
00172   virtual double y() = 0;
00173 
00174   /** Get z-coordinate of latest endeffector position.
00175    * Call 'read_coordinates()' to read latest position.
00176    * @return z-coordinate
00177    */
00178   virtual double z() = 0;
00179 
00180   /** Get x-coordinate of latest endeffector position.
00181    * Call 'read_coordinates()' to read latest position.
00182    * @return x-coordinate
00183    */
00184 
00185   /** Get phi-rotation of latest endeffector orientation.
00186    * Call 'read_coordinates()' to read latest orientation.
00187    * @return phi-rotation (1st rotation of euler-ZXZ-rotation)
00188    */
00189   virtual double phi() = 0;
00190 
00191   /** Get theta-rotation of latest endeffector orientation.
00192    * Call 'read_coordinates()' to read latest orientation.
00193    * @return theta-rotation (2nd rotation of euler-ZXZ-rotation)
00194    */
00195   virtual double theta() = 0;
00196 
00197   /** Get psi-rotation of latest endeffector orientation.
00198    * Call 'read_coordinates()' to read latest orientation.
00199    * @return psi-rotation (3rd rotation of euler-ZXZ-rotation)
00200    */
00201   virtual double psi() = 0;
00202 
00203   /** Get sensor values.
00204    * @param to vector to be filled with all available sensor values.
00205    * @param refresh refresh sensor data (call 'read_sensor_data')?
00206    */
00207   virtual void get_sensors(std::vector<int>& to, bool refresh = false) = 0;
00208 
00209   /** Get encoder values of joints/motors.
00210    * @param to vector to be filled with encoder values for active joints.
00211    * @param refresh refresh joints/motors data (call 'read_motor_data')?
00212    */
00213   virtual void get_encoders(std::vector<int>& to, bool refresh = false) = 0;
00214 
00215   /** Get angle values of joints/motors.
00216    * @param to vector to be filled with angle values for active joints.
00217    * @param refresh refresh joints/motors data (call 'read_motor_data')?
00218    */
00219   virtual void get_angles(std::vector<float>& to, bool refresh = false) = 0;
00220 
00221 
00222 };
00223 
00224 
00225 } // end of namespace fawkes
00226 
00227 #endif