Visual Servoing Platform  version 3.4.0
movePtu46.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 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  }
121  catch (const vpException &e) {
122  std::cout << "Sorry PtU46 not available. Got exception: " << e << std::endl;
123  return EXIT_FAILURE
124  }
125  return EXIT_SUCCESS;
126 }
127 #else
128 int main()
129 {
130  std::cout << "You do not have an PTU46 PT robot connected to your computer..." << std::endl;
131  return EXIT_SUCCESS;
132 }
133 
134 #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:67
error that can be emited by ViSP classes.
Definition: vpException.h:71
vpRobot::vpRobotStateType setRobotState(vpRobot::vpRobotStateType newState)
Initialize the velocity controller.
Definition: vpRobot.h:66
Interface for the Directed Perception ptu-46 pan, tilt head .
Definition: vpRobotPtu46.h:80
static double rad(double deg)
Definition: vpMath.h:110
#define vpCTRACE
Definition: vpDebug.h:338
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130