Testing of basic functionality of hekateros::HekRobot class instance.
More...
|
|
void | dbgPrintTunes (HekTunes &tunes) |
| |
| static int | testHekRobot () |
| | Test HekRobot connected to hekateros. More...
|
| |
| | TEST (HEKROBOT, HEKROBOT) |
| | Test State Machine class. More...
|
| |
Testing of basic functionality of hekateros::HekRobot class instance.
| TEST |
( |
HEKROBOT |
, |
|
|
HEKROBOT |
|
|
) |
| |
Test State Machine class.
- The Test:
- Construct a (2,3) Turing State Machin and run.
Definition at line 443 of file ut-hekrobot.cxx.
References testHekRobot().
static int testHekRobot()
Test HekRobot connected to hekateros.
| static int testHekRobot |
( |
| ) |
|
|
static |
Test HekRobot connected to hekateros.
- Returns
- Returns 0 if test succeeds, else returns < 0.
Handy dandy checker.
Definition at line 140 of file ut-hekrobot.cxx.
References hekateros::degToRad(), and TestMenu.
Referenced by TEST().
145 #define BOT_CHK(conn) \ 146 if( pRobot == NULL ) \ 148 printf("Error: Robot object does not exist - create first.\n"); \ 151 else if( conn && !pRobot->isConnected() ) \ 153 printf("Error: Robot not connected.\n"); \ 157 HekRobot *pRobot = NULL;
171 if( gets(line) == NULL )
176 if( (nArgs = sscanf(line,
" %c %s", &c, arg1)) == EOF )
182 fprintf(stderr,
"#%d ", nArgs);
185 fprintf(stderr,
"c=%c ", c);
189 fprintf(stderr,
"arg1=%s ", arg1);
191 fprintf(stderr,
"\n");
200 pRobot =
new HekRobot;
201 printf(
"Robot created.\n");
205 printf(
"Robot already created.\n");
215 printf(
"Robot deleted.\n");
219 printf(
"Robot not created.\n");
227 string str = nArgs<2?
"/etc/hekateros.conf": arg1;
229 if( xml.loadFile(str) < 0 )
231 printf(
"Error: Loading XML file '%s' failed.\n", str.c_str());
233 else if( xml.setHekDescFromDOM(*pRobot->getHekDesc()) < 0 )
235 printf(
"Error: Setting robot description failed.\n");
237 else if( pRobot->getHekDesc()->markAsDescribed() < 0 )
239 printf(
"Error: Failed to finalize descriptions.\n");
243 printf(
"Robot description complete for %s.\n",
244 pRobot->getHekDesc()->getFullProdBrief().c_str());
253 string str = nArgs<2?
"/etc/hek_tune.conf": arg1;
254 fprintf(stderr,
"rdk here 1\n");
256 fprintf(stderr,
"rdk here 2\n");
258 fprintf(stderr,
"rdk here 3\n");
259 if( xml.loadFile(str) < 0 )
261 printf(
"Error: Loading XML file '%s' failed.\n", str.c_str());
263 else if( xml.setTunesFromDOM(tunes) < 0 )
265 printf(
"Error: Setting robot tune parameters failed.\n");
269 printf(
"Robot tuning complete.\n");
270 dbgPrintTunes(tunes);
279 string str = nArgs<2?
"/dev/ttyUSB0": arg1;
280 if( pRobot->connect(str) < 0 )
282 printf(
"Error: Failed to connnect to '%s'.\n", str.c_str());
286 printf(
"Robot connected.\n");
294 if( pRobot->isConnected() )
296 pRobot->disconnect();
297 printf(
"Robot disconnected.\n");
301 printf(
"Robot not connected.\n");
309 string str = nArgs<2?
"a": arg1;
310 if( (str ==
"s") || (str ==
"sync") )
312 if( pRobot->calibrate() < 0 )
314 printf(
"Error: Calibration failed.\n");
318 printf(
"Robot calibrated.\n");
323 if( pRobot->calibrateAsync() < 0 )
325 printf(
"Error: Async calibration failed.\n");
329 printf(
"Calibrating robot - enter '9' to cancel.\n");
338 if( !pRobot->isCalibrated() )
340 printf(
"Error: Robot not calibrated.\n");
344 printf(
"Error: Missing <move> argument.\n");
346 else if( strlen(arg1) < 2 )
348 printf(
"Error: \"%s\": Ambiguous <move>.\n", arg1);
350 else if( !strncmp(arg1,
"calibrated", strlen(arg1)) )
352 pRobot->gotoZeroPtPos();
354 else if( !strncmp(arg1,
"balanced", strlen(arg1)) )
356 pRobot->gotoBalancedPos();
358 else if( !strncmp(arg1,
"park", strlen(arg1)) )
360 pRobot->gotoParkedPos();
362 else if( !strncmp(arg1,
"gopen", strlen(arg1)) )
364 pRobot->openGripper();
366 else if( !strncmp(arg1,
"gclose", strlen(arg1)) )
368 pRobot->closeGripper();
372 printf(
"Error: \"%s\": Unknown <move>.\n", arg1);
379 if( !pRobot->isCalibrated() )
381 printf(
"Error: Robot not calibrated.\n");
385 printf(
"Error: Missing <deg> argument.\n");
387 else if( sscanf(arg1,
"%lf", &fVal) < 1 )
389 printf(
"Error: \"%s\": NaN.\n", arg1);
393 HekJointTrajectoryPoint trajPoint;
394 trajPoint.append(
string(
"wrist_rot"),
degToRad(fVal), 5.0);
395 pRobot->moveArm(trajPoint);
402 pRobot->cancelAsyncTask();
406 LOG_SET_THRESHOLD(LOG_LEVEL_DIAG3);
421 printf(
"'%c': huh?\n", c);
double degToRad(double d)
Convert degrees to radians.
static const char * TestMenu
Test menu.
Initial value:=
"\nTest Menu\n"
" 1 Create robot.\n"
" 2 Delete robot.\n"
" 3 [<file>] Read xml cfg <file>. DEFAULT: /etc/hekateros.conf\n"
" 4 [<file>] Read xml tune <file>. DEFAULT: /etc/hek_tune.conf\n"
" 5 [<dev>] Connect to dynamixel bus <dev>. DEFAULT: /dev/ttyUSB0\n"
" 6 Disconnect from dynamixel bus.\n"
" 7 <how> [A]synchronously calibrate arm. <how> is 'a' or 's'. "
"DEFAULT: a\n"
" 8 <move> Execute pre-defined move: calibrated balanced parked "
" 9 <deg> Rotate wrist by the given degrees."
" a Cancel asynchronous task."
"gopen gclose.\n"
"\n"
" d Enable library diagnostics logging.\n"
" ? Show this menu.\n"
" q Quit unit test.\n\n"
Test menu.
Definition at line 82 of file ut-hekrobot.cxx.
Referenced by testHekRobot().