Go to the documentation of this file.
44 #define _USE_MATH_DEFINES
57 #define DEMO_BENCHMARK_USE_COMBINED_SET_GET 1
67 "Simple script to benchmark communication speed of the SDH:\n"
68 "The hand will move to a start position in coordinated position control\n"
69 "mode first. Then periodic movements are performed using the velocity\n"
70 "with acceleration ramp controller while the communication and control\n"
74 " - Make SDH connected via Ethernet move.\n"
75 " The SDH has IP-Address 192.168.1.42 and is attached to TCP port 23.\n"
76 " (Requires at least SDH-firmware v0.0.3.1)\n"
77 " > demo-benchmark --tcp=192.168.1.42:23\n"
79 " - Make SDH connected to port 2 = COM3 move:\n"
80 " > demo-benchmark -p 2 --dsaport=3\n"
82 " - Make SDH connected to USB to RS232 converter 0 move:\n"
83 " > demo-benchmark --sdh_rs_device=/dev/ttyUSB0 --dsa_rs_device=/dev/ttyUSB1\n"
85 " - Get the version info of both the joint controllers and the tactile \n"
86 " sensor firmware from an SDH connected via Ethernet.\n"
87 " The joint controllers and the tactile sensors have a common IP-Address,\n"
88 " here 192.168.1.42. The SDH controller is attached to the \n"
89 " default TCP port 23 and the tactile sensors to the default TCP port 13000.\n"
90 " (Requires at least SDH-firmware v0.0.3.2)\n"
91 " > demo-benchmark --tcp=192.168.1.42 --dsa_tcp -v\n"
93 " - Get the version info of both the joint controllers and the tactile \n"
94 " sensor firmware from an SDH connected to:\n"
95 " - port 2 = COM3 (joint controllers) and \n"
96 " - port 3 = COM4 (tactile sensor controller) \n"
97 " > demo-benchmark --port=2 --dsaport=3 -v\n";
98 char const*
__author__ =
"Dirk Osswald: dirk.osswald@de.schunk.com";
99 char const*
__url__ =
"http://www.schunk.com";
100 char const*
__version__ =
"$Id: demo-benchmark.cpp 10895 2013-11-11 14:15:08Z Osswald2 $";
107 "usage: demo-benchmark [options]\n"
120 sRecordedData(
double _t, std::vector<double>
const& _aaa, std::vector<double>
const& _aav, std::vector<double>
const& _atv ) :
147 int main(
int argc,
char** argv )
167 cdbg <<
"Debug messages of " << argv[0] <<
" are printed like this.\n";
177 cdbg <<
"Connecting to joint controller...\n";
179 cdbg <<
"Successfully created cSDH instance\n";
183 cdbg <<
"Successfully opened communication to SDH\n";
194 std::vector<double> start_pose;
195 start_pose.push_back( 10 );
196 start_pose.push_back( -10 );
197 start_pose.push_back( 0 );
198 start_pose.push_back( -10 );
199 start_pose.push_back( 0 );
200 start_pose.push_back( -10 );
201 start_pose.push_back( 0 );
204 std::vector<double> end_pose;
205 end_pose.push_back( 80.0 );
206 end_pose.push_back( -80.0 );
207 end_pose.push_back( -80.0 );
208 end_pose.push_back( -80.0 );
209 end_pose.push_back( -80.0 );
210 end_pose.push_back( -80.0 );
211 end_pose.push_back( -80.0 );
224 std::vector<double> aperiod;
225 aperiod.push_back( 10.0 );
226 aperiod.push_back( 5.0 );
227 aperiod.push_back( 4.0 );
228 aperiod.push_back( 3.0 );
229 aperiod.push_back( 4.0 );
230 aperiod.push_back( 5.0 );
231 aperiod.push_back( 3.0 );
235 std::vector<double> aamplitude( aperiod.size(), 0.0 );
237 for ( ai=0; ai<nb_axes; ai++ )
239 aamplitude[ai] = (end_pose[ai]-start_pose[ai]) * M_PI / aperiod[ai];
241 ToRange( aamplitude[ai], -max_vel[ai]+1.0, +max_vel[ai]-1.0 );
254 cdbg <<
" Moving with velocity with acceleration ramp controller.\n";
261 std::vector<double> aaa(nb_axes, 0.0);
262 std::vector<double> aav(nb_axes, 0.0);
263 std::vector<double> atv(nb_axes, 0.0);
271 std::vector<sRecordedData> recorded_data;
276 double const duration = 10.0;
287 for ( ai=0; ai<nb_axes; ai++ )
289 atv[ai] = aamplitude[ai] * sin( 2.0*M_PI/aperiod[ai] * t );
292 #if DEMO_BENCHMARK_USE_COMBINED_SET_GET
305 recorded_data.push_back(
sRecordedData( t, aaa, aav, atv ) );
306 }
while ( t < duration );
313 double brake_time = 0.5;
317 for ( ai=0; ai<nb_axes; ai++ )
319 atv[ai] = aav[ai] * ( 1.0-t/brake_time);
336 cdbg <<
"Successfully disabled joint controllers of SDH and closed connection\n";
341 double dt_min = 1000.0;
347 std::cout <<
"# combined gnuplot commands + data. Use plot.py for easy viewing\n";
348 std::cout <<
"## plot using 2:3 with lines title 'dt [s]'\n";
349 std::cout <<
"## plot using 2:4 with lines title 'aaa[0] [deg]'\n";
350 std::cout <<
"## plot using 2:5 with lines title 'aaa[1] [deg]'\n";
351 std::cout <<
"## plot using 2:6 with lines title 'aaa[2] [deg]'\n";
352 std::cout <<
"## plot using 2:7 with lines title 'aaa[3] [deg]'\n";
353 std::cout <<
"## plot using 2:8 with lines title 'aaa[4] [deg]'\n";
354 std::cout <<
"## plot using 2:9 with lines title 'aaa[5] [deg]'\n";
355 std::cout <<
"## plot using 2:10 with lines title 'aaa[6] [deg]'\n";
356 std::cout <<
"## plot using 2:11 with lines title 'aav[0] [deg/s]'\n";
357 std::cout <<
"## plot using 2:12 with lines title 'aav[1] [deg/s]'\n";
358 std::cout <<
"## plot using 2:13 with lines title 'aav[2] [deg/s]'\n";
359 std::cout <<
"## plot using 2:14 with lines title 'aav[3] [deg/s]'\n";
360 std::cout <<
"## plot using 2:15 with lines title 'aav[4] [deg/s]'\n";
361 std::cout <<
"## plot using 2:16 with lines title 'aav[5] [deg/s]'\n";
362 std::cout <<
"## plot using 2:17 with lines title 'aav[6] [deg/s]'\n";
363 std::cout <<
"## plot using 2:18 with lines title 'atv[0] [deg/s]'\n";
364 std::cout <<
"## plot using 2:19 with lines title 'atv[1] [deg/s]'\n";
365 std::cout <<
"## plot using 2:20 with lines title 'atv[2] [deg/s]'\n";
366 std::cout <<
"## plot using 2:21 with lines title 'atv[3] [deg/s]'\n";
367 std::cout <<
"## plot using 2:22 with lines title 'atv[4] [deg/s]'\n";
368 std::cout <<
"## plot using 2:23 with lines title 'atv[5] [deg/s]'\n";
369 std::cout <<
"## plot using 2:24 with lines title 'atv[6] [deg/s]'\n";
370 std::cout <<
"## set xlabel 'Time [s]'\n";
371 std::cout <<
"## set ylabel 'Control-Period / Position / Velocity [s] / [deg] / [deg/s]'\n";
372 std::cout <<
"## set grid\n";
373 std::cout <<
"## set title \"demo-benchmark: SDH moving in acceleration + velocity control mode\"\n";
375 std::vector<sRecordedData>::iterator it0 = recorded_data.begin();
376 std::vector<sRecordedData>::iterator it1 = recorded_data.begin();
377 std::cout <<
"# i, t, dt, aaa[0..6], aav[0..6], atv[0..6]\n";
378 std::cout << r <<
", " << it1->t <<
", " << dt <<
", " << it1->aaa <<
", " << it1->aav <<
", " << it1->atv <<
"\n";
379 for ( it1++; it1 < recorded_data.end(); it1++, it0++, r++ )
381 dt = it1->t - it0->t;
393 std::cout << r <<
", " << it1->t <<
", " << dt <<
", " << it1->aaa <<
", " << it1->aav <<
", " << it1->atv <<
"\n";
395 double dt_avg = start_time.
Elapsed( end_time ) / recorded_data.size();
396 std::cout <<
"## set label 'dt_min=" << dt_min <<
"' at " << t_dt_min <<
"," << dt_min <<
" front point\n";
397 std::cout <<
"## set label 'dt_max=" << dt_max <<
"' at " << t_dt_max <<
"," << dt_max <<
" front point\n";
398 std::cout <<
"## set label 'dt_avg=" << dt_avg <<
"' at " << it0->t <<
"," << dt_avg <<
" front point\n";
399 std::cout <<
"## set title \"demo-benchmark.cpp: SDH moving in acceleration + velocity control mode\\ndt_avg = " << dt_avg <<
" fps = " << 1.0/dt_avg;
406 std::cerr <<
"demo-benchmark main(): An exception was caught: " << e->
what() <<
"\n";
std::vector< double > aaa
std::vector< double > aav
void SetAxisTargetVelocity(std::vector< int > const &axes, std::vector< double > const &velocities)
#define DEMO_BENCHMARK_USE_COMBINED_SET_GET
#define USING_NAMESPACE_SDH
Base class for exceptions in the SDHLibrary-CPP.
std::vector< int > all_real_axes
A vector with indices of all real axes (in natural order), excluding the virtual axis.
Very simple class to measure elapsed time.
std::vector< double > GetAxisMinAngle(std::vector< int > const &axes)
@ eCT_VELOCITY_ACCELERATION
velocity controller with acceleration ramp, velocities and accelerations of axes are controlled indep...
void GotoPose(cSDH &hand, std::vector< double > &ta)
double MoveAxis(std::vector< int >const &axes, bool sequ=true)
int main(int argc, char **argv)
double Elapsed(void) const
Return time in seconds elapsed between the time stored in the object and now.
void SetAxisTargetAngle(std::vector< int > const &axes, std::vector< double > const &angles)
std::vector< double > GetAxisActualAngle(std::vector< int > const &axes)
std::vector< double > GetAxisMaxAngle(std::vector< int > const &axes)
Implementation of a class to parse common SDH related command line options.
void SetOutput(std::ostream *fd)
std::vector< double > GetAxisActualVelocity(std::vector< int >const &axes)
void OpenCommunication(NS_SDH cSDH &hand)
static char const * GetLibraryRelease(void)
@ eCT_POSE
coordinated position controller (position per axis => "pose controller"), all axes start and stop mov...
This file contains interface to #SDH::cDSA, a class to communicate with the tactile sensors of the SD...
std::vector< double > GetAxisMaxVelocity(std::vector< int > const &axes)
std::vector< double > SetAxisTargetGetAxisActualVelocity(std::vector< int > const &axes, std::vector< double > const &velocities)
class for command line option parsing holding option parsing results
#SDH::cSDH is the end user interface class to control a SDH (SCHUNK Dexterous Hand).
structure to hold current hand state while recording with demo-benchmark
A class to print colored debug messages.
char const * __copyright__
This file contains some basic definitions (defines, macros, datatypes)
std::vector< double > atv
sRecordedData(double _t, std::vector< double > const &_aaa, std::vector< double > const &_aav, std::vector< double > const &_atv)
double ToRange(double v, double min, double max)
This file contains settings to make the SDHLibrary compile on differen systems:
static char const * GetLibraryName(void)
USING_NAMESPACE_SDH NAMESPACE_SDH_START std::ostream * g_sdh_debug_log
This file contains the interface to class #SDH::cSDH, the end user class to access the SDH from a PC.
void SetAxisTargetAcceleration(std::vector< int >const &axes, std::vector< double >const &accelerations)
virtual const char * what() const
int Parse(int argc, char **argv, char const *helptext, char const *progname, char const *version, char const *libname, char const *librelease)
void SetController(cSDHBase::eControllerType controller)
void Close(bool leave_enabled=false)
Interface of auxilliary utility functions for SDHLibrary-CPP.
#define SDH_ASSERT_TYPESIZES()
macro to assert that the defined typedefs have the expected sizes
@ All
A meta-value that means "access all possible values".
sdhlibrary_cpp
Author(s): Dirk Osswald
autogenerated on Wed Mar 2 2022 01:00:58