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