All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

circle.cc 1.17 KB
Newer Older
Timothy Stack's avatar
Timothy Stack committed
1 2 3 4 5 6
/*
 * EMULAB-COPYRIGHT
 * Copyright (c) 2005 University of Utah and the Flux Group.
 * All rights reserved.
 */

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
/* circle: garcia robot simple circle path
 * (Tests grobot::setvPath(float, float))
 *
 * Dan Flickinger
 *
 * 2004/11/10
 * 2004/11/11
 */
 
#include "dgrobot/commotion.h"

int main(int argc, char **argv)
{
  
  // terminal setup
  struct termios old_mode;
  struct termios new_mode;

  tcgetattr(fileno(stdout),&old_mode);
  
  new_mode = old_mode;
  new_mode.c_lflag &= ~(ECHOKE | ECHOK | ECHOE | ECHO);
  new_mode.c_lflag &= ~(ICANON);
  
  tcsetattr(fileno(stdout),TCSANOW,&new_mode);
  
  setbuf(stdin,(char*)NULL);
  char keypress = '~';
  
  int status = 0;
  grobot robot1;
  
  robot1.setvPath(0.2f, 0.5f);
  robot1.sleepy();
  cout << "Set path to 1.0 m diameter circle at 0.2 m/s" << endl;
  
  do {
    robot1.sleepy();
    fread(&keypress, sizeof(char), 1, stdin);
  
    status = robot1.getGstatus();
  } while ((keypress == '~') && (status == 0));
  
  robot1.sleepy();
  cout << "Garcia status: " << status << endl;
  
  cout << "Setting wheels to zero" << endl;
  robot1.setWheels(0.0f, 0.0f);
  cout << "DONE..." << endl;
  
  robot1.sleepy();
  
  
  return 0;
}