ypspur-interpreter.c
Go to the documentation of this file.
1 // Copyright (c) 2010-2016 The YP-Spur Authors, except where otherwise indicated.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <signal.h>
25 #include <setjmp.h>
26 #include <unistd.h>
27 #include <getopt.h>
28 
29 #ifdef HAVE_CONFIG_H
30 #include <config.h>
31 #endif // HAVE_CONFIG_H
32 
33 #if HAVE_LIBREADLINE
34 #include <readline/readline.h>
35 #include <readline/history.h>
36 #endif // HAVE_LIBREADLINE
37 
38 #include <ypspur.h>
39 #include <utility.h>
40 
41 typedef struct SPUR_COMMAND
42 {
43  enum
44  {
45  SPUR_NONE = -1,
100  } id;
101  char name[64];
102  int reqarg;
103  int narg;
104  double arg[3];
105 } SpurCommand;
106 
108  { SPUR_LINE, { "line" }, 3 },
109  { SPUR_STOP_LINE, { "stop_line" }, 3 },
110  { SPUR_CIRCLE, { "circle" }, 3 },
111  { SPUR_SPIN, { "spin" }, 1 },
112  { SPUR_GETPOS, { "get_pos" }, 0 },
113  { SPUR_GETVEL, { "get_vel" }, 0 },
114  { SPUR_GETFORCE, { "get_force" }, 0 },
115  { SPUR_SETPOS, { "set_pos" }, 3 },
116  { SPUR_NEAR_POS, { "near_pos" }, 3 },
117  { SPUR_NEAR_ANG, { "near_ang" }, 2 },
118  { SPUR_OVER_LINE, { "over_line" }, 3 },
119  { SPUR_ADJUSTPOS, { "adjust_pos" }, 3 },
120  { SPUR_SETVEL, { "set_vel" }, 1 },
121  { SPUR_SETANGVEL, { "set_angvel" }, 1 },
122  { SPUR_SETACCEL, { "set_accel" }, 1 },
123  { SPUR_SETANGACCEL, { "set_angaccel" }, 1 },
124  { SPUR_FREE, { "free" }, 0 },
125  { SPUR_OPENFREE, { "openfree" }, 0 },
126  { SPUR_STOP, { "stop" }, 0 },
127  { SPUR_INIT, { "init" }, 0 },
128  { SPUR_FREEZE, { "freeze" }, 0 },
129  { SPUR_UNFREEZE, { "unfreeze" }, 0 },
130  { SPUR_ISFREEZE, { "isfreeze" }, 0 },
131  { SPUR_GETAD, { "get_ad_value" }, 1 },
132  { SPUR_SET_IO_DIR, { "set_io_dir" }, 1 },
133  { SPUR_SET_IO_DATA, { "set_io_data" }, 1 },
134  { SPUR_GET_DEVICE_ERROR_STATE, { "get_device_error_state" }, 1 },
135  { SPUR_VEL, { "vel" }, 2 },
136  { SPUR_WHEEL_VEL, { "wheel_vel" }, 2 },
137  { SPUR_GET_WHEEL_VEL, { "get_wheel_vel" }, 0 },
138  { SPUR_GET_WHEEL_ANG, { "get_wheel_ang" }, 0 },
139  { SPUR_GET_WHEEL_TORQUE, { "get_wheel_torque" }, 0 },
140  { SPUR_WHEEL_TORQUE, { "wheel_torque" }, 2 },
141  { SPUR_ORIENT, { "orient" }, 1 },
142  { SPUR_GET_VREF, { "get_vref" }, 0 },
143  { SPUR_GET_WHEEL_VREF, { "get_wheel_vref" }, 0 },
144  { SPUR_SET_WHEEL_VEL, { "set_wheel_vel" }, 2 },
145  { SPUR_SET_WHEEL_ACCEL, { "set_wheel_accel" }, 2 },
146  { SPUR_WHEEL_ANG, { "wheel_ang" }, 2 },
147  { SPUR_JOINT_TORQUE, { "joint_torque" }, 2 },
148  { SPUR_JOINT_VEL, { "joint_vel" }, 2 },
149  { SPUR_JOINT_ANG, { "joint_ang" }, 2 },
150  { SPUR_JOINT_ANG_VEL, { "joint_ang_vel" }, 3 },
151  { SPUR_SET_JOINT_ACCEL, { "set_joint_accel" }, 2 },
152  { SPUR_SET_JOINT_VEL, { "set_joint_vel" }, 2 },
153  { SPUR_GET_JOINT_VEL, { "get_joint_vel" }, 1 },
154  { SPUR_GET_JOINT_VREF, { "get_joint_vref" }, 1 },
155  { SPUR_GET_JOINT_ANG, { "get_joint_ang" }, 1 },
156  { SPUR_GET_JOINT_TORQUE, { "get_joint_torque" }, 1 },
157  { SPUR_SLEEP, { "sleep" }, 1 },
158  { SPUR_REQUEST_DEVICE_DUMP, { "request_device_dump" }, 2 },
159  { HELP, { "help" }, 0 },
160  { EXIT, { "exit" }, 0 }
161 };
162 
163 #if HAVE_SIGLONGJMP
164 sigjmp_buf ctrlc_capture;
165 #endif // HAVE_SIGLONGJMP
166 
167 void ctrlc(int num)
168 {
169  printf("\n");
170 #if HAVE_SIGLONGJMP
171  siglongjmp(ctrlc_capture, 1);
172 #endif // HAVE_SIGLONGJMP
173 }
174 
175 int proc_spur_cmd(char *line, int *coordinate)
176 {
177  int i;
179  int lcoordinate;
180  char *argv;
181  int ret;
182  int ad;
183  int error;
184  enum
185  {
186  MODE_COMMAND,
187  MODE_ARG
188  } mode = MODE_COMMAND;
189  char *toksave;
190 
191  spur.id = -1;
192  lcoordinate = *coordinate;
193 
194  argv = strtok_r(line, " >\t\n\r", &toksave);
195  if (!argv)
196  {
197  return 0;
198  }
199 
200  while (argv)
201  {
202  switch (mode)
203  {
204  case MODE_COMMAND:
205  for (i = 0; i < CS_MAX; i++)
206  {
207  if (strcmp(argv, YPSpur_CSName[i]) == 0)
208  {
209  lcoordinate = i;
210  break;
211  }
212  }
213  if (i != CS_MAX)
214  {
215  break;
216  }
217  for (i = 0; i < SPUR_COMMAND_MAX; i++)
218  {
219  if (strcmp(argv, SPUR_COMMAND[i].name) == 0)
220  {
221  spur = SPUR_COMMAND[i];
222  break;
223  }
224  }
225  mode = MODE_ARG;
226  break;
227  default:
228  spur.arg[mode - MODE_ARG] = atof(argv);
229  mode++;
230  spur.narg = mode - MODE_ARG;
231  if (mode > MODE_ARG + 3)
232  break;
233  break;
234  }
235  argv = strtok_r(NULL, " >\t\n\r", &toksave);
236  }
237 
238  if (spur.id < 0)
239  {
240  *coordinate = lcoordinate;
241  return 1;
242  }
243 
244  if (spur.narg < spur.reqarg)
245  {
246  fprintf(stderr, "error: too few arguments to %s\n", spur.name);
247  fflush(stderr);
248  return 0;
249  }
250 
251  switch (spur.id)
252  {
253  case SPUR_LINE:
254  YPSpur_line(lcoordinate, spur.arg[0], spur.arg[1], spur.arg[2]);
255  break;
256  case SPUR_STOP_LINE:
257  YPSpur_stop_line(lcoordinate, spur.arg[0], spur.arg[1], spur.arg[2]);
258  break;
259  case SPUR_CIRCLE:
260  YPSpur_circle(lcoordinate, spur.arg[0], spur.arg[1], spur.arg[2]);
261  break;
262  case SPUR_ORIENT:
263  YPSpur_orient(lcoordinate, spur.arg[0]);
264  break;
265  case SPUR_SPIN:
266  YPSpur_spin(lcoordinate, spur.arg[0]);
267  break;
268  case SPUR_GETPOS:
269  YPSpur_get_pos(lcoordinate, &spur.arg[0], &spur.arg[1], &spur.arg[2]);
270  printf("%f %f %f\n", spur.arg[0], spur.arg[1], spur.arg[2]);
271  break;
272  case SPUR_GETVEL:
273  YPSpur_get_vel(&spur.arg[0], &spur.arg[1]);
274  printf("%f %f\n", spur.arg[0], spur.arg[1]);
275  break;
276  case SPUR_GETFORCE:
277  YPSpur_get_force(&spur.arg[0], &spur.arg[1]);
278  printf("%f %f\n", spur.arg[0], spur.arg[1]);
279  break;
281  YP_get_wheel_torque(&spur.arg[0], &spur.arg[1]);
282  printf("%f %f\n", spur.arg[0], spur.arg[1]);
283  break;
284  case SPUR_GET_VREF:
285  YP_get_vref(&spur.arg[0], &spur.arg[1]);
286  printf("%f %f\n", spur.arg[0], spur.arg[1]);
287  break;
288  case SPUR_GET_WHEEL_VREF:
289  YP_get_wheel_vref(&spur.arg[0], &spur.arg[1]);
290  printf("%f %f\n", spur.arg[0], spur.arg[1]);
291  break;
292  case SPUR_SETPOS:
293  YPSpur_set_pos(lcoordinate, spur.arg[0], spur.arg[1], spur.arg[2]);
294  break;
295  case SPUR_NEAR_POS:
296  ret = YPSpur_near_pos(lcoordinate, spur.arg[0], spur.arg[1], spur.arg[2]);
297  printf("%d\n", ret);
298  break;
299  case SPUR_NEAR_ANG:
300  ret = YPSpur_near_ang(lcoordinate, spur.arg[0], spur.arg[1]);
301  printf("%d\n", ret);
302  break;
303  case SPUR_OVER_LINE:
304  ret = YPSpur_over_line(lcoordinate, spur.arg[0], spur.arg[1], spur.arg[2]);
305  printf("%d\n", ret);
306  break;
307  case SPUR_ADJUSTPOS:
308  YPSpur_adjust_pos(lcoordinate, spur.arg[0], spur.arg[1], spur.arg[2]);
309  break;
310  case SPUR_SETVEL:
311  YPSpur_set_vel(spur.arg[0]);
312  break;
313  case SPUR_SETANGVEL:
314  YPSpur_set_angvel(spur.arg[0]);
315  break;
316  case SPUR_SETACCEL:
317  YPSpur_set_accel(spur.arg[0]);
318  break;
319  case SPUR_SETANGACCEL:
320  YPSpur_set_angaccel(spur.arg[0]);
321  break;
322  case SPUR_STOP:
323  YPSpur_stop();
324  break;
325  case SPUR_INIT:
326  break;
327  case SPUR_FREE:
328  YPSpur_free();
329  break;
330  case SPUR_OPENFREE:
331  YP_openfree();
332  break;
333  case SPUR_FREEZE:
334  YPSpur_freeze();
335  break;
336  case SPUR_UNFREEZE:
337  YPSpur_unfreeze();
338  break;
339  case SPUR_ISFREEZE:
340  ret = YPSpur_isfreeze();
341  printf("%d\n", ret);
342  break;
343  case SPUR_GETAD:
344  ad = YP_get_ad_value((int)spur.arg[0]);
345  printf("%d\n", ad);
346  break;
347  case SPUR_SET_IO_DIR:
348  YP_set_io_dir((int)spur.arg[0]);
349  break;
350  case SPUR_SET_IO_DATA:
351  YP_set_io_data((int)spur.arg[0]);
352  break;
354  YP_get_device_error_state((int)spur.arg[0], &error);
355  printf("%d\n", error);
356  break;
357  case SPUR_VEL:
358  YPSpur_vel(spur.arg[0], spur.arg[1]);
359  break;
360  case SPUR_WHEEL_VEL:
361  YP_wheel_vel(spur.arg[0], spur.arg[1]);
362  break;
363  case SPUR_WHEEL_TORQUE:
364  YP_wheel_torque(spur.arg[0], spur.arg[1]);
365  break;
366  case SPUR_GET_WHEEL_VEL:
367  YP_get_wheel_vel(&spur.arg[0], &spur.arg[1]);
368  printf("%f %f\n", spur.arg[0], spur.arg[1]);
369  break;
370  case SPUR_GET_WHEEL_ANG:
371  YP_get_wheel_ang(&spur.arg[0], &spur.arg[1]);
372  printf("%f %f\n", spur.arg[0], spur.arg[1]);
373  break;
374  case SPUR_SET_WHEEL_VEL:
375  YP_set_wheel_vel(spur.arg[0], spur.arg[1]);
376  break;
378  YP_set_wheel_accel(spur.arg[0], spur.arg[1]);
379  break;
380  case SPUR_WHEEL_ANG:
381  YP_wheel_ang(spur.arg[0], spur.arg[1]);
382  break;
383  case SPUR_JOINT_TORQUE:
384  YP_joint_torque((int)spur.arg[0], spur.arg[1]);
385  break;
386  case SPUR_JOINT_VEL:
387  YP_joint_vel((int)spur.arg[0], spur.arg[1]);
388  break;
389  case SPUR_JOINT_ANG:
390  YP_joint_ang((int)spur.arg[0], spur.arg[1]);
391  break;
392  case SPUR_JOINT_ANG_VEL:
393  YP_joint_ang_vel((int)spur.arg[0], spur.arg[1], spur.arg[2]);
394  break;
396  YP_set_joint_accel((int)spur.arg[0], spur.arg[1]);
397  break;
398  case SPUR_SET_JOINT_VEL:
399  YP_set_joint_vel((int)spur.arg[0], spur.arg[1]);
400  break;
401  case SPUR_GET_JOINT_VEL:
402  YP_get_joint_vel((int)spur.arg[0], &spur.arg[1]);
403  printf("%f\n", spur.arg[1]);
404  break;
405  case SPUR_GET_JOINT_VREF:
406  YP_get_joint_vref((int)spur.arg[0], &spur.arg[1]);
407  printf("%f\n", spur.arg[1]);
408  break;
409  case SPUR_GET_JOINT_ANG:
410  YP_get_joint_ang((int)spur.arg[0], &spur.arg[1]);
411  printf("%f\n", spur.arg[1]);
412  break;
414  YP_get_joint_torque((int)spur.arg[0], &spur.arg[1]);
415  printf("%f\n", spur.arg[1]);
416  break;
417  case SPUR_SLEEP:
418  yp_usleep((int)(spur.arg[0] * 1000.0 * 1000.0));
419  break;
421  YP_request_device_dump((int)spur.arg[0], (int)spur.arg[1]);
422  break;
423  case HELP:
424  printf("Usage:\n");
425  printf(" > command arg1 arg2 arg3\n");
426  printf(" > coordinate\n");
427  printf(" > coordinate command arg1 arg2 arg3\n");
428  printf(" > coordinate> command arg1 arg2 arg3\n");
429  printf("Commands:\n");
430  for (i = 0; i < SPUR_COMMAND_MAX; i++)
431  {
432  printf(" %s\n", SPUR_COMMAND[i].name);
433  }
434  printf("Coordinates:\n");
435  for (i = 0; i < CS_MAX + 1; i++)
436  {
437  printf(" %s\n", YPSpur_CSName[i]);
438  }
439  break;
440  case EXIT:
441  return -1;
442  break;
443  default:
444  printf("unknown command\n");
445  }
446  fflush(stdout);
447 
448  return 1;
449 }
450 
451 int proc_spur(char *line, int *coordinate)
452 {
453  char *line_div;
454  char *toksave;
455  int ret;
456 
457  ret = 0;
458  line_div = strtok_r(line, ";\n\r", &toksave);
459  while (line_div)
460  {
461  ret = proc_spur_cmd(line_div, coordinate);
462  if (ret < 0)
463  {
464  break;
465  }
466  line_div = strtok_r(NULL, ";\n\r", &toksave);
467  }
468  return ret;
469 }
470 
471 void print_help(char *argv[])
472 {
473  fprintf(stderr, "USAGE: %s\n", argv[0]);
474  fputs("\t-V | --set-vel VALUE : [m/s] set max vel of SPUR to VALUE\n", stderr);
475  fputs("\t-W | --set-angvel VALUE : [rad/s] set max angvel of SPUR to VALUE\n", stderr);
476  fputs("\t-A | --set-accel VALUE : [m/ss] set accel of SPUR to VALUE\n", stderr);
477  fputs("\t-O | --set-angaccel VALUE : [rad/ss] set angaccel of SPUR to VALUE\n", stderr);
478  fputs("\t-c | --command \"VALUE\" : execute command VALUE\n", stderr);
479  fputs("\t-q | --msq-id VALUE : set message-queue id\n", stderr);
480  fputs("\t-s | --socket IP:PORT : use socket ipc\n", stderr);
481  fputs("\t-h | --help : print this help\n", stderr);
482 }
483 
484 int main(int argc, char *argv[])
485 {
486  int coordinate = CS_FS;
487  char ip[64];
488  int port = 0;
489  int active = 1;
490  int err = 0;
491  double vel = 0;
492  double angvel = 0;
493  double accel = 0;
494  double angaccel = 0;
495  int set_vel = 0;
496  int set_accel = 0;
497  int set_angvel = 0;
498  int set_angaccel = 0;
499  int msqid = 0;
500  struct option options[9] =
501  {
502  { "set-vel", 1, 0, 'V' },
503  { "set-angvel", 1, 0, 'W' },
504  { "set-accel", 1, 0, 'A' },
505  { "set-angaccel", 1, 0, 'O' },
506  { "command", 1, 0, 'c' },
507  { "msq-id", 1, 0, 'q' },
508  { "socket", 1, 0, 's' },
509  { "help", 0, 0, 'h' },
510  { 0, 0, 0, 0 }
511  };
512  int opt;
513 
514  hook_pre_global();
515 
516  while ((opt = getopt_long(argc, argv, "V:W:A:O:c:q:s:h", options, NULL)) != -1)
517  {
518  switch (opt)
519  {
520  case 'V':
521  vel = atof(optarg);
522  set_vel = 1;
523  break;
524  case 'W':
525  angvel = atof(optarg);
526  set_angvel = 1;
527  break;
528  case 'A':
529  accel = atof(optarg);
530  set_accel = 1;
531  break;
532  case 'O':
533  angaccel = atof(optarg);
534  set_angaccel = 1;
535  break;
536  case 'c':
537  if (msqid == -1)
538  YPSpur_init_socket(ip, port);
539  else if (msqid == 0)
540  YPSpur_init();
541  else
542  YPSpur_initex(msqid);
543  proc_spur(optarg, &coordinate);
544  return 1;
545  break;
546  case 'q':
547  msqid = atoi(optarg);
548  break;
549  case 's':
550  strncpy(ip, optarg, 64);
551  {
552  char *p;
553  p = strchr(ip, ':');
554  if (p == NULL)
555  {
556  fprintf(stderr, "USAGE: %s -s ip:port\n", argv[0]);
557  return -1;
558  }
559  *p = 0;
560  port = atoi(p + 1);
561  msqid = -1;
562  }
563  break;
564  case 'h':
565  print_help(argv);
566  return 1;
567  break;
568  default:
569  break;
570  }
571  }
572 
573 #if HAVE_SIGLONGJMP
574  signal(SIGINT, ctrlc);
575 #endif // HAVE_SIGLONGJMP
576 
577  if (msqid == -1)
578  YPSpur_init_socket(ip, port);
579  else if (msqid == 0)
580  YPSpur_init();
581  else
582  YPSpur_initex(msqid);
583 
584  if (set_vel)
585  YPSpur_set_vel(vel);
586  if (set_angvel)
587  YPSpur_set_angvel(angvel);
588  if (set_accel)
589  YPSpur_set_accel(accel);
590  if (set_angaccel)
591  YPSpur_set_angaccel(angaccel);
592 
593 #if HAVE_LIBREADLINE
594  using_history();
595  read_history(".spurip_history");
596 #endif // HAVE_LIBREADLINE
597  while (active)
598  {
599  static char *line = NULL;
600  static char *line_prev = NULL;
601  char text[16];
602 #if !HAVE_LIBREADLINE
603 #if HAVE_GETLINE
604  size_t len;
605 #endif // HAVE_GETLINE
606 #endif // !HAVE_LIBREADLINE
607 #if HAVE_SIGLONGJMP
608  if (sigsetjmp(ctrlc_capture, 1) != 0)
609  {
610 #if HAVE_LIBREADLINE
611  write_history(".spurip_history");
612 #endif // HAVE_LIBREADLINE
613  }
614  else
615 #endif // HAVE_SIGLONGJMP
616  {
617  {
618  // Dummy for error checking
619  double x, y, th;
620  YPSpur_get_pos(CS_GL, &x, &y, &th);
621  }
622  if (YP_get_error_state())
623  {
624  if (msqid == -1)
625  YPSpur_init_socket(ip, port);
626  else if (msqid == 0)
627  YPSpur_init();
628  else
629  YPSpur_initex(msqid);
630  if (set_vel)
631  YPSpur_set_vel(vel);
632  if (set_angvel)
633  YPSpur_set_angvel(angvel);
634  if (set_accel)
635  YPSpur_set_accel(accel);
636  if (set_angaccel)
637  YPSpur_set_angaccel(angaccel);
638  if (err == 0)
639  {
640  fprintf(stderr, "WARN: YPSpur-coordinator terminated.\n");
641  fflush(stderr);
642 #if HAVE_SIGLONGJMP
643  signal(SIGINT, NULL);
644 #endif // HAVE_SIGLONGJMP
645  }
646  err = 1;
647  yp_usleep(50000);
648  continue;
649  }
650  else
651  {
652  if (err == 1)
653  {
654  fprintf(stderr, "INFO: YPSpur-coordinator started.\n");
655  fflush(stderr);
656 #if HAVE_SIGLONGJMP
657  signal(SIGINT, ctrlc);
658 #endif // HAVE_SIGLONGJMP
659  }
660  }
661  err = 0;
662 
663  snprintf(text, sizeof(text), "%s> ", YPSpur_CSName[coordinate]);
664 #if HAVE_LIBREADLINE
665  line_prev = line;
666  line = readline(text);
667  if (!line)
668  {
669  // EOF
670  break;
671  }
672  if (strlen(line) > 0)
673  {
674  if (line && line_prev)
675  {
676  if (strcmp(line, line_prev) != 0)
677  {
678  add_history(line);
679  }
680  }
681  else
682  {
683  add_history(line);
684  }
685  }
686 #else
687  printf("%s", text);
688  fflush(stdout);
689  line = NULL;
690 #if HAVE_GETLINE
691  len = 0;
692  getline(&line, &len, stdin);
693  if (len == 0)
694  continue;
695 #else
696  line = malloc(512);
697  fgets(line, 512, stdin);
698 #endif // HAVE_GETLINE
699  line_prev = line;
700 #endif // HAVE_LIBREADLINE
701  if (proc_spur(line, &coordinate) < 0)
702  {
703  active = 0;
704  }
705 
706  if (line_prev)
707  free(line_prev);
708  }
709  }
710  printf("\n");
711 #if HAVE_LIBREADLINE
712  write_history(".spurip_history");
713 #endif // HAVE_LIBREADLINE
714 
715  return 0;
716 }
int proc_spur_cmd(char *line, int *coordinate)
double YP_get_wheel_vref(double *wrref, double *wlref)
Definition: libypspur.c:187
double YPSpur_get_force(double *trans, double *angular)
Definition: libypspur.c:211
void print_help(char *argv[])
void yp_usleep(int usec)
Definition: utility.c:54
int YPSpur_over_line(int cs, double x, double y, double theta)
Definition: libypspur.c:277
double YP_get_joint_vref(int id, double *v)
Definition: libypspur.c:359
int YPSpur_initex(int msq_key)
Definition: libypspur.c:56
int YPSpur_near_ang(int cs, double th, double d)
Definition: libypspur.c:271
int YPSpur_unfreeze(void)
Definition: libypspur.c:115
int proc_spur(char *line, int *coordinate)
int YPSpur_near_pos(int cs, double x, double y, double r)
Definition: libypspur.c:265
int YP_set_io_data(unsigned char data)
Definition: libypspur.c:293
int YP_get_ad_value(int num)
Definition: libypspur.c:283
double YP_get_joint_ang(int id, double *a)
Definition: libypspur.c:364
double p(YPSpur_param id, enum motor_id motor)
Definition: param.c:79
int YPSpur_vel(double v, double w)
Definition: libypspur.c:223
double YPSpur_get_vel(double *v, double *w)
Definition: libypspur.c:175
Definition: ypparam.h:492
char * strtok_r(char *str, const char *delim, char **nextp)
Definition: utility.c:91
int YPSpur_set_pos(int cs, double x, double y, double theta)
Definition: libypspur.c:133
int YP_joint_ang_vel(int id, double a, double v)
Definition: libypspur.c:339
int YP_wheel_ang(double r, double l)
Definition: libypspur.c:319
int YPSpur_set_angaccel(double w)
Definition: libypspur.c:163
enum SPUR_COMMAND::@2 id
double YPSpur_get_pos(int cs, double *x, double *y, double *theta)
Definition: libypspur.c:169
int YP_wheel_vel(double r, double l)
Definition: libypspur.c:299
int YP_openfree(void)
Definition: libypspur.c:127
void hook_pre_global(void)
Definition: utility.c:73
static YPSpur spur
Definition: libypspur.c:42
int YP_set_io_dir(unsigned char dir)
Definition: libypspur.c:288
int ad[16]
Definition: adinput.c:48
int YPSpur_freeze(void)
Definition: libypspur.c:109
int YPSpur_circle(int cs, double x, double y, double r)
Definition: libypspur.c:85
double YP_get_joint_torque(int id, double *t)
Definition: libypspur.c:369
void ctrlc(int num)
double YP_get_device_error_state(int id, int *err)
Definition: libypspur.c:50
Definition: ypparam.h:494
static const char YPSpur_CSName[CS_MAX][16]
Definition: ypparam.h:499
int YPSpur_isfreeze(void)
Definition: libypspur.c:217
int YP_set_wheel_vel(double r, double l)
Definition: libypspur.c:309
int YP_joint_ang(int id, double a)
Definition: libypspur.c:334
int YPSpur_spin(int cs, double theta)
Definition: libypspur.c:91
int YPSpur_set_angvel(double w)
Definition: libypspur.c:151
int YP_joint_torque(int id, double t)
Definition: libypspur.c:324
int YPSpur_line(int cs, double x, double y, double theta)
Definition: libypspur.c:73
struct SPUR_COMMAND SpurCommand
int YPSpur_free(void)
Definition: libypspur.c:121
int YPSpur_init_socket(char *ip, int port)
Definition: libypspur.c:61
int YPSpur_stop(void)
Definition: libypspur.c:103
int YPSpur_set_vel(double v)
Definition: libypspur.c:145
int YPSpur_set_accel(double v)
Definition: libypspur.c:157
double YP_get_wheel_vel(double *wr, double *wl)
Definition: libypspur.c:193
int YP_set_joint_vel(int id, double v)
Definition: libypspur.c:349
int option(ParamOptions option)
Definition: param.c:99
int YPSpur_stop_line(int cs, double x, double y, double theta)
Definition: libypspur.c:79
int YP_get_error_state(void)
Definition: libypspur.c:45
int YP_joint_vel(int id, double v)
Definition: libypspur.c:329
double YP_get_wheel_torque(double *torque_r, double *torque_l)
Definition: libypspur.c:205
void YP_request_device_dump(int id, int block)
Definition: libypspur.c:374
int YPSpur_init(void)
Definition: libypspur.c:67
int YPSpur_adjust_pos(int cs, double x, double y, double theta)
Definition: libypspur.c:139
int YP_set_wheel_accel(double r, double l)
Definition: libypspur.c:314
double YP_get_vref(double *vref, double *wref)
Definition: libypspur.c:181
double YP_get_joint_vel(int id, double *v)
Definition: libypspur.c:354
int main(int argc, char *argv[])
int YPSpur_orient(int cs, double theta)
Definition: libypspur.c:97
int YP_wheel_torque(double r, double l)
Definition: libypspur.c:304
double YP_get_wheel_ang(double *theta_r, double *theta_l)
Definition: libypspur.c:199
int YP_set_joint_accel(int id, double a)
Definition: libypspur.c:344


yp-spur
Author(s):
autogenerated on Fri May 7 2021 02:12:17