Visual Servoing Platform  version 3.1.0
movePtu46.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Tests the control law
33  *
34  * Authors:
35  * Fabien Spindler
36  *
37  *****************************************************************************/
53 #include <visp3/core/vpConfig.h>
54 #include <visp3/core/vpDebug.h>
55 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
56 #include <unistd.h>
57 #endif
58 
59 #ifdef VISP_HAVE_PTU46
60 
61 #include <visp3/robot/vpRobotPtu46.h>
62 
63 int main()
64 {
65  try {
66  vpRobotPtu46 robot;
67  vpColVector q(2);
68 
69  vpERROR_TRACE(" ");
70 
72 
73  q = 0;
74  vpCTRACE << "Set position in the articular frame: " << q.t();
76 
77  q[0] = vpMath::rad(10);
78  q[1] = vpMath::rad(20);
79  vpCTRACE << "Set position in the articular frame: " << q.t();
81 
82  vpColVector qm(2);
84  vpCTRACE << "Position in the articular frame " << qm.t();
85 
86  vpColVector qdot(2);
88 #if 0
89  qdot = 0 ;
90  qdot[0] = vpMath::rad(10) ;
91  qdot[1] = vpMath::rad(10) ;
92  vpCTRACE << "Set camera frame velocity " << qdot.t() ;
93 
94  robot.setVelocity(vpRobot::CAMERA_FRAME, qdot) ;
95  sleep(2) ;
96 
97  qdot = 0 ;
98  qdot[0] = vpMath::rad(-10) ;
99  qdot[1] = vpMath::rad(-10) ;
100 
101  vpCTRACE << "Set camera frame velocity " << qdot.t() ;
102  robot.setVelocity(vpRobot::CAMERA_FRAME, qdot) ;
103  sleep(2) ;
104 #endif
105 
106  qdot = 0;
107  // qdot[0] = vpMath::rad(0.1) ;
108  qdot[1] = vpMath::rad(10);
109  vpCTRACE << "Set articular frame velocity " << qdot.t();
111  sleep(2);
112 
113  qdot = 0;
114  qdot[0] = vpMath::rad(-5);
115  // qdot[1] = vpMath::rad(-5);
116 
117  vpCTRACE << "Set articular frame velocity " << qdot.t();
119  sleep(2);
120  } catch (...) {
121  std::cout << "Sorry PtU46 not available ..." << std::endl;
122  }
123 
124  return 0;
125 }
126 #else
127 int main()
128 {
129  vpERROR_TRACE("You do not have a ptu-46 robot connected to your computer...");
130  return 0;
131 }
132 
133 #endif
void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q)
#define vpERROR_TRACE
Definition: vpDebug.h:393
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:68
vpRobot::vpRobotStateType setRobotState(vpRobot::vpRobotStateType newState)
Initialize the velocity controller.
Definition: vpRobot.h:67
Interface for the Directed Perception ptu-46 pan, tilt head .
Definition: vpRobotPtu46.h:80
static double rad(double deg)
Definition: vpMath.h:102
#define vpCTRACE
Definition: vpDebug.h:338
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72