ViSP  2.8.0
servoCycabBasic.cpp
1 /****************************************************************************
2  *
3  * $Id: servoCycabBasic.cpp 4056 2013-01-05 13:04:42Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Send a command to the car-like Cycab mobile robot.
36  *
37  * Authors:
38  * Fabien Spindler
39  *
40  *****************************************************************************/
50 #include "visp/vpConfig.h"
51 #include "visp/vpRobotCycab.h"
52 #include "visp/vpMath.h"
53 #include <iostream>
54 #ifdef VISP_HAVE_CYCAB
55 
56 int main()
57 {
58  try {
59  double v = 0.1, phi = vpMath::rad(0);
60  double x, y;
61  double x_min=2000, x_max=0, y_min=2000, y_max=0;
62 
63  vpRobotCycab robot;
64 
65  std::cout << "Send the command v: " << v << " m/s and phi: "
66  << vpMath::deg(phi) << " deg" << std::endl;
67  while (true) {
68 
69  robot.setCommand(v, phi);
70  robot.getJoystickPosition(x, y);
71  //std::cout << "x: " << x << " y: " << y << std::endl;
72  if (x < x_min) x_min = x;
73  if (y < y_min) y_min = y;
74  if (x > x_max) x_max = x;
75  if (y > y_max) y_max = y;
76  std::cout << "x_min: " << x_min << " x_max: " << x_max
77  << " y_min: " << y_min << " y_max: " << y_max
78  << std::endl;
79 
80  usleep(10000);
81  }
82  }
83  catch(...) {
84  std::cerr << "An exception was catched" << std::endl;
85 
86  return 1;
87  }
88 
89  return 0;
90 }
91 
92 #else // VISP_HAVE_CYCAB
93 int main()
94 {
95  std::cout << "Sorry, you don't have access to the Cycab car-like mobile robot."
96  << std::endl;
97 }
98 #endif // VISP_HAVE_CYCAB
99 
Interface for the car-like Cycab mobile robot.
static double rad(double deg)
Definition: vpMath.h:100
static double deg(double rad)
Definition: vpMath.h:93