您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

58 行
1.5KB

  1. #include <assert.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <unistd.h>
  6. #include <math.h>
  7. #include "linalg.h"
  8. #include "licks_message.h"
  9. licks_message message;
  10. int
  11. main(int argc, char **argv) {
  12. if(argc==1) {
  13. printf("%s <command> <args...>\n",argv[0]);
  14. exit(0);
  15. }
  16. if(!strcmp(argv[1],"power")) {
  17. if(argc!=3) {
  18. printf("%s power {1|0}\n",argv[0]);
  19. exit(0);
  20. };
  21. message.type=MSG_POWER;
  22. message.i=atoi(argv[2]);
  23. } else if(!strcmp(argv[1],"quit")) {
  24. message.type=MSG_QUIT;
  25. } else if(!strcmp(argv[1],"move")) {
  26. if(argc!=6) {
  27. printf("%s move x y z duration \n",argv[0]);
  28. exit(0);
  29. };
  30. message.type=MSG_MOVE_BODY;
  31. message.move_parameters.v.x=atoi(argv[2]);
  32. message.move_parameters.v.y=atoi(argv[3]);
  33. message.move_parameters.v.z=atoi(argv[4]);
  34. message.move_parameters.duration=atoi(argv[5]);
  35. } else if(!strcmp(argv[1],"walk")) {
  36. if(argc!=7) {
  37. printf("%s walk x y a h d\n",argv[0]);
  38. exit(0);
  39. };
  40. message.type=MSG_WALK;
  41. message.walk_parameters.step_direction.x=atoi(argv[2]);
  42. message.walk_parameters.step_direction.y=atoi(argv[3]);
  43. message.walk_parameters.step_rotation=(M_PI/1800.0)*atoi(argv[4]);
  44. message.walk_parameters.step_height=atoi(argv[5]);
  45. message.walk_parameters.step_duration=atoi(argv[6]);
  46. }
  47. licks_socket_open("/tmp/ikcontrol");
  48. send_message(&message,ikd_path);
  49. licks_socket_close();
  50. return 0;
  51. }