Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * controller_kni.h - KNI 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_KNI_H_ 00024 #define __PLUGINS_KATANA_CONTROLLER_KNI_H_ 00025 00026 #include "controller.h" 00027 00028 #include <core/utils/refptr.h> 00029 #include <string> 00030 #include <memory> 00031 #include <vector> 00032 00033 // Classes from libkni (KNI) 00034 class CCdlCOM; 00035 class CCplSerialCRC; 00036 class CLMBase; 00037 class CKatBase; 00038 class CSctBase; 00039 class TMotInit; 00040 00041 namespace fawkes { 00042 #if 0 /* just to make Emacs auto-indent happy */ 00043 } 00044 #endif 00045 00046 //class RefPtr; 00047 00048 class KatanaControllerKni : public KatanaController 00049 { 00050 public: 00051 KatanaControllerKni(); 00052 virtual ~KatanaControllerKni(); 00053 00054 // setup 00055 virtual void setup(std::string& device, std::string& kni_conffile, 00056 unsigned int read_timeout, unsigned int write_timeout); 00057 virtual void init(); 00058 virtual void set_max_velocity(unsigned int vel); 00059 00060 00061 // status checking 00062 virtual bool final(); 00063 virtual bool joint_angles(); 00064 virtual bool joint_encoders(); 00065 00066 // commands 00067 virtual void calibrate(); 00068 virtual void stop(); 00069 virtual void turn_on(); 00070 virtual void turn_off(); 00071 virtual void read_coordinates(bool refresh = false); 00072 virtual void read_motor_data(); 00073 virtual void read_sensor_data(); 00074 virtual void gripper_open(bool blocking = false); 00075 virtual void gripper_close(bool blocking = false); 00076 virtual void move_to(float x, float y, float z, float phi, float theta, float psi, bool blocking = false); 00077 virtual void move_to(std::vector<int> encoders, bool blocking = false); 00078 virtual void move_to(std::vector<float> angles, bool blocking = false); 00079 virtual void move_motor_to(unsigned short id, int enc, bool blocking = false); 00080 virtual void move_motor_to(unsigned short id, float angle, bool blocking = false); 00081 virtual void move_motor_by(unsigned short id, int enc, bool blocking = false); 00082 virtual void move_motor_by(unsigned short id, float angle, bool blocking = false); 00083 00084 // getters 00085 virtual double x(); 00086 virtual double y(); 00087 virtual double z(); 00088 virtual double phi(); 00089 virtual double theta(); 00090 virtual double psi(); 00091 virtual void get_sensors(std::vector<int>& to, bool refresh = false); 00092 virtual void get_encoders(std::vector<int>& to, bool refresh = false); 00093 virtual void get_angles(std::vector<float>& to, bool refresh = false); 00094 00095 private: 00096 double __x, __y, __z; 00097 double __phi, __theta, __psi; 00098 00099 std::string __cfg_device; 00100 std::string __cfg_kni_conffile; 00101 unsigned int __cfg_read_timeout; 00102 unsigned int __cfg_write_timeout; 00103 00104 fawkes::RefPtr<CLMBase> __katana; 00105 std::auto_ptr<CCdlCOM> __device; 00106 std::auto_ptr<CCplSerialCRC> __protocol; 00107 CKatBase *__katbase; 00108 CSctBase *__sensor_ctrl; 00109 std::vector<TMotInit> __motor_init; 00110 00111 std::vector<short> __active_motors; 00112 std::vector<int> __gripper_last_pos; 00113 00114 bool motor_oor(unsigned short id); 00115 bool motor_final(unsigned short id); 00116 void cleanup_active_motors(); 00117 void add_active_motor(unsigned short id); 00118 00119 }; 00120 00121 00122 } // end of namespace fawkes 00123 00124 #endif