ViSP  2.9.0
movePtu46.cpp
1 /****************************************************************************
2  *
3  * $Id: movePtu46.cpp 4604 2014-01-21 14:15:23Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 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  * Tests the control law
36  *
37  * Authors:
38  * Fabien Spindler
39  *
40  *****************************************************************************/
57 #include <visp/vpConfig.h>
58 #include <visp/vpDebug.h>
59 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
60 # include <unistd.h>
61 #endif
62 
63 
64 
65 #ifdef VISP_HAVE_PTU46
66 
67 #include <visp/vpRobotPtu46.h>
68 
69 int
70 main()
71 {
72  try
73  {
74  vpRobotPtu46 robot ;
75  vpColVector q(2) ;
76 
77  vpERROR_TRACE(" ") ;
78 
80 
81  q = 0;
82  vpCTRACE << "Set position in the articular frame: " << q.t();
84 
85  q[0] = vpMath::rad(10);
86  q[1] = vpMath::rad(20);
87  vpCTRACE << "Set position in the articular frame: " << q.t();
89 
90  vpColVector qm(2) ;
92  vpCTRACE << "Position in the articular frame " << qm.t() ;
93 
94  vpColVector qdot(2) ;
96 #if 0
97  qdot = 0 ;
98  qdot[0] = vpMath::rad(10) ;
99  qdot[1] = vpMath::rad(10) ;
100  vpCTRACE << "Set camera frame velocity " << qdot.t() ;
101 
102  robot.setVelocity(vpRobot::CAMERA_FRAME, qdot) ;
103  sleep(2) ;
104 
105  qdot = 0 ;
106  qdot[0] = vpMath::rad(-10) ;
107  qdot[1] = vpMath::rad(-10) ;
108 
109  vpCTRACE << "Set camera frame velocity " << qdot.t() ;
110  robot.setVelocity(vpRobot::CAMERA_FRAME, qdot) ;
111  sleep(2) ;
112 #endif
113 
114  qdot = 0 ;
115  // qdot[0] = vpMath::rad(0.1) ;
116  qdot[1] = vpMath::rad(10) ;
117  vpCTRACE << "Set articular frame velocity " << qdot.t() ;
119  sleep(2) ;
120 
121  qdot = 0 ;
122  qdot[0] = vpMath::rad(-5);
123  //qdot[1] = vpMath::rad(-5);
124 
125  vpCTRACE << "Set articular frame velocity " << qdot.t() ;
127  sleep(2) ;
128  }
129  catch (...)
130  {
131  std::cout << "Sorry PtU46 not available ..." << std::endl;
132  }
133 
134  return 0;
135 
136 }
137 #else
138 int
139 main()
140 {
141  vpERROR_TRACE("You do not have a ptu-46 robot connected to your computer...");
142  return 0;
143 }
144 
145 #endif
void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q)
#define vpERROR_TRACE
Definition: vpDebug.h:395
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &q_dot)
void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q)
Initialize the position controller.
Definition: vpRobot.h:71
vpRobot::vpRobotStateType setRobotState(vpRobot::vpRobotStateType newState)
#define vpCTRACE
Definition: vpDebug.h:341
Initialize the velocity controller.
Definition: vpRobot.h:70
Interface for the Directed Perception ptu-46 pan, tilt head .
Definition: vpRobotPtu46.h:88
static double rad(double deg)
Definition: vpMath.h:100
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72