main_forceExttest.cc

This example demonstartes the BHandForceExt::moveForce() method.

00001 // ***************************************************************************
00002 //                           main_forceExttest.cc
00003 //                            Programm implementing test functions for bhandforcext
00004 //                            of each finger
00005 //
00006 //    copyright            : (C) 2005 by tbaier
00007 //    email                : tbaier@informatik.uni-hamburg.de
00008 // ***************************************************************************
00009 
00010 #include "bhandforceext.h"
00011 #include <iostream>
00012 
00013 
00014 int main(int argc, char *argv[])
00015 {
00016 
00017   if ((argc != 2)){
00018     std::cerr << "** usage: forceExtTest <serial port>  \n" << std::endl;
00019     return -1;
00020    }
00021 
00022   BHandForceExt hand(*++argv);
00023 
00024   try{
00025     hand.init();
00026     hand.open(FINGERS);
00027     hand.BHandForce::initForceSensor();
00028   }
00029   catch(BHandException e){
00030     std::cerr << e << std::endl;
00031   }
00032 
00033   //test calibration !!!
00034   double maxForce[3];
00035   double forces[3];
00036 
00037   for(int i = 2; i < 30; i++){
00038 
00039     for(int j = 0; j < 3; j++)
00040       maxForce[j] = i;
00041 
00042     hand.moveForce(FINGERS, maxForce);
00043 
00044     hand.getForce (forces);
00045     hand.getForce (forces);
00046     hand.stop();
00047 
00048     std::cout << " ** The desired force was : " << i << ". Results are:\n"
00049               << "    F1: " << forces[0] << "\n"
00050               << "    F2: " << forces[1] << "\n"
00051               << "    F3: " << forces[2] << "\n"
00052               << std::endl;
00053 
00054     std::cout << "\t  " << hand.getParam(F1, STRAIN)
00055               << "\t " << hand.getParam(F2, STRAIN)
00056               << "\t " << hand.getParam(F3, STRAIN) << std::endl;
00057 
00058 
00059     hand.open(FINGERS);
00060   }
00061 }


tams Tim Baier bhandlib v0.25
Generated Wed Aug 16 14:57:08 2006 by doxygen 1.4.7