00001
00028
00029
00030 #ifndef SDHBASE_H_
00031 #define SDHBASE_H_
00032
00033 #include "sdhlibrary_settings.h"
00034
00035 #if SDH_USE_VCC
00036 # pragma warning(disable : 4290)
00037 #endif
00038
00039
00040
00041
00042
00043 #include "iostream"
00044
00045
00046
00047
00048
00049 #include "dbg.h"
00050 #include "sdhexception.h"
00051 #include "simplevector.h"
00052
00053
00054
00055
00056
00057 NAMESPACE_SDH_START
00058
00059
00060
00061
00062
00063
00064 extern std::ostream* g_sdh_debug_log;
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00078 class cSDHErrorInvalidParameter: public cSDHLibraryException
00079 {
00080 public:
00081 cSDHErrorInvalidParameter( cMsg const & _msg )
00082 : cSDHLibraryException( "cSDHErrorInvalidParameter", _msg )
00083 {}
00084 };
00085
00086
00097 class cSDHBase
00098 {
00099 public:
00100
00102 enum {
00103 All = -1
00104 };
00105
00106
00112 enum eErrorCode
00113 {
00114 eEC_SUCCESS = 0,
00115 eEC_NOT_AVAILABLE = 1,
00116 eEC_NO_SENSOR = 2,
00117 eEC_NOT_INITIALIZED = 3,
00118 eEC_ALREADY_RUNNING = 4,
00119 eEC_FEATURE_NOT_SUPPORTED = 5,
00120 eEC_INCONSISTENT_DATA = 6,
00121 eEC_TIMEOUT = 7,
00122 eEC_READ_ERROR = 8,
00123 eEC_WRITE_ERROR = 9,
00124 eEC_INSUFFICIENT_RESOURCES = 10,
00125 eEC_CHECKSUM_ERROR = 11,
00126 eEC_NOT_ENOUGH_PARAMS = 12 ,
00127 eEC_NO_PARAMS_EXPECTED = 13,
00128 eEC_CMD_UNKNOWN = 14,
00129 eEC_CMD_FORMAT_ERROR = 15,
00130 eEC_ACCESS_DENIED = 16,
00131 eEC_ALREADY_OPEN = 17,
00132 eEC_CMD_FAILED = 18,
00133 eEC_CMD_ABORTED = 19,
00134 eEC_INVALID_HANDLE = 20,
00135 eEC_DEVICE_NOT_FOUND = 21,
00136 eEC_DEVICE_NOT_OPENED = 22,
00137 eEC_IO_ERROR = 23,
00138 eEC_INVALID_PARAMETER = 24,
00139 eEC_RANGE_ERROR = 25,
00140 eEC_NO_DATAPIPE = 26,
00141 eEC_INDEX_OUT_OF_BOUNDS = 27,
00142 eEC_HOMING_ERROR = 28,
00143 eEC_AXIS_DISABLED = 29,
00144 eEC_OVER_TEMPERATURE = 30,
00145
00146 eEC_DIMENSION
00147 };
00148
00149
00155 enum eGraspId
00156 {
00157
00158 eGID_INVALID = -1,
00159 eGID_CENTRICAL = 0,
00160 eGID_PARALLEL = 1,
00161 eGID_CYLINDRICAL = 2,
00162 eGID_SPHERICAL = 3,
00163
00164 eGID_DIMENSION
00165 };
00166
00167
00169 enum eControllerType
00170 {
00171 eCT_INVALID = -1,
00172 eCT_POSE = 0,
00173 eCT_VELOCITY,
00174 eCT_VELOCITY_ACCELERATION,
00175
00176
00177
00178
00179 eCT_DIMENSION
00180 };
00181
00182
00184 enum eVelocityProfile
00185 {
00186 eVP_INVALID = -1,
00187 eVP_SIN_SQUARE,
00188 eVP_RAMP,
00189
00190 eVP_DIMENSION
00191 };
00192
00193
00203 cSDHBase( int debug_level );
00204
00205
00206
00210 virtual ~cSDHBase()
00211 {}
00212
00213
00215 void CheckIndex( int index, int maxindex, char const* name="" )
00216 throw (cSDHErrorInvalidParameter*);
00217
00218
00220 void CheckRange( double value, double minvalue, double maxvalue, char const* name="" )
00221 throw (cSDHErrorInvalidParameter*);
00222
00223
00225 void CheckRange( double* values, double* minvalues, double* maxvalues, char const* name="" )
00226 throw (cSDHErrorInvalidParameter*);
00227
00228
00230 static char const* GetStringFromErrorCode( eErrorCode error_code );
00231
00232
00234 static char const* GetStringFromGraspId( eGraspId grasp_id );
00235
00236
00238 static char const* GetStringFromControllerType( eControllerType controller_type );
00239
00240
00242 int GetNumberOfAxes( void );
00243
00244
00246 int GetNumberOfFingers( void );
00247
00248
00250 int GetNumberOfTemperatureSensors( void );
00251
00252
00254 eErrorCode GetFirmwareState( void );
00255
00256
00258 double GetEps( void );
00259
00260
00262 cSimpleVector const & GetEpsVector( void );
00263
00264
00266 virtual bool IsOpen( void ) = 0;
00267
00269 virtual void SetDebugOutput( std::ostream* debuglog )
00270 {
00271 cdbg.SetOutput( debuglog );
00272 }
00273 protected:
00275 cDBG cdbg;
00276
00278 int debug_level;
00279
00281 static char const* firmware_error_codes[];
00282
00283
00285 static char const* grasp_id_name[];
00286
00287
00289 static char const* controller_type_name[];
00290
00291
00293 int NUMBER_OF_AXES;
00294
00296 int NUMBER_OF_FINGERS;
00297
00299 int NUMBER_OF_TEMPERATURE_SENSORS;
00300
00302 int all_axes_used;
00303
00305 eErrorCode firmware_state;
00306
00311 double eps;
00312
00314 cSimpleVector eps_v;
00315
00317
00318
00320
00321
00323 cSimpleVector min_angle_v;
00324
00326 cSimpleVector max_angle_v;
00327
00328 };
00329
00330
00331
00332
00333 NAMESPACE_SDH_END
00334
00335 #endif
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348