00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BHANDFORCEEXT_H
00009 #define BHANDFORCEEXT_H
00010
00011 #include <string>
00012 #include <zbsplinefunction.h>
00013
00014 #include "bhand.h"
00015 #include "bhandext.h"
00016 #include "bhandforce.h"
00017 #include "zlinearfunction.h"
00018 #include "bhkinematic.h"
00019 #include "bhfinger.h"
00020 #include "bhspread.h"
00021
00022 #include "bhspeedgen.h"
00023
00024
00054 class BHandForceExt : public BHandForce {
00055 public:
00056
00061 BHandForceExt(std::string devName);
00062
00063
00067 virtual ~BHandForceExt();
00068
00069 void init();
00070
00076
00085 void move(const Motors motors, const bool plotIt = false) throw (BHandException);
00086
00097 void move(const Motors motors, const int position) throw (BHandException);
00098
00110 void move(const Motors motors, const int position[4]) throw (BHandException);
00111
00112 #if 0
00113
00118 void moveG(const Motors motors, const int position[4])throw (BHandException){};
00119 #endif
00120 void moveG(const Motors motors) throw (BHandException);
00121 void moveG(const Motors motors, const int position) throw (BHandException);
00122
00123
00124
00141 void adjustForce(const Motors motors, const double force) throw (BHandException);
00142
00143
00144
00159 void moveForce(const Motors motors, double force[3], const bool sameSpeed = false) throw (BHandException, BHMotorException);
00160
00173 void moveForce(const Motors motors, double force) throw (BHandException, BHMotorException);
00174
00175
00189 void force2File(std::string fileName, bool showPlot = false);
00190
00192
00197
00198
00206 void setMaxForce(const double force, const Motors motors = FINGERS);
00207
00215 void setMinForce(const double force, const Motors motors = FINGERS);
00216
00218
00222
00232 void getForce(double *forces, const bool update = true);
00233
00234 void writeForce(std::ostream *stream);
00235
00236
00237
00239
00240
00241
00242
00243 protected:
00244
00248 ZLinearFunction RealForceFunction[NUM_FINGERS];
00249
00250 double toN(ZLinearFunction &f, double strain);
00251 int toStrain(ZLinearFunction &f, double force);
00252
00253 };
00254
00255
00256
00257
00258
00259 inline double BHandForceExt::toN(ZLinearFunction &f, double strain)
00260 {
00261 return f.output(strain);
00262 }
00263
00264
00265
00266
00267
00268 inline int BHandForceExt::toStrain(ZLinearFunction &f, double force)
00269 {
00270 return (int) f.inverse(force);
00271 }
00272
00273
00274
00275
00276
00277 inline void BHandForceExt::getForce(double *forces, const bool update)
00278 {
00279 if(update){
00280 try{
00281
00282 BHandForce::getForce();
00283
00284 }
00285 catch(...){
00286 std::cout << " ** getForce(int *forces, const bool update) " << std::endl;
00287 }
00288 }
00289
00290
00291
00292
00293
00294
00295 forces[0] = toN(RealForceFunction[0], MoveParams->Fingers[0]->getForce());
00296 forces[1] = toN(RealForceFunction[1], MoveParams->Fingers[1]->getForce());
00297 forces[2] = toN(RealForceFunction[2], MoveParams->Fingers[2]->getForce());
00298
00299 }
00300
00301 #if 1
00302
00303
00304
00305 inline void BHandForceExt::moveForce(const Motors motors, double force) throw (BHandException, BHMotorException)
00306 {
00307 double force3[3];
00308 force3[0] = force;
00309 force3[1] = force;
00310 force3[2] = force;
00311 moveForce(motors, force3, true);
00312 }
00313 #endif
00314
00315
00316 #if 1
00317
00318
00319
00320 inline void BHandForceExt::writeForce(std::ostream *stream)
00321 {
00322 double forces[3] = {0,0,0};
00323 getForce(forces,true);
00324 *stream << forces[0] << " " << forces[1] << " " << forces[2] << " ";
00325 }
00326 #endif
00327
00328 #endif