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.

gorobotc.cc 1.33 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.
 */

Daniel Flickinger's avatar
Daniel Flickinger committed
7 8 9 10 11 12 13
/* gorobotc.cc
 *
 * Console application to drive robot using grobot::goto()
 *
 * Dan Flickinger
 *
 * 2004/12/08
Timothy Stack's avatar
Timothy Stack committed
14
 * 2004/12/09
Daniel Flickinger's avatar
Daniel Flickinger committed
15 16 17 18 19 20 21 22 23
 */

 
#include "dgrobot/commotion.h"


int main() {

  float dx, dy, dr;
Timothy Stack's avatar
Timothy Stack committed
24
  float dxe, dye;
Daniel Flickinger's avatar
Daniel Flickinger committed
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
  
  int quitnow = 0;
  int gstatus = 0;
  
  grobot mrrobot;
  
  
  while (quitnow == 0) {
    
    std::cout << "? " << std::flush;
    std::cin >> dx >> dy >> dr;
    
    if ((float)(dx) == 0.0f && (float)(dy) == 0.0f) {
      if ((float)(dr) == 0.0f) {
        // send an estop
        std::cout << "ESTOP" << std::endl;
        mrrobot.estop();
      } else {
        std::cout << "Quiting..." << std::endl;
        quitnow = 1;
      }
    } else {
      mrrobot.dgoto((float)(dx), (float)(dy), (float)(dr));
    
    
      // wait for moves to complete
      while (!mrrobot.garcia.getNamedValue("idle")->getBoolVal()) {
        mrrobot.sleepy();
      }
    
      // get the status
      gstatus = mrrobot.getGOTOstatus();
Timothy Stack's avatar
Timothy Stack committed
57
      mrrobot.getDisplacement(dxe, dye);
Daniel Flickinger's avatar
Daniel Flickinger committed
58 59 60 61
      
      std::cout << "Goto move finished with status: " << gstatus
                << std::endl
                << "(Estimated position: " << dxe << ", "
Timothy Stack's avatar
Timothy Stack committed
62
                << dye << ".)" << std::endl;
Daniel Flickinger's avatar
Daniel Flickinger committed
63 64 65 66 67 68 69 70
      
      
      
    }
  }
 
  return 0; 
}