84 "Simple demo to test cDSA class of SDHLibrary-cpp.\n" 87 "- You must specify at least one of these options to see some output:\n" 88 " -f | --fullframe \n" 90 " -c | --controllerinfo \n" 91 " -s | --sensorinfoinfo\n" 92 " -m | --matrixinfo=N\n" 95 " - Read a single full frame from tactile sensors connected to port 3 = COM4:\n" 96 " > demo-dsa --dsaport=3 -f\n" 98 " - Read a single full frame from tactile sensors connected via TCP/IP (ethernet):\n" 99 " The tactile sensors have IP-Address 192.168.1.42 and use TCP port 13000.\n" 100 " (Requires at least SDH-firmware v0.0.3.2)\n" 101 " > demo-dsa --dsa_tcp=192.168.1.42:13000 -f\n" 103 " - Read full frames continuously once per second from tactile sensors\n" 104 " connected to port 3 = COM4:\n" 105 " > demo-dsa --dsaport=3 -f -r 1\n" 107 " - Read full frames continuously 10 times per second from tactile sensors\n" 108 " connected to port 3 = COM4:\n" 109 " > demo-dsa --dsaport=3 -f -r 10\n" 111 " - Read full frames continuously as fast as possible (DSA push-mode)\n" 112 " from tactile sensors connected to port 3 = COM4:\n" 113 " > demo-dsa --dsaport=3 -f -r 30\n" 115 " - Read a single full frame from tactile sensors connected to USB\n" 116 " to RS232 converter 0:\n" 117 " > demo-dsa --dsa_rs_device=/dev/ttyUSB0 -f \n" 119 " - Read the sensor, controller, matrix 0 infos \n" 120 " from tactile sensors connected to port 3 = COM4:\n" 121 " > demo-dsa --dsaport=3 -s -c -m 0 \n" 123 " - Get the version info of both the joint controllers and the tactile \n" 124 " sensor firmware from an SDH connected via Ethernet.\n" 125 " The joint controllers and the tactile sensors have a common IP-Address,\n" 126 " here 192.168.1.42. The SDH controller is attached to the \n" 127 " default TCP port 23 and the tactile sensors to the default TCP port 13000.\n" 128 " (Requires at least SDH-firmware v0.0.3.2)\n" 129 " > demo-dsa --tcp=192.168.1.42 --dsa_tcp -v\n" 131 " - Get the version info of both the joint controllers and the tactile \n" 132 " sensor firmware from an SDH connected to \n" 133 " - port 2 = COM3 (joint controllers) and \n" 134 " - port 3 = COM4 (tactile sensor controller) \n" 135 " > demo-dsa -p 2 --dsaport=3 -v\n" 136 " - Set the sensitivity of all tactile sensor matrixes to 0.75 temporarily.\n" 137 " The value will be used only temporarily (until reset or power cycle). \n" 138 " > demo-dsa --dsaport=3 --sensitivity=0.75 \n" 140 " - Set the sensitivity of all tactile sensor matrixes to 0.75 persistently.\n" 141 " The value will be stored persistently (i.e. will remain after reset or \n" 143 " > demo-dsa --dsaport=3 --sensitivity=0.75 --persistent\n" 145 " - Reset the sensitivity of all tactile sensor matrixes to factory default.\n" 146 " > demo-dsa --dsaport=3 --sensitivity=0.75 --reset\n" 148 " - Set the sensitivity of tactile sensor matrices 1 and 4 to individual\n" 149 " values temporarily.\n" 150 " The value will be used only temporarily (until reset or power cycle).\n" 151 " Sensor 1 (distal sensor of finger 1) will be set to 0.1\n" 152 " Sensor 4 (proximal sensor of finger 3) will be set to 0.4\n" 153 " > demo-dsa --dsaport=3 --sensitivity1=0.1 --sensitivity4=0.4 \n" 155 " - Like for the sensitivity the thresholds can be adjusted via \n" 156 " the --threshold=VALUE parameter.\n" 159 " - see the bug description for \"cDSAException: Checksum Error on Windows\n" 160 " console\" in the Related Pages->Bug List section of the doxygen\n" 164 char const*
__author__ =
"Dirk Osswald: dirk.osswald@de.schunk.com";
165 char const*
__url__ =
"http://www.schunk.com";
166 char const*
__version__ =
"$Id: demo-dsa.cpp 10351 2013-06-18 16:28:14Z Osswald2 $";
170 "usage: demo-dsa [options]\n" 179 int main(
int argc,
char **argv )
187 cSDHOptions options(
"general sdhcom_common dsacom dsaother dsaadjust" );
199 cdbg <<
"Debug messages of " << argv[0] <<
" are printed like this.\n";
227 cout <<
"Controller Info:\n";
233 cout <<
"Sensor Info:\n";
237 for ( i=0; i<6; i++ )
242 cout <<
"Matrix Info " << options.
matrixinfo[i] <<
":\n";
250 cout <<
" sensitivity = " << sensitivity_info.
cur_sens <<
"\n";
251 cout <<
" factory_sensitivity = " << sensitivity_info.
fact_sens <<
"\n";
261 cerr <<
"To be able to read the sensitivity/threshold settings you must update\n";
262 cerr <<
"the firmware of the DSACON32m (tactile sensor controller in the SDH)\n";
263 cerr <<
"to at least release R268.\n";
268 char const* descr[] = {
" proximal",
" distal" };
269 for ( i=0; i<6; i++ )
272 cout <<
"Sensor " << i <<
" (finger " << i/2+1 << descr[i%2] <<
")\n";
273 cout <<
" sensitivity = " << sensitivity_info.
cur_sens <<
"\n";
274 cout <<
" factory_sensitivity = " << sensitivity_info.
fact_sens <<
"\n";
283 for ( i=0; i<6; i++ )
291 for ( i=0; i<6; i++ )
304 bool do_single_frames = options.
framerate < 30;
306 if ( do_single_frames )
309 cdbg <<
"Starting DSA pull-mode, framerate=0 do_rle=" << options.
do_RLE <<
" do_data_acquisition=false" <<
"\n";
315 cdbg <<
"Starting DSA push-mode, framerate=1 do_rle=" << options.
do_RLE <<
" do_data_acquisition=true" <<
"\n";
322 double period_s = 0.0;
324 period_s = 1.0 / double(options.
framerate);
337 if ( do_single_frames )
347 cout <<
"Actual framerate=" << ((nb_frames-nb_last)/last.
Elapsed( now )) <<
"Hz nb_frames=" << nb_frames <<
" nb_errors=" << nb_errors <<
" (" << ((100.0*nb_errors)/nb_frames) <<
"%)\n";
349 if ( last.
Elapsed( now ) > 3.0 )
359 cerr <<
"Caught and ignored cDSAException: " << e->
what() <<
" nb_errors=" << nb_errors <<
"\n";
365 if ( do_single_frames )
367 remaining_s = period_s - (start.
Elapsed());
368 if ( remaining_s > 0.0 )
380 cerr <<
"\ndemo-dsa main(): Caught exception from SDHLibrary: " << e->
what() <<
". Giving up!\n";
385 cerr <<
"\ncaught unknown exception, giving up\n";
int main(int argc, char **argv)
int Parse(int argc, char **argv, char const *helptext, char const *progname, char const *version, char const *libname, char const *librelease)
This file contains the interface to class #SDH::cSDH, the end user class to access the SDH from a PC...
#define SDH_ASSERT_TYPESIZES()
macro to assert that the defined typedefs have the expected sizes
void StoreNow(void)
Store current time internally.
A class to print colored debug messages.
sMatrixInfo const & GetMatrixInfo(int m) const
Return a reference to the sMatrixInfo of matrix m read from the remote DSACON32m controller.
Derived exception class for low-level DSA related exceptions.
double Elapsed(void) const
Return time in seconds elapsed between the time stored in the object and now.
void Close(void)
Set the framerate of the remote DSACON32m controller to 0 and close connection to it...
Implementation of a class to parse common SDH related command line options.
static char const * GetLibraryRelease(void)
void SetFramerate(UInt16 framerate, bool do_RLE=true, bool do_data_acquisition=true)
void SetMatrixSensitivity(int matrix_no, double sensitivity, bool do_all_matrices=false, bool do_reset=false, bool do_persistent=false)
SDH::cDSA is the end user interface class to access the DSACON32m, the tactile sensor controller of t...
Base class for exceptions in the SDHLibrary-CPP.
Interface of auxilliary utility functions for SDHLibrary-CPP.
virtual const char * what() const
This file contains interface to #SDH::cDSA, a class to communicate with the tactile sensors of the SD...
#define USING_NAMESPACE_SDH
Structure to hold info about the sensitivity settings of one sensor patch.
This file contains settings to make the SDHLibrary compile on differen systems:
char dsa_rs_device[MAX_DEV_LENGTH]
Very simple class to measure elapsed time.
static char const * GetLibraryName(void)
void SetMatrixThreshold(int matrix_no, UInt16 threshold, bool do_all_matrices=false, bool do_reset=false, bool do_persistent=false)
This file contains some basic definitions (defines, macros, datatypes)
class for command line option parsing holding option parsing results
unsigned int threshold[6]
sSensorInfo const & GetSensorInfo(void) const
Return a reference to the sSensorInfo read from the remote DSACON32m controller.
USING_NAMESPACE_SDH NAMESPACE_SDH_START std::ostream * g_sdh_debug_log
sTactileSensorFrame const & UpdateFrame()
read the tactile sensor frame from remote DSACON32m and return a reference to it. A command to query ...
sControllerInfo const & GetControllerInfo(void) const
Return a reference to the sControllerInfo read from the remote DSACON32m controller.
UInt16 GetMatrixThreshold(int matrix_no)
sSensitivityInfo GetMatrixSensitivity(int matrix_no)
char const * __copyright__
void SetFramerateRetries(UInt16 framerate, bool do_RLE=true, bool do_data_acquisition=true, unsigned int retries=0, bool ignore_exceptions=false)